index.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. var $s, $show;
  2. var persons = [{ name: "Ivan",
  3. surname: "Ivanovv",
  4. age: "57",
  5. note: {value: "Buhaet", name: 'ivanovvsTextArea'},
  6. married: true},
  7. { name: "Petr",
  8. surname: "Petroff",
  9. age: "17",
  10. note: "Tyolki v golove",
  11. married: false,
  12. },
  13. { name: "Mary",
  14. surname: "Tester",
  15. married: true,
  16. note: "Ovulyashka",
  17. age: "27"} ];
  18. setTimeout(function(){
  19. $s = nbInit({
  20. text1: "txt",
  21. textarea: "txt area",
  22. // p1: "para",
  23. select: {"": "--",
  24. M: "Male",
  25. F: "Female",
  26. X: "Xenomorph"},
  27. check1: true,
  28. numberTable: [[[1],2,[3],4,5,6],
  29. [7,8,9,10,11,12],
  30. [13,14,15,16,17,18],
  31. [19,20,21,22,23,24]],
  32. hashTable: persons,
  33. checks: [
  34. {check: {name: "first", checked: true},
  35. description: "first check"},
  36. {check: {name: "second", checked: false},
  37. description: "second check"},
  38. {check: {name: "third", checked: true},
  39. description: "third check"},
  40. ],
  41. radios: [
  42. {radio: {name: "sexism", value: "M"},
  43. description: "Male"},
  44. {radio: {name: "sexism", value: "F", checked: true},
  45. description: "Female"},
  46. {radio: {name: "racism", value: "white", checked: true},
  47. description: "White"},
  48. {radio: {name: "racism", value: "black"},
  49. description: "Black"}, ],
  50. });
  51. // $s.textarea; $s.select; $s.dzen; $s.check1; $s.note; $s.married; //just for init
  52. //$s.btn = {onclick: function(){
  53. //var thisLine = this.parentElement.parentElement;
  54. //var newLine = thisLine.cloneNode(true);
  55. //newLine.nbData = Object.assign({},thisLine.nbData);
  56. //thisLine.parentElement.insertBefore(newLine,thisLine);
  57. //$s.btn = {onclick: arguments.callee};
  58. //}};
  59. var ediNumbers = [];
  60. function ediFunc(){
  61. if ($s.ediInput){
  62. this.innerHTML = $s.ediInput;
  63. }
  64. else {
  65. var text = this.innerHTML;
  66. this.innerHTML = "<input id='ediInput'/>";
  67. $s.ediInput = text;
  68. }
  69. }
  70. for (var i=0;i<10;i++){
  71. ediNumbers[i] = [];
  72. for (var j=0;j<10;j++){
  73. //ediNumbers[i][j] = [i*j]; //one-level lower trick; uncomment input in html
  74. //ediNumbers[i][j] = i*j; //read only table
  75. ediNumbers[i][j] = {onclick: ediFunc,
  76. innerHTML: i*j, //read only table
  77. }
  78. }
  79. }
  80. $s.ediTable = ediNumbers;
  81. $show = nbInit({});
  82. document.onchange();
  83. },2000);
  84. function onUpdate(){
  85. var key = this.parentElement.getElementsByClassName("key")[0].innerHTML;
  86. var value = this.parentElement.getElementsByClassName("data")[0].value;
  87. eval(key + value);
  88. }
  89. document.onchange = function(evt){
  90. //$s.state = "";
  91. //$s.state = JSON.stringify($s, null, 4);
  92. //
  93. if (evt && evt.target.className == 'data'){
  94. return;
  95. }
  96. var data = [];
  97. for (key in $s){
  98. data.push({key: "$s." + key + " = ", data: JSON.stringify($s[key], null, 4), update: {onclick: onUpdate}});
  99. }
  100. $show.rightColumn = data;
  101. }