Marko 1 rok temu
commit
7d73a08bb2
1 zmienionych plików z 46 dodań i 0 usunięć
  1. 46 0
      index.html

+ 46 - 0
index.html

@@ -0,0 +1,46 @@
+<!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>A-Level</title>
+</head>
+<body>
+    <script>
+        
+        function Password(parent, open){
+    const pass = document.createElement('input')
+    const button = document.createElement('button')
+    const logn = document.createElement('input')
+    pass.placeholder = "Enter your password"
+    logn.placeholder = "Enter your login"
+    button.innerText = 'Hide'
+    parent.prepend(button)
+    parent.prepend(pass)
+    parent.prepend(logn)
+    button.addEventListener('click', () => this.setOpen(!this.open))
+    button.addEventListener('click', () => {
+        button.innerText = (button.innerText === 'Hide') ? button.innerText = 'Show' : button.innerText = 'Hide';
+    })
+this.open = open
+ this .setOpen = (value) => {
+  this.open = value
+        render()
+    }
+    this.getOpen = () => {
+        return this.open
+    }
+    
+    const render = () => {
+        pass.setAttribute('type', `${this.open ? 'text' : 'password'}`);
+        logn.setAttribute('type', `${this.open ? 'text' : 'password'}` );
+    }
+    return render()
+}
+
+let p = new Password(document.body, true)
+    </script>
+</body>
+</html>
+