Browse Source

hw5 in process

Vadym Hlushko 2 years ago
parent
commit
2bbfb47317
2 changed files with 3 additions and 180 deletions
  1. 3 0
      hw5/.vscode/settings.json
  2. 0 180
      hw5/js/main.js

+ 3 - 0
hw5/.vscode/settings.json

@@ -0,0 +1,3 @@
+{
+    "liveServer.settings.port": 5501
+}

+ 0 - 180
hw5/js/main.js

@@ -64,188 +64,8 @@ persons.push(alesha)
 console.log(persons)
 
 //11task
-var table = "";
-table += '<table border = 1>'
-table += '\n\t<tr>'
-table += `\n\t\t<th>\n\t\t\tSurame\n\t\t</th>`
-table += `\n\t\t<th>\n\t\t\tName\n\t\t</th>`
-table += '</tr>'
-for (let i=0; i < persons.length; i++){
-    table += '\n\t<tr>'
-    table += `\n\t\t<td>\n\t\t\t${persons[i]["surname"]}\n\t\t</td>`
-    table += `\n\t\t<td>\n\t\t\t${persons[i]["name"]}\n\t\t</td>`
-    table += '</tr>'
-}
-table += '</table>'
-document.write(table)
-
-//12task
-var table = "";
-table += '<table border = 1>'
-for (let i=0; i < persons.length; i++){
-    table += '\n\t<tr>'
-    for (let key in persons[i]) {
-        table += `\n\t\t<td>\n\t\t\t${persons[i][key]}\n\t\t</td>`
-    }
-    table += '</tr>'
-}
-table += '</table>'
-document.write(table)
-
-//13task
-var table = "";
-table += '<table border = 1>'
-for (let i=0; i < persons.length; i++){
-    if (i%2) {
-        table += '\n\t<tr bgcolor="lightgrey">'
-    }
-    else {table += '\n\t<tr>'}
-    for (let key in persons[i]) {
-        table += `\n\t\t<td>\n\t\t\t${persons[i][key]}\n\t\t</td>`
-    }
-    table += '</tr>'
-}
-table += '</table>'
-document.write(table)
 
-//14task
-var table = "";
-table += '<table border = 1>'
-table += '\n\t<tr bgcolor="#90ee90">'
-for (let key in personsKeys){ 
-    table += `\n\t\t<th>\n\t\t\t${personsKeys[key]}\n\t\t</th>`
-}
-table += '</tr>'
-for (let i=0; i < persons.length; i++){
-    if (i%2) {
-        table += '\n\t<tr bgcolor="lightgrey">'
-    }
-    else {table += '\n\t<tr>'}
-    for (let key in personsKeys) {
-        if (personsKeys[key] in persons[i]) {
-            table += `\n\t\t<td>\n\t\t\t${persons[i][personsKeys[key]]}\n\t\t</td>`
-        }
-        else {
-            table += `\n\t\t<td></td>`
-        }
-    }
-    table += '</tr>'
-}
-table += '</table>'
-document.write(table)
-
-//15task
-var someTree = {
-    tagName: "table", 
-    subTags: [ //vlozhennie tegi
-        {
-            tagName: "tr",
-            subTags: [
-                {
-                    tagName: "td",
-                    text: "some text",
-                },
-                {
-                    tagName: "td",
-                    text: "some text 2",
-                }
-            ]
-        }
-    ],
-    attrs:
-        {
-            border: 1,
-        },
-}
-
-const createHtmlTree = function (objectHtml, tag, attr, content, children) { //object and standart names of keys
-    var strHtmlTree = "";
-    strHtmlTree += `<${objectHtml[tag]}`
-    if (attr in objectHtml) {
-        for (let key in objectHtml[attr]) {
-            strHtmlTree += ` ${key} = "${objectHtml[attr][key]}"`
-        }
-    }
-    strHtmlTree += `>`
-    if (content in objectHtml) {
-        strHtmlTree += objectHtml[content]
-    }
-    if (children in objectHtml) {
-        for (let i=0; i < objectHtml[children].length; i++) {
-            strHtmlTree += createHtmlTree(objectHtml[children][i], tag, attr, content, children)
-        }
-    }
-    if (undefined !== objectHtml[content] || objectHtml[children].length > 0) {
-        strHtmlTree += `</${objectHtml[tag]}>`
-    }
-    return strHtmlTree;
-}
-
-document.write(createHtmlTree(someTree, "tagName", "attrs", "text", "subTags"))
-
-var body = {
-    name: 'body',
-    atr: {},
-    children: [
-        {
-            name: 'div',
-            atr: {},
-            children: [
-                {
-                    name: 'span',
-                    atr: {},
-                    children: [],
-                    content: "Enter a data please:"
-                },
-                {
-                    name: 'br',
-                    atr: {},
-                    children: [],
-                },
-                {
-                    name: "input",
-                    atr: {
-                        id: "name",
-                        type: "text"
-                    },
-                    children: []
-                },
-                {
-                    name: "input",
-                    atr: {
-                        id: "surname",
-                        type: "text"
-                    },
-                    children: []
-                }
-            ]
-        },
-        {
-            name: 'div',
-            atr: {},
-            children: [
-                {
-                    name: "button",
-                    atr: {
-                        id: "ok"
-                    },
-                    children: [],
-                    content: "OK"
-                },
-                {
-                    name: "button",
-                    atr: {
-                        id: "cancel"
-                    },
-                    children: [],
-                    content: "Cancel"
-                }
-            ]
-        }
-    ]
-}
 
-document.write(createHtmlTree(body, "name", "atr", "content", "children"))
 
 //black poyas
 var userHistory = "1111";