Viktor97 il y a 1 an
commit
db96c043ab
2 fichiers modifiés avec 117 ajouts et 0 suppressions
  1. 15 0
      index.html
  2. 102 0
      index.js

+ 15 - 0
index.html

@@ -0,0 +1,15 @@
+<!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>
+    
+
+
+    <script src="/index.js">  </script>
+</body>
+</html>

+ 102 - 0
index.js

@@ -0,0 +1,102 @@
+
+function Password(parent, open) {
+
+
+    var inputPassword = document.createElement('input')
+    inputPassword.value = "Пароль"
+    document.body.append(inputPassword)
+
+    var inputPassword2 = document.createElement('input')
+    inputPassword2.value = "Пароль"
+    
+    inputPassword2.style.position = 'relative';
+    inputPassword2.style.top = '25px'
+    inputPassword2.style.left = '-427px'
+
+
+    let inputLogin = document.createElement('input')    
+    document.body.append(inputLogin)
+
+    var input2 = document.createElement('input')
+    input2.type = 'checkbox'
+    input2.id = 'chek'    
+    document.body.append(input2)
+
+    var button = document.createElement('button')
+    button.innerHTML = 'Нажать'
+    button.disabled = true
+    document.body.append(button)
+
+    var buttonPassword = document.createElement('button')
+    buttonPassword.innerHTML = 'Пароли совпадают)'
+    buttonPassword.disabled = true
+    buttonPassword.style.position = 'relative';
+    buttonPassword.style.left = '-400px'
+    buttonPassword.style.top = '25px'
+    
+
+    let i = () => {
+      
+     open = !open  
+      if (open) {
+          inputPassword.type = 'text'
+          inputPassword2.type = 'text'
+          inputPassword2.remove()
+          buttonPassword.remove()
+      } else {
+          inputPassword.type = 'password'
+          inputPassword2.type = 'password'
+          document.body.append(inputPassword2)
+          document.body.append(buttonPassword)
+        }
+    }
+    chek.onchange = i
+    this.setOpen = i
+
+    let o = () => {
+
+        if (inputPassword.value === "" || inputLogin.value === "" || inputPassword2.value === "") {
+            button.disabled = true
+            
+        } else {
+            button.disabled = false
+         }
+         
+        }
+
+    inputPassword.onchange = o;
+    inputPassword2.onchange = o;
+    inputLogin.onchange = o;
+    
+    let u = () => {
+
+        if (inputPassword.value === inputPassword2.value) {
+            buttonPassword.disabled = false
+        } else {
+            buttonPassword.disabled = true
+        }
+    
+    }
+
+    inputPassword.oninput = u;
+    inputPassword2.oninput = u;
+    this.setValue = u;
+}
+
+
+
+let p = new Password(document.body, true)
+
+
+
+
+
+
+p.onChange = data => console.log(data)
+p.onOpenChange = open => console.log(open)
+
+p.setValue('qwerty')   // < ------ это не догоняю как сделать , чтобы с консоли поменять
+console.log(p.getValue())
+
+p.setOpen(false)    // < ---- это можно вызвать
+console.log(p.getOpen())