|
@@ -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())
|