Przeglądaj źródła

added hw10 tasks with function password done

makstravm 3 lat temu
rodzic
commit
85396c9f0a
4 zmienionych plików z 76 dodań i 22 usunięć
  1. 2 1
      HW10/audio/main.js
  2. 4 2
      HW10/taskHW/index.html
  3. 63 18
      HW10/taskHW/main.js
  4. 7 1
      HW10/taskHW/style.css

+ 2 - 1
HW10/audio/main.js

@@ -84,6 +84,8 @@ green.onchange = setRGB
 const blue = new Control(containerRgb, { min: 0, max: 255, width: 100 })
 blue.onchange = setRGB
 
+
+
 // громкость звука
 const volume = new Control(volMus, {
   value: 1, min: 0, max: 1, width: 100, wheelSpeed: 0.001, step: 0.1
@@ -125,7 +127,6 @@ function regulatorPlayTrack() {
     let reDraw = function () {
       progressTrack.setValue((track.currentTime * 100) / track.duration)
       progressMus.children[0].innerText = `${progressTrack.getValue().toFixed(0)}%`
-      console.log(3);
     }
     // рандом боди при проигрывание
     let glyuk = function () {

+ 4 - 2
HW10/taskHW/index.html

@@ -10,9 +10,11 @@
 
 </head>
 
-<body >
-  
+<body>
 
+  <div class="container">
+    <div id='form' class="form"></div>
+  </div>
   <script src="main.js"></script>
 
 </body>

+ 63 - 18
HW10/taskHW/main.js

@@ -1,13 +1,15 @@
 function Password(parent, open = false) {
 
+  let wrap = document.createElement('div')
   let input = document.createElement('input')
   let checkBox = document.createElement('input')
+
   input.type = open ? 'text' : 'password'
   checkBox.type = 'checkbox'
   checkBox.checked = open
-  parent.append(input)
-  parent.append(checkBox)
-
+  wrap.append(input)
+  wrap.append(checkBox)
+  parent.append(wrap)
   this.getValue = () => input.value
   this.getOpen = () => checkBox.checked
 
@@ -25,18 +27,61 @@ function Password(parent, open = false) {
   }
 }
 
-let p = new Password(document.body, true)
-p.onChange = () => console.log(p.getValue())
-p.onOpenChange = (open) => console.log(open)
-p.setValue('qwerty')
-console.log(p.getValue())
-
-let login = new Password(document.body, false)
-let button = document.createElement('button')
-button.setAttribute('disabled', 'disabled')
-button.innerText = 'LogIn'
-document.body.append(button)
-
-let checkDisabled = () => p.getValue() !== '' && p.getValue() !== '' ? button.removeAttribute('disabled', 'disabled') : button.setAttribute('disabled', 'disabled')
-p.onChange = () => checkDisabled()
-login.onChange = () => checkDisabled()
+// let p = new Password(document.body, true)
+// p.onChange = () => console.log(p.getValue())
+// p.onOpenChange = (open) => console.log(open)
+// p.setValue('qwerty')
+// console.log(p.getValue())
+
+// let button = document.createElement('button')
+// let input = document.createElement('input')
+// input.type = 'text'
+// button.disabled = true
+// button.innerText = 'LogIn'
+// document.body.append(input)
+// document.body.append(button)
+
+// let checkDisabled = () => input.value !== '' && p.getValue() !== '' ? button.disabled = false : button.disabled = true
+// p.onChange = () => checkDisabled()
+// input.oninput = () => checkDisabled()
+
+function LoginForm(parent, disabled) {
+  const input = document.createElement('input')
+  const btn = document.createElement('button')
+  input.type = 'text'
+  btn.disabled = disabled
+  btn.innerText = 'LogIn'
+  this.getValue = () => input.value
+  this.setValue = (newValue) => input.value = newValue
+
+  input.oninput = () => this.onChange()
+
+  this.getOpen = () => btn.disabled
+  this.setOpen = (newChek) => btn.disabled = newChek
+
+  parent.append(input)
+  parent.append(btn)
+}
+let lf = new LoginForm(form, true)
+let psw = new Password(form, true)
+
+let checkDisabled = () => lf.getValue() !== '' && psw.getValue() !== '' ? lf.setOpen(false) : lf.setOpen(true)
+lf.onChange = () => checkDisabled()
+psw.onChange = () => checkDisabled()
+
+//Password Verifyd
+function pswInputChange() {
+  const pswInputDouble = document.createElement('input')
+  psw.onOpenChange = (chek) => {
+    debugger
+    if (!chek) {
+      pswInputDouble.type = psw.setOpen()
+      pswInputDouble.value = psw.getValue()
+      pswInputDouble.checked = psw.getOpen()
+      form.append(pswInputDouble)
+    } else {
+      pswInputDouble.remove()
+    }
+  }
+}
+pswInputChange()

+ 7 - 1
HW10/taskHW/style.css

@@ -8,5 +8,11 @@ body {
 .container {
   max-width: 1200px;
   padding: 15px;
-  text-align: center;
+}
+button{
+  cursor: pointer;
+}
+input {
+  margin-bottom: 15px;
+  margin-right: 10px;
 }