Bladeren bron

+ js/05/index.html

ilya_shyian 3 jaren geleden
bovenliggende
commit
ed797049e9
2 gewijzigde bestanden met toevoegingen van 640 en 1 verwijderingen
  1. 1 1
      js/04/index.html
  2. 639 0
      js/05/index.html

+ 1 - 1
js/04/index.html

@@ -35,7 +35,7 @@
             //                         type: "text",
             //                         id: "name",
             //                     },
-            //                     subTags: {},
+            //                     subTags: [],
             //                 },
             //                 {
             //                     tagName: "input",

+ 639 - 0
js/05/index.html

@@ -0,0 +1,639 @@
+<!DOCTYPE html>
+<html lang="en">
+    <head>
+        <meta charset="UTF-8" />
+        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
+        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+        <title>Document</title>
+    </head>
+    <body>
+        <style>
+            tr.striped:nth-child(even) {
+                background: #c1c1c1;
+            }
+        </style>
+        <script>
+//3 PERSONS
+            // let a = {
+            //     name:"name1",
+            //     surname:"surname1"
+            // }
+            // let b = {
+            //     name:"name2",
+            //     surname:"surname2"
+            // }
+            // let c = {
+            //     name:"name3",
+            //     surname:"surname3"
+            // }
+//DIFFERENT FIELDS
+            // let a = {
+            //     name:"name1",
+            //     surname:"surname1",
+            //     age:32,
+            //     sex:"male"
+            // }
+            // let b = {
+            //     name:"name2",
+            //     surname:"surname2",
+            //     age:13,
+            //     fathername:"fathername2"
+            // }
+            // let c = {
+            //     name:"name3",
+            //     surname:"surname3",
+            //     sex:"female",
+            //     age:32
+            // }
+//FIELDS CHECK
+            // let a = {
+            //     name: "name1",
+            //     surname: "surname1",
+            //     age: 32,
+            //     sex: "male",
+            // };
+            // let b = {
+            //     name: "name2",
+            //     surname: "surname2",
+            //     age: 13,
+            //     fathername: "fathername2",
+            // };
+            // let c = {
+            //     name: "name3",
+            //     surname: "surname3",
+            //     sex: "female",
+            //     age: 32,
+            // };
+
+            // let checkOtherFields = (dict) => {
+            //     for (key in dict) {
+            //         if (key != "name" && key != "surname") {
+            //             alert(key + " " + dict[key]);
+            //         }
+            //     }
+            // };
+
+            // checkOtherFields(a);
+            // checkOtherFields(b);
+            // checkOtherFields(c);
+
+//ARRAY OF PERSONS
+
+            // let a = {
+            //     name: "name1",
+            //     surname: "surname1",
+            //     age: 32,
+            //     sex: "male",
+            // };
+            // let b = {
+            //     name: "name2",
+            //     surname: "surname2",
+            //     age: 13,
+            //     fathername: "fathername2",
+            // };
+            // let c = {
+            //     name: "name3",
+            //     surname: "surname3",
+            //     sex: "female",
+            //     age: 32,
+            // };
+
+            // let persons = [a, b, c];
+            // persons[persons.length] = {
+            //     name: "name4",
+            //     surname: "surname4",
+            //     age: 44,
+            // };
+
+//LOOP OF PERSONS
+
+            // let a = {
+            //     name: "name1",
+            //     surname: "surname1",
+            //     age: 32,
+            //     sex: "male",
+            // };
+            // let b = {
+            //     name: "name2",
+            //     surname: "surname2",
+            //     age: 13,
+            //     fathername: "fathername2",
+            // };
+            // let c = {
+            //     name: "name3",
+            //     surname: "surname3",
+            //     sex: "female",
+            //     age: 32,
+            // };
+
+            // let persons = [a, b, c];
+            // persons[persons.length] = {
+            //     name: "name4",
+            //     surname: "surname4",
+            //     age: 44,
+            // };
+
+            // for (let i = 0; i < persons.length; i++) {
+            //     console.log(persons[i]);
+            // }
+
+//LOOP OF NAME AND SURNAME
+
+            // let a = {
+            //     name: "name1",
+            //     surname: "surname1",
+            //     age: 32,
+            //     sex: "male",
+            // };
+            // let b = {
+            //     name: "name2",
+            //     surname: "surname2",
+            //     age: 13,
+            //     fathername: "fathername2",
+            // };
+            // let c = {
+            //     name: "name3",
+            //     surname: "surname3",
+            //     sex: "female",
+            //     age: 32,
+            // };
+
+            // let persons = [a, b, c];
+            // persons[persons.length] = {
+            //     name: "name4",
+            //     surname: "surname4",
+            //     age: 44,
+            // };
+            // for (persone of persons) {
+            //     console.log(persone["name"] + " " + persone.surname);
+            // }
+
+//LOOP OF LOOP OF VALUES
+            // let a = {
+            //     name: "name1",
+            //     surname: "surname1",
+            //     age: 32,
+            //     sex: "male",
+            // };
+            // let b = {
+            //     name: "name2",
+            //     surname: "surname2",
+            //     age: 13,
+            //     fathername: "fathername2",
+            // };
+            // let c = {
+            //     name: "name3",
+            //     surname: "surname3",
+            //     sex: "female",
+            //     age: 32,
+            // };
+
+            // let persons = [a, b, c];
+            // persons[persons.length] = {
+            //     name: "name4",
+            //     surname: "surname4",
+            //     age: 44,
+            // };
+            // for (persone of persons) {
+            //     for (key in persone) {
+            //         console.log(persone[key]);
+            //     }
+            //     console.log("\n");
+            // }
+
+//FULLNAME
+            // let a = {
+            //     name: "name1",
+            //     surname: "surname1",
+            //     age: 32,
+            //     sex: "male",
+            // };
+            // let b = {
+            //     name: "name2",
+            //     surname: "surname2",
+            //     age: 13,
+            //     fathername: "fathername2",
+            // };
+            // let c = {
+            //     name: "name3",
+            //     surname: "surname3",
+            //     sex: "female",
+            //     age: 32,
+            // };
+
+            // let persons = [a, b, c];
+            // persons[persons.length] = {
+            //     name: "name4",
+            //     surname: "surname4",
+            //     age: 44,
+            // };
+
+            // for (persone of persons) {
+            //     persone.fullname = ` ${persone.surname} ${persone.name}`;
+            //     persone.fullname += persone.fathername ? ` ${persone.fathername}` : "";
+            //     console.log(persone.fullname);
+            // }
+
+//SERIALIZE
+
+            // let a = {
+            //     name: "name1",
+            //     surname: "surname1",
+            //     age: 32,
+            //     sex: "male",
+            // };
+            // let b = {
+            //     name: "name2",
+            //     surname: "surname2",
+            //     age: 13,
+            //     fathername: "fathername2",
+            // };
+            // let c = {
+            //     name: "name3",
+            //     surname: "surname3",
+            //     sex: "female",
+            //     age: 32,
+            // };
+
+            // let persons = [a, b, c];
+            // persons[persons.length] = {
+            //     name: "name4",
+            //     surname: "surname4",
+            //     age: 44,
+            // };
+
+            // let jsonStr = JSON.stringify(persons);
+            // console.log(jsonStr);
+
+//DESERIALIZE
+
+            // let a = {
+            //     name: "name1",
+            //     surname: "surname1",
+            //     age: 32,
+            //     sex: "male",
+            // };
+            // let b = {
+            //     name: "name2",
+            //     surname: "surname2",
+            //     age: 13,
+            //     fathername: "fathername2",
+            // };
+            // let c = {
+            //     name: "name3",
+            //     surname: "surname3",
+            //     sex: "female",
+            //     age: 32,
+            // };
+
+            // let persons = [a, b, c];
+            // persons[persons.length] = {
+            //     name: "name4",
+            //     surname: "surname4",
+            //     age: 44,
+            // };
+
+            // persons[persons.length] = JSON.parse(
+            //     '{"name":"name5","surname":"surname5","fathername":"fathername5","age":52,"sex":"male"}'
+            // );
+
+//HTML
+            // let a = {
+            //     name: "name1",
+            //     surname: "surname1",
+            //     age: 32,
+            //     sex: "male",
+            // };
+            // let b = {
+            //     name: "name2",
+            //     surname: "surname2",
+            //     age: 13,
+            //     fathername: "fathername2",
+            // };
+            // let c = {
+            //     name: "name3",
+            //     surname: "surname3",
+            //     sex: "female",
+            //     age: 32,
+            // };
+
+            // let persons = [a, b, c];
+            // persons[persons.length] = {
+            //     name: "name4",
+            //     surname: "surname4",
+            //     age: 44,
+            // };
+
+            // persons[persons.length] = JSON.parse(
+            //     '{"name":"name5","surname":"surname5","fathername":"fathername5","age":52,"sex":"male"}'
+            // );
+
+            // let str = "<table><tr><td>name</td><td>surname</td></tr>";
+
+            // for (persone of persons) {
+            //     str += `<tr><td>${persone.name}</td><td>${persone.surname}</td></tr>`;
+            // }
+            // str += "</table>";
+            // document.write(str);
+
+//HTML OPTIONAL FIELDS
+
+            // let a = {
+            //     name: "name1",
+            //     surname: "surname1",
+            //     age: 32,
+            //     sex: "male",
+            // };
+            // let b = {
+            //     name: "name2",
+            //     surname: "surname2",
+            //     age: 13,
+            //     fathername: "fathername2",
+            // };
+            // let c = {
+            //     name: "name3",
+            //     surname: "surname3",
+            //     sex: "female",
+            //     age: 32,
+            // };
+
+            // let persons = [a, b, c];
+            // persons[persons.length] = {
+            //     name: "name4",
+            //     surname: "surname4",
+            //     age: 44,
+            // };
+
+            // persons[persons.length] = JSON.parse(
+            //     '{"name":"name5","surname":"surname5","fathername":"fathername5","age":52,"sex":"male"}'
+            // );
+
+            // let str = "<table border=1><tr><td>number</td>";
+            // let keys = [];
+            // for (persone of persons) {
+            //     for (key in persone) {
+            //         keys.push(key);
+            //     }
+            // }
+            // keys = [...new Set(keys)];
+
+            // for (key of keys) {
+            //     str += `<td>${key}</td>`;
+            // }
+            // str += "</tr>";
+
+            // for (idx in persons) {
+            //     str += `<tr><td>${idx}</td>`;
+            //     for (key of keys) {
+            //         str += `<td>${persons[idx][key] ?? ""}</td>`;
+            //     }
+            //     str += "</tr>";
+            // }
+            // str += "</table>";
+            // document.write(str);
+
+//HTML TR COLOR
+
+            // let a = {
+            //     name: "name1",
+            //     surname: "surname1",
+            //     age: 32,
+            //     sex: "male",
+            // };
+            // let b = {
+            //     name: "name2",
+            //     surname: "surname2",
+            //     age: 13,
+            //     fathername: "fathername2",
+            // };
+            // let c = {
+            //     name: "name3",
+            //     surname: "surname3",
+            //     sex: "female",
+            //     age: 32,
+            // };
+
+            // let persons = [a, b, c];
+            // persons[persons.length] = {
+            //     name: "name4",
+            //     surname: "surname4",
+            //     age: 44,
+            // };
+
+            // persons[persons.length] = JSON.parse(
+            //     '{"name":"name5","surname":"surname5","fathername":"fathername5","age":52,"sex":"male"}'
+            // );
+
+            // let str = "<table border=1><tr><td>number</td>";
+            // let keys = [];
+            // for (persone of persons) {
+            //     for (key in persone) {
+            //         keys.push(key);
+            //     }
+            // }
+            // keys = [...new Set(keys)];
+
+            // for (key of keys) {
+            //     str += `<td>${key}</td>`;
+            // }
+            // str += "</tr>";
+
+            // for (idx in persons) {
+            //     str += `<tr class = "striped"><td>${idx}</td>`;
+            //     for (key of keys) {
+            //         str += `<td>${persons[idx][key] ?? ""}</td>`;
+            //     }
+            //     str += "</tr>";
+            // }
+            // str += "</table>";
+            // document.write(str);
+
+// HTML TH OPTIONAL
+
+            // let a = {
+            //     name: "name1",
+            //     surname: "surname1",
+            //     age: 32,
+            //     sex: "male",
+            // };
+            // let b = {
+            //     name: "name2",
+            //     surname: "surname2",
+            //     age: 13,
+            //     fathername: "fathername2",
+            // };
+            // let c = {
+            //     name: "name3",
+            //     surname: "surname3",
+            //     sex: "female",
+            //     age: 32,
+            // };
+
+            // let persons = [a, b, c];
+            // persons[persons.length] = {
+            //     name: "name4",
+            //     surname: "surname4",
+            //     age: 44,
+            // };
+
+            // persons[persons.length] = JSON.parse(
+            //     '{"name":"name5","surname":"surname5","fathername":"fathername5","age":52,"sex":"male"}'
+            // );
+
+            // let str = "<table border=1><tr><th>number</th>";
+            // let keys = [];
+            // for (persone of persons) {
+            //     for (key in persone) {
+            //         keys.push(key);
+            //     }
+            // }
+            // keys = [...new Set(keys)];
+
+            // keys.sort();
+
+            // for (key of keys) {
+            //     str += `<th>${key}</th>`;
+            // }
+            // str += "</tr>";
+
+            // for (idx in persons) {
+            //     str += `<tr class = "striped"><th>${idx + 1}</th>`;
+            //     for (key of keys) {
+            //         str += `<td>${persons[idx][key] ?? ""}</td>`;
+            //     }
+            //     str += "</tr>";
+            // }
+            // str += "</table>";
+            // document.write(str);
+
+
+//ЗАДАНИЕ НА СИНИЙ ПОЯС.
+
+            // let dictHTML = {
+            //     tagName: "body",
+            //     attrs: {},
+            //     subTags: [
+            //         {
+            //             tagName: "div",
+            //             attrs: {},
+            //             subTags: [
+            //                 {
+            //                     tagName: "span",
+            //                     text: "Enter a data please:",
+            //                     attrs: {},
+            //                     subTags: [],
+            //                 },
+            //                 {
+            //                     tagName: "br",
+            //                     attrs: {},
+            //                     subTags: [],
+            //                 },
+            //                 {
+            //                     tagName: "input",
+            //                     attrs: {
+            //                         type: "text",
+            //                         id: "name",
+            //                     },
+            //                     subTags: [],
+            //                 },
+            //                 {
+            //                     tagName: "input",
+            //                     attrs: {
+            //                         type: "text",
+            //                         id: "surname",
+            //                     },
+            //                     subTags: [],
+            //                 },
+            //             ],
+            //         },
+            //         {
+            //             tagName: "div",
+            //             attrs: {},
+            //             subTags: [
+            //                 {
+            //                     tagName: "button",
+            //                     attrs: {
+            //                         id: "ok",
+            //                     },
+            //                     text: "OK",
+            //                     subTags: [],
+            //                 },
+            //                 {
+            //                     tagName: "button",
+            //                     attrs: {
+            //                         id: "cancel",
+            //                     },
+            //                     text: "Cancel",
+            //                     subTags: [],
+            //                 },
+            //             ],
+            //         },
+            //     ],
+            // };
+
+            // function contsractHTML(htmlTree) {
+            //     let str = `<${htmlTree["tagName"]}`;
+            //     for (attrName in htmlTree["attrs"]) {
+            //         str += ` ${attrName}="${htmlTree["attrs"][attrName]}" `;
+            //     }
+            //     str += ">";
+            //     str += htmlTree["text"] ?? "";
+            //     if (htmlTree.subTags) {
+            //         for (tag of htmlTree.subTags) str += contsractHTML(tag);
+            //     }
+
+            //     str += `</${htmlTree["tagName"]}>`;
+
+            //     return str;
+            // }
+
+            // let html = contsractHTML(dictHTML);
+
+            // document.write(html);
+
+//DESTRUCT ARRAY
+
+            // let arr = [1, 2, 3, 4, 5, "a", "b", "c"];
+
+            // let [odd1, even1, odd2, even2, odd3, ...rest] = arr;
+
+//DESTRUCT STRING
+
+            // let arr = [1, "abc"];
+            // let [number, [s1, s2, s3]] = arr;
+
+//DESTRUCT 2
+
+            // let obj = { name: "Ivan", surname: "Petrov", children: [{ name: "Maria" }, { name: "Nikolay" }] };
+
+            // let [{ name: name1 }, { name: name2 }] = obj["children"];
+
+//DESTRUCT 3
+            // let arr = [1, 2, 3, 4, 5, 6, 7, 10];
+
+            // let { 0: a, 1: b, length: length, ...rest } = arr;
+
+//ЗАДАНИЕ НА ЧЕРНЫЙ ПОЯС
+
+            // let history = "1111";
+            // let predictArray = {};
+            // let input;
+            // while (true) {
+            //     console.clear();
+            //     for (el of history) console.log(el);
+            //     if (!(history in predictArray)) {
+            //         console.log("now - " + Math.floor(Math.random() * 2));
+            //     } else {
+            //         console.log("now - " + predictArray[history]);
+            //     }
+            //     input = prompt("Enter the number (1 or 0)");
+            //     if (input === null) break;
+            //     input = +input;
+
+            //     predictArray[history] = input;
+            //     history = history.substr(1);
+            //     history += input;
+            // }
+        </script>
+    </body>
+</html>