Browse Source

HW_14 test2

Graf15 2 years ago
parent
commit
a9a4f8be17
1 changed files with 12 additions and 14 deletions
  1. 12 14
      js/js_14_foop/index.js

+ 12 - 14
js/js_14_foop/index.js

@@ -200,7 +200,7 @@ console.log(b.getFullName()) //Анна Иванова*/
     }
 }
 
-/*Password*/
+
 /*Password*/
 {
     function Password(parent, open) {
@@ -213,7 +213,7 @@ console.log(b.getFullName()) //Анна Иванова*/
         
         this.setValue = (value) => {
             inputPass.value = value
-            if (typeof this.onChange === 'function') this.onChange() // запускается по событию oninput в поле ввода, передает текст в колбэк
+            if (typeof this.onChange === 'function') this.onChange(this.getValue()) // запускается по событию oninput в поле ввода, передает текст в колбэк
         }      //задает значение
         this.getValue = () => inputPass.value                   //читает значение
         this.setOpen = (open) => {
@@ -225,12 +225,12 @@ console.log(b.getFullName()) //Анна Иванова*/
                 checkboxPass.checked = false
                 inputPass.type = "password"
             }
-            if (typeof this.onOpenChange === 'function') this.onOpenChange() // запускается по изменению состояния открытости пароля
+            if (typeof this.onOpenChange === 'function') this.onOpenChange(this.getOpen()) // запускается по изменению состояния открытости пароля
         } //задает открытость текста в поле ввода
         this.getOpen = () => checkboxPass.checked //читает открытость текста в поле ввода
 
         this.setOpen(open)
-        inputPass.oninput = () => this.onChange(this.getValue())
+        inputPass.oninput = () => this.setValue(this.getValue())
         checkboxPass.oninput = () => this.setOpen(this.getOpen())
 
     }
@@ -269,14 +269,13 @@ onOpenChange - запускается по изменению состояния
 
         const inputPass = document.createElement('input')
         parent.append(inputPass)
-
         const checkboxPass = document.createElement('input')
         checkboxPass.type = 'checkbox'
         parent.append(checkboxPass)
-
+        
         this.setValue = (value) => {
             inputPass.value = value
-            if (typeof this.onChange === 'function') this.onChange() // запускается по событию oninput в поле ввода, передает текст в колбэк
+            if (typeof this.onChange === 'function') this.onChange(this.getValue()) // запускается по событию oninput в поле ввода, передает текст в колбэк
         }      //задает значение
         this.getValue = () => inputPass.value                   //читает значение
         this.setOpen = (open) => {
@@ -288,12 +287,12 @@ onOpenChange - запускается по изменению состояния
                 checkboxPass.checked = false
                 inputPass.type = "password"
             }
-            if (typeof this.onOpenChange === 'function') this.onOpenChange() // запускается по изменению состояния открытости пароля
+            if (typeof this.onOpenChange === 'function') this.onOpenChange(this.getOpen()) // запускается по изменению состояния открытости пароля
         } //задает открытость текста в поле ввода
         this.getOpen = () => checkboxPass.checked //читает открытость текста в поле ввода
 
         this.setOpen(open)
-        inputPass.oninput = () => this.onChange(this.getValue())
+        inputPass.oninput = () => this.setValue(this.getValue())
         checkboxPass.oninput = () => this.setOpen(this.getOpen())
 
     }
@@ -330,14 +329,13 @@ onOpenChange - запускается по изменению состояния
 
             const inputPass = document.createElement('input')
             parent.append(inputPass)
-    
             const checkboxPass = document.createElement('input')
             checkboxPass.type = 'checkbox'
             parent.append(checkboxPass)
-    
+            
             this.setValue = (value) => {
                 inputPass.value = value
-                if (typeof this.onChange === 'function') this.onChange() // запускается по событию oninput в поле ввода, передает текст в колбэк
+                if (typeof this.onChange === 'function') this.onChange(this.getValue()) // запускается по событию oninput в поле ввода, передает текст в колбэк
             }      //задает значение
             this.getValue = () => inputPass.value                   //читает значение
             this.setOpen = (open) => {
@@ -349,12 +347,12 @@ onOpenChange - запускается по изменению состояния
                     checkboxPass.checked = false
                     inputPass.type = "password"
                 }
-                if (typeof this.onOpenChange === 'function') this.onOpenChange() // запускается по изменению состояния открытости пароля
+                if (typeof this.onOpenChange === 'function') this.onOpenChange(this.getOpen()) // запускается по изменению состояния открытости пароля
             } //задает открытость текста в поле ввода
             this.getOpen = () => checkboxPass.checked //читает открытость текста в поле ввода
     
             this.setOpen(open)
-            inputPass.oninput = () => this.onChange(this.getValue())
+            inputPass.oninput = () => this.setValue(this.getValue())
             checkboxPass.oninput = () => this.setOpen(this.getOpen())
     
         }