123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323 |
- //password
- // function Password (parent , open) {
- // let passwordInput = document.createElement ('input')
- // let passwordCheckbox = document.createElement('input')
- // let passwordSpan = document.createElement('span')
- // let passwordContent = document.createElement('div')
-
- // parent.append(passwordContent)
- // passwordContent.append(passwordInput)
- // passwordContent.append(passwordCheckbox)
- // passwordContent.append(passwordSpan)
- // passwordContent.style.marginTop = "15px"
- // passwordContent.style.marginBottom = '20px'
- // passwordInput.placeholder = "Enter a password"
-
-
- // passwordCheckbox.type = 'checkbox'
- // passwordCheckbox.style.marginLeft = '10px'
- // passwordSpan.innerHTML = "Hide password"
- // passwordSpan.style.marginLeft = "10px"
-
- // passwordInput.onchange = () => {
- // if(typeof this.onChange === 'function'){
- // this.onChange(passwordInput.value)
- // }
- // }
-
- // function showOrHide() {
- // if (passwordCheckbox.checked) {
- // passwordInput.setAttribute('type' , 'password')
- // } else {
- // passwordInput.setAttribute('type','text')
- // }
- // }
-
- // passwordCheckbox.addEventListener('change' , showOrHide)
-
- // this.setValue = function (text) {
- // passwordInput.value = text
- // }
-
- // this.getValue = function () {
- // return passwordInput.value
- // }
-
- // this.setOpen = function (checker) {
- // showOrHide.call(this)
- // passwordCheckbox.checked = checker
- // }
-
- // passwordCheckbox.onclick = () => {
- // showOrHide()
- // this.onOpenChange("нажали чекбокс")
- // }
-
- // this.getOpen = function () {
- // return passwordCheckbox.checked
- // }
- // }
- // 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())
- // //loginform
- // let loginContent = document.createElement('div')
- // let loginH1 = document.createElement('h1')
- // loginH1.innerHTML = "LoginForm"
- // loginContent.append(loginH1)
- // let password = new Password(loginContent,true)
- // loginContent.querySelector('span').remove()
- // loginContent.querySelector(`input[type="checkbox"]`).remove();
- // loginContent.querySelector(`input`).setAttribute("placeholder", "Enter a login")
-
- // document.body.append(loginContent)
-
- // let pass = new Password(loginContent , false)
- // loginContent.querySelector('input:nth-child(2)').setAttribute('placeholder' , 'Enter a password')
-
-
- // let btn = document.createElement('button')
- // loginContent.append(btn)
- // btn.innerHTML = "Log in"
- // btn.style.marginLeft = '20px';
- // btn.setAttribute('disabled' , 'disabled')
- // pass.onChange = password.onChange = () => {
- // if (pass.getValue() && password.getValue()){
- // btn.removeAttribute('disabled');
- // }else btn.setAttribute('disabled' , 'disabled');
- // }
- // function LoginFormConstructor (parent , open) {
- // let passwordForm = document.createElement('div')
- // let loginForm = document.createElement('div')
- // let btnForm = document.createElement('div')
- // let loginInput = document.createElement('input')
- // loginInput.type = 'text'
- // loginInput.style.marginBottom = '10px'
- // loginInput.placeholder = "Enter a login"
- // let passwordInput = document.createElement('input')
- // passwordInput.type = 'text'
- // passwordInput.placeholder = "Enter a password"
- // let checkbox = document.createElement('input')
- // checkbox.type = 'checkbox'
- // checkbox.style.marginLeft = '7px'
- // let btn = document.createElement('button')
- // btn.style.marginLeft = '130px'
- // btn.style.marginTop = '10px'
- // btn.innerHTML = 'Log in'
- // // btn.setAttribute('disabled' , 'disabled')
- // parent.append(loginForm)
- // parent.append(passwordForm)
- // parent.append(btnForm)
- // loginForm.append(loginInput)
- // passwordForm.append(passwordInput)
- // passwordForm.append(checkbox)
- // btnForm.append(btn)
- // function showOrHide() {
- // if (checkbox.checked) {
- // passwordInput.setAttribute('type' , 'password')
- // } else {
- // passwordInput.setAttribute('type','text')
- // }
- // }
- // checkbox.addEventListener('change' , showOrHide)
- // passwordInput.onchange = () => {
- // if(typeof this.onChange === 'function'){
- // this.onChange(passwordInput.value)
- // }
- // }
-
- // checkbox.onclick = () => {
- // showOrHide()
- // this.onOpenChange("нажали чекбокс")
- // }
-
-
- // this.passwordSetValue = function (text) {
- // passwordInput.value = text
- // }
-
- // this.passwordGetValue = function () {
- // return passwordInput.value
- // }
-
- // this.passwordSetOpen = function (checker) {
- // checkbox.checked = checker
- // showOrHide.call(this)
- // }
-
-
- // this.passwordGetOpen = function () {
- // return checkbox.checked
- // }
- // this.loginSetValue = function (text) {
- // loginInput.value = text
- // }
- // this.loginGetValue = function () {
- // return loginInput.value
- // }
- // // тут не разобрался, как сделать тут прикол с кнопкой
- // // loginInput.onChange = passwordInput.onChange = () => {
- // // if (passwordInput.passwordGetValue() && loginInput.loginGetValue()){
- // // btn.removeAttribute('disabled')
- // // } else btn.setAttribute('disabled' , 'disabled')
- // // }
- // loginInput.onchange = () => {
- // if(typeof this.onChange === 'function'){
- // this.onLoginChange(loginInput.value)
- // }
- // }
- // }
- // let lfc = new LoginFormConstructor(document.body, true)
- // lfc.onChange = data => console.log(data)
- // lfc.onOpenChange = open => console.log(open)
- // lfc.passwordSetValue('qwerty')
- // console.log(lfc.passwordGetValue())
- // lfc.passwordSetOpen(false)
- // console.log(lfc.passwordGetOpen())
- // lfc.loginSetValue('admin')
- // console.log(lfc.loginGetValue())
- // lfc.onLoginChange = something => console.log(something)
- //password verify
- function Password (parent , open) {
- let passwordContent = document.createElement('div')
- let passwordContent2 = document.createElement('div')
- let btnContent = document.createElement('div')
- let h = document.createElement('h1')
- h.innerHTML = "Password Verify"
- let passwordInput = document.createElement ('input')
- let passwordInput2 = document.createElement ('input')
- passwordInput2.value = 'qwerty'
- passwordInput2.type = 'password'
- let passwordCheckbox = document.createElement('input')
- let passwordSpan = document.createElement('span')
- let btn = document.createElement('button')
- btn.innerHTML = 'Log in'
- btn.style.marginTop = '10px'
- btn.style.marginLeft = '120px'
-
-
- parent.style.zIndex = 1
- parent.append(passwordContent)
- h.style.marginTop = '100px'
- parent.append(passwordContent2)
- parent.append(btnContent)
- passwordContent.append(h)
- passwordContent.append(passwordInput)
- passwordContent.append(passwordCheckbox)
- passwordContent.append(passwordSpan)
- passwordContent2.append(passwordInput2)
- passwordContent.style.marginTop = "15px"
- passwordContent.style.marginBottom = '20px'
- passwordInput.placeholder = "Enter a password"
- btnContent.append(btn)
-
-
- passwordCheckbox.type = 'checkbox'
- passwordCheckbox.style.marginLeft = '10px'
- passwordSpan.innerHTML = "Hide password"
- passwordSpan.style.marginLeft = "10px"
-
- function showOrHide() {
- if (passwordCheckbox.checked) {
- passwordInput.setAttribute('type' , 'password')
- } else {
- passwordInput.setAttribute('type','text')
- }
- }
- passwordCheckbox.addEventListener('change' , showOrHide)
- this.passwordSetOpen = function(bool){
- if(bool === false) {
- passwordInput.type = 'password'
- passwordCheckbox.checked = false
- passwordCheckbox.onchange = function() {
- if (passwordInput.type === "password") {
- passwordInput.type = "text";
- }
- else {
- passwordInput.type = 'password'
- }
- if(passwordInput.type === 'text'){
- passwordInput2.hidden = true
- }
- else if (passwordInput.type === 'password') {
- passwordInput2.hidden = false
- }
- }
- }
- else if (bool === true){
- passwordInput.type = 'text'
- passwordCheckbox.checked = true
- passwordCheckbox.onchange = function() {
- if (passwordInput.type === "password") {
- passwordInput.type = "text";
- }
- else {
- passwordInput.type = 'password'
- }
- }
- }
- }
- this.Verify = function () {
- btn.disabled = true
- passwordInput.oninput = passwordInput2.oninput = () => {
- if (passwordInput.value === passwordInput2.value && passwordInput.value != '') {
- btn.disabled = false
- }
- else {
- btn.disabled = true
- }
- }
- }
- }
- let p = new Password(document.body, true)
- p.passwordSetOpen(false)
- p.Verify()
-
|