main.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. //html tree
  2. /*let body = {
  3. tagName:'body',
  4. paired: true,
  5. attrs:{},
  6. subTags: [
  7. {
  8. tagName:'div',
  9. paired:true,
  10. subTags: [
  11. {
  12. tagName:'span',
  13. paired:true,
  14. text:'Enter a data please',
  15. },
  16. {
  17. tagName:'br',
  18. paired:true,
  19. attrs:{},
  20. },
  21. {
  22. tagName:'input',
  23. paired:true,
  24. attrs:{
  25. type:'text',
  26. id:'name',
  27. },
  28. },
  29. {
  30. tagName:'input',
  31. paired:true,
  32. attrs:{
  33. type:'text',
  34. id:'surname', //body.subTags[0].subTags[3].attrs.id
  35. },
  36. }
  37. ]
  38. },
  39. {
  40. tagName:'div',
  41. paired:true,
  42. subTags:[
  43. {
  44. tagName:'button',
  45. paired:true,
  46. attrs:{
  47. id:'ok',
  48. text:'ok',
  49. },
  50. tagName:'button', //body.subTags[1].subTags[0].attrs.text
  51. paired:true,
  52. attrs:{
  53. id:'cancel',
  54. text:'Cancel',
  55. },
  56. }
  57. ]
  58. }
  59. ]
  60. }*/
  61. //declarative fields
  62. /*let notebook = {
  63. brand: prompt('Введите название'),
  64. type: prompt('Введите id'),
  65. model: prompt('Введите модель'),
  66. ram: prompt('Введите кол-во ram'),
  67. size: confirm('Вас устроит size-14?') || prompt('Введите данные size'),
  68. weight: confirm('Вас устриоть weight 16?') || prompt('Введите данные weight'),
  69. resolution: {
  70. width: 1920,
  71. height: 1080,
  72. },
  73. };
  74. console.log(notebook)
  75. let phone = {
  76. brand: "meizu",
  77. model: "m2",
  78. ram: 2,
  79. color: "black",
  80. };
  81. let person = {
  82. name: "Donald",
  83. surname: "Trump",
  84. married: true,
  85. }*/
  86. //object links
  87. /*var notebook = {
  88. brand: "HP",
  89. type: "440 G4",
  90. model: "Y7Z75EA",
  91. ram: 4,
  92. size: "14",
  93. weight: 1.8,
  94. resolution: {
  95. width: 1920,
  96. height: 1080,
  97. },
  98. };
  99. var phone = {
  100. brand: "meizu",
  101. model: "m2",
  102. ram: 2,
  103. color: "black",
  104. };
  105. var person = {
  106. name: "Donald",
  107. surname: "Trump",
  108. married: true,
  109. }
  110. person.smartphone=phone;
  111. person.laptop=notebook;
  112. phone.owner=person;
  113. notebook.owner=person;
  114. console.log(person.smartphone.owner.laptop.owner.smartphone == person.smartphone)*/
  115. //imperative array fill 3
  116. /*var arr = [];
  117. arr[0] = prompt('Введите элемент')
  118. arr[1] = prompt('Введите элемент')
  119. arr[2] = prompt('Введите элемент')
  120. */
  121. //while confirm
  122. /*let con = true;
  123. do{
  124. con = confirm()
  125. }while(!con)*/
  126. //array fill
  127. /*arr = [];
  128. a = prompt('Введит элемент')
  129. while(a){
  130. arr.push(a)
  131. a = prompt('Введите элемент')
  132. }*/
  133. //array fill nopush
  134. /*arr = []
  135. a = prompt('Введит элемент')
  136. let b = 0;
  137. while(a){
  138. arr[b++] = a;
  139. a = prompt('Введите элемент')
  140. } */
  141. //infinite probability
  142. /*let cons = 0;
  143. while(true){
  144. if(Math.random() > 0.9){
  145. alert(cons)
  146. break;
  147. }
  148. else{
  149. cons++
  150. }
  151. }*/
  152. //empty loop
  153. /*while(prompt() == null){
  154. }*/
  155. // progression sum
  156. /*let Num;
  157. for(let i = 1;i < 30 ;i = i +3){
  158. alert(i)
  159. }*/
  160. //chess one line
  161. /*let size = prompt('Введите число')
  162. var Symbol = "";
  163. for (let a = 0; a < size; a++){
  164. if((a + size)% 2 == 0)
  165. Symbol +="#"
  166. else
  167. Symbol +="#";
  168. }
  169. console.log(Symbol)*/
  170. //numbers
  171. /*let Num = "\n";
  172. for (let i = 0; i < 10; i++) {
  173. for (let j = 0; j < 10; j++) {
  174. Num +=j;
  175. }
  176. Num +="\n";
  177. }*/
  178. // chess
  179. /*let size = 10;
  180. var Symbol = "";
  181. for (let a = 0; a < size; a++){
  182. for(let b = 0; b <6; b++){
  183. if((a + b)% 2 == 0)
  184. Symbol +=".#."
  185. else
  186. Symbol +="#";
  187. }
  188. Symbol +="\n";
  189. }
  190. console.log(Symbol)*/
  191. //cubes
  192. /*var numbers = [1, 2, 3, 4, 5];
  193. var cubes = new Array;
  194. for (i in numbers) {
  195. cubes[i] = Math.pow(numbers[i], 3);
  196. alert(cubes)
  197. }*/
  198. //multiply table
  199. /*let arr = [];
  200. for(let i = 0; i <= 10; i++ ){
  201. arr[i] = [];
  202. for (let j = 0; j <= 10; j++ ){
  203. arr[i][j] = i * j;
  204. }
  205. }
  206. let sum = '';
  207. for (let i = 1; i < 10; i++) {
  208. sum += arr[i].slice(1).join(' ') + '\n';
  209. }
  210. console.log(arr);*/
  211. //matrix to html table
  212. /*var table, row, cell, i, j;
  213. var table, row, cell, i, j;
  214. table = document.createElement('table');
  215. table.style.textAlign = 'right';
  216. table.style.fontFamily = 'monospace';
  217. for (i=1; i<10; i++) {
  218. row = document.createElement('tr');
  219. for (j=1; j<10; j++) {
  220. cell = document.createElement(i == 1 || j == 1 ? 'th' : 'td');
  221. cell.appendChild(document.createTextNode(i*j));
  222. cell.style.padding = '4px';
  223. cell.style.width = 100 / 9 + '%';
  224. row.appendChild(cell);
  225. }
  226. table.appendChild(row);
  227. }
  228. document.body.appendChild(table);*/