Gennadysht пре 2 година
родитељ
комит
c3f0d3d40d
1 измењених фајлова са 0 додато и 76 уклоњено
  1. 0 76
      js/15_Recurs/hw_15_04_1_string .html

+ 0 - 76
js/15_Recurs/hw_15_04_1_string .html

@@ -1,76 +0,0 @@
-<header>
-    HTML Tree
-</header>
-
-<body>
-    <script>
-        function walker(parent) {
-            let str = "";
-            let tagName = parent.tagName;
-            if (tagName) {
-                str = '{';
-                str += `"tagName":"${tagName}",`;
-                let attrs = parent.attrs;
-                if (attrs) {
-                    str += '"attrs":{';
-                    let attrsArr = [];
-                    for (const attrName in attrs) {
-                        attrsArr.push(`"${attrName}":"${attrs[attrName]}"`);
-                    }
-                    str += attrsArr.join(',');
-                    str += '},';
-                }
-                if (parent.children) {
-                    str += '"children":['
-                    let childrenArr = [];
-                    for (const child of parent.children) {
-                        childrenArr.push(walker(child)); //вложенный вызов - вложенный уровень вложенности :-D
-                    }
-                    str += childrenArr.join(',');
-                    str += ']';
-                }
-                str += '}';
-            }
-            else {
-                str = `"${parent}"`;
-            }
-            return str;
-        }
-        const table = {
-            tagName: 'table',
-            attrs: {
-                border: "1",
-            },
-            children: [
-                {
-                    tagName: 'tr',
-                    children: [
-                        {
-                            tagName: "td",
-                            children: ["1x1"],
-                        },
-                        {
-                            tagName: "td",
-                            children: ["1x2"],
-                        },
-                    ]
-                },
-                {
-                    tagName: 'tr',
-                    children: [
-                        {
-                            tagName: "td",
-                            children: ["2x1"],
-                        },
-                        {
-                            tagName: "td",
-                            children: ["2x2"],
-                        },
-                    ]
-                }
-            ]
-        }
-        var objStr = walker(table);;
-        document.write(walker(objStr));
-    </script>
-</body>