123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- var $s, $show, basicKeys = ["text1", "textarea", "menu","select", "check1", "someInput", "numberTable", "hashTable", "checks", "radios", "ediTable"];
- var persons = [{ name: "Ivan",
- surname: "Ivanovv",
- age: "57",
- note: {value: "Buhaet", name: 'ivanovvsTextArea'},
- married: true},
- { name: "Petr",
- surname: "Petroff",
- age: "17",
- note: "Tyolki v golove",
- married: false,
- },
- { name: "Mary",
- surname: "Tester",
- married: true,
- note: "Ovulyashka",
- age: "27"} ];
- setTimeout(function(){
- $s = nbInit({
- text1: "txt",
- textarea: "txt area",
- // p1: "para",
- //menu: {0: "Main", 1: "About Us"},
- menu: ["Main", "About Us", 'yep'],
- select: {"": "--",
- M: "Male",
- F: "Female",
- X: "Xenomorph"},
- check1: true,
- someInput: {type: "number", placeholder: "percents", max: "100", min: "0", value: 50},
- numberTable: [[[1],2,[3],4,5,6],
- [7,8,9,10,11,12],
- [13,14,15,16,17,18],
- [19,20,21,22,23,24]],
- hashTable: persons,
- checks: [
- {check: {name: "first", checked: true},
- description: "first check"},
- {check: {name: "second", checked: false},
- description: "second check"},
- {check: {name: "third", checked: true},
- description: "third check"},
- ],
- radios: [
- {radio: {name: "sexism", value: "M"},
- description: "Male"},
- {radio: {name: "sexism", value: "F", checked: true},
- description: "Female"},
- {radio: {name: "racism", value: "white", checked: true},
- description: "White"},
- {radio: {name: "racism", value: "black"},
- description: "Black"}, ],
- });
- // $s.textarea; $s.select; $s.dzen; $s.check1; $s.note; $s.married; //just for init
- function btnDel(){
- var arr = $s.hashTable.slice();
- var thisLine = this.parentElement.parentElement;
- arr.splice(thisLine.rowIndex -1,1)
- $s.hashTable = arr;
- $s.btnDel = {onclick: btnDel};
- //document.onchange();
- };
- $s.btnDel = {onclick: btnDel};
- $s.addPerson = {onclick: function(){
- var arr = $s.hashTable.slice();
- arr.push(Object.assign({},arr[0]))
- $s.hashTable = arr;
- $s.btnDel = {onclick: btnDel};
-
-
- //var newLine = document.getElementById('hashTable').copy.children[0].cloneNode(true);
- //newLine.nbData = Object.assign({},persons[0]);
- //document.getElementById('hashTable').appendChild(newLine);
- //$s.btnDel = {onclick: btnDel};
- //document.onchange();
- }}
- var ediNumbers = [];
- function ediFunc(){
- if ($s.ediInput){
- this.innerHTML = $s.ediInput;
- }
- else {
- var text = this.innerHTML;
- this.innerHTML = "<input id='ediInput'/>";
- $s.ediInput = text;
- }
- }
- for (var i=0;i<10;i++){
- ediNumbers[i] = [];
- for (var j=0;j<10;j++){
- //ediNumbers[i][j] = [i*j]; //one-level lower trick; uncomment input in html
- //ediNumbers[i][j] = i*j; //read only table
- ediNumbers[i][j] = {ondblclick: ediFunc,
- innerHTML: i*j, //read only table
- }
- }
- }
- $s.ediTable = ediNumbers;
- $show = nbInit({});
- document.onchange();
- },2000);
- function onUpdate(){
- var key = this.parentElement.getElementsByClassName("key")[0].innerHTML;
- var value = this.parentElement.getElementsByClassName("data")[0].value;
- eval(key + value);
- }
- document.onchange = function(evt){
- //$s.state = "";
- //$s.state = JSON.stringify($s, null, 4);
- //
- if (evt && evt.target.className == 'data'){
- return;
- }
-
- var data = [];
- for (var i=0,key=basicKeys[i];i<basicKeys.length;i++,key=basicKeys[i]){
- data.push({key: "$s." + key + " = ", data: JSON.stringify($s[key], null, 4), update: {onclick: onUpdate}});
- }
- $show.rightColumn = data;
- }
|