Ivar vor 2 Jahren
Ursprung
Commit
aeffb95f7f
4 geänderte Dateien mit 98 neuen und 67 gelöschten Zeilen
  1. 5 3
      js/05/index.js
  2. 78 52
      js/08/index.js
  3. 7 4
      js/10/regulator/index.js
  4. 8 8
      js/10/tasks/index.js

+ 5 - 3
js/05/index.js

@@ -278,7 +278,7 @@ function HTMLThOptional() {
    document.write(str)
 }
 
-// HTMLConstructor()
+HTMLConstructor()
 function HTMLConstructor() {
    let body = {
       tagName: 'body',
@@ -337,8 +337,8 @@ function HTMLConstructor() {
             str += ` ${key}="${value}"`
          }
       }
-   str += `>`   
       if (body.children) {
+         str += `>`   
          if (typeof body.children === 'object') {
             for (let obj of body.children) {
 
@@ -389,8 +389,10 @@ function HTMLConstructor() {
          } else {
             str += `${body.children}`
          }
+         str += `</${body.tagName}>`
+      } else {
+         str += `/>`
       }
-   str += `</${body.tagName}>`   
 
    console.log(str)   
    document.write(str)

+ 78 - 52
js/08/index.js

@@ -102,59 +102,85 @@ function sumRec(length, a1, d) {
    }
 }
 
-let body = {
-   tagName: 'body',
-   attrs: {},
-   children: [
-       {   tagName: 'div',
-           attrs: {},
-           children: [
-               {   tagName: 'span',
-                   attrs: {},
-                   children: 'Enter a data please'    
-               },
-               {   tagName: 'br',
-                   attrs: {}
-               },
-               {   tagName: 'input',
-                   attrs: {
-                       type: 'text',
-                       id: 'name'
-                   }
-               },
-               {   tagName: 'input',
-                   attrs: {
-                       type: 'text',
-                       id: 'surname'
-                   }
-               }
-           ]
-       },
-       {   tagName: 'div',
-           attrs: {},
-           children: [
-               {   tagName: 'button',
-                   attrs: {
-                       id: 'ok'
-                   },
-                   children: 'OK'
-               },
-               {   tagName: 'button',
-                   attrs: {
-                       id: 'cansel'
-                   },
-                   children: 'Cancel'
+
+
+htmlTreeRecWrapp()
+function htmlTreeRecWrapp() {
+
+   let body = {
+      tagName: 'body',
+      attrs: {},
+      children: [
+         {   tagName: 'div',
+            attrs: {},
+            children: [
+                  {   tagName: 'span',
+                     attrs: {},
+                     children: 'Enter a data please'    
+                  },
+                  {   tagName: 'br',
+                     attrs: {}
+                  },
+                  {   tagName: 'input',
+                     attrs: {
+                        type: 'text',
+                        id: 'name'
+                     }
+                  },
+                  {   tagName: 'input',
+                     attrs: {
+                        type: 'text',
+                        id: 'surname'
+                     }
+                  }
+            ]
+         },
+         {   tagName: 'div',
+            attrs: {},
+            children: [
+                  {   tagName: 'button',
+                     attrs: {
+                        id: 'ok'
+                     },
+                     children: 'OK'
+                  },
+                  {   tagName: 'button',
+                     attrs: {
+                        id: 'cansel'
+                     },
+                     children: 'Cancel'
+                  }
+            ]
+         }
+      ]
+   }
+   let str = ''
+
+   htmlTreeRec(body, 0)
+   function htmlTreeRec(object, level = 0) {
+
+         str += `<${object.tagName}`
+            if (object.attrs) {
+               for (let [key, value] of Object.entries(object.attrs)) {
+                  str += ` ${key}="${value}"`
                }
-           ]
-       }
-   ]
-}
-// htmlTreeRec(body, 0)
-function htmlTreeRec(object, level = 0) {
-      if (Object.keys(object)) for (const [key, value] of Object.entries(object)) {
+            }
+         if (object.children) {
+            str += `>`   
+            if (typeof object.children === 'object') {
+               for (let child of object.children) {
 
+                  htmlTreeRec(child, level + 1)
 
-         htmlTreeRec(child, level + 1)
-      }
+               }
+            } else {
+               str += `${object.children}`
+            }
+            str += `</${object.tagName}>`
+         } else {
+            str += `/>`
+         }    
+   }
+   console.log(str)   
+   document.write(str)
 }
-

+ 7 - 4
js/10/regulator/index.js

@@ -112,10 +112,13 @@ audio.onloadedmetadata = function() {
     }
     const playControl  = new Control(container2, {min:0, max:audio.duration})
         playControl.onchange = setTime
-    audio.ondurationchange = () => {
-        console.log(audio.currentTime)
-        playControl.setValue(audio.currentTime)
-    }
+    // setInterval(() => {
+    //     playControl.setValue(audio.currentTime)
+    // }, 10000);
+    // audio.ontimeupdate = (e) => {
+    //     e.preventDefault()
+    //     console.log(audio.currentTime)
+    // }
 }
 
 

+ 8 - 8
js/10/tasks/index.js

@@ -62,8 +62,8 @@ function passwordWrapp() {
 }
 
 
-// loginFormWrapp()
-function loginFormWrapp() {
+// loginFormWrapp2()
+function loginFormWrapp2() {
 
    function LoginForm(parent=document.body, open=false) {
 
@@ -147,8 +147,8 @@ function loginFormWrapp() {
 }
 
 
-// loginFormConstructorWrapp()
-function loginFormConstructorWrapp() {
+// loginFormConstructorWrapp2()
+function loginFormConstructorWrapp2() {
 
    function LoginForm(parent=document.body, open=false) {
 
@@ -249,8 +249,8 @@ function loginFormConstructorWrapp() {
 }
 
 
-// passwordVerifyWrapp()
-function passwordVerifyWrapp() {
+// passwordVerifyWrapp2()
+function passwordVerifyWrapp2() {
 
    function LoginForm(parent=document.body, open=false) {
 
@@ -387,8 +387,7 @@ function formWrapp() {
           formBody.appendChild(cancelButton);
           cancelButton.onclick = cancelCallback
       }
-   
-      
+            
       let inputCreators = {
          String(key, value, oninput){
              let input = document.createElement('input')
@@ -408,6 +407,7 @@ function formWrapp() {
          Date(key, value, oninput){
              let input = document.createElement('input')
              input.type = 'datetime-local'
+             // при преобразовании объекта к строке смещается часовой пояс на нулевой, выражение ниже восстанавливает текущий
              input.value       = new Date(value - (new Date()).getTimezoneOffset() * 60 * 1000).toISOString().slice(0,-1)
              input.oninput     = () => oninput(new Date(input.value))
              return input