|
@@ -0,0 +1,85 @@
|
|
|
+//-------------------------------------------------------Password--------------------------------------------------------------------
|
|
|
+
|
|
|
+function Password(parent, open = false) {
|
|
|
+ let password = document.createElement("input");
|
|
|
+ parent.append(password);
|
|
|
+ password.setAttribute("type", open ? "text" : "password");
|
|
|
+ let showPassword = document.createElement("input");
|
|
|
+ parent.append(showPassword);
|
|
|
+ showPassword.setAttribute("type", "checkbox");
|
|
|
+
|
|
|
+ showPassword.checked = open;
|
|
|
+
|
|
|
+ showPassword.onclick = () => {
|
|
|
+ password.setAttribute("type", showPassword.checked ? "text" : "password");
|
|
|
+ }
|
|
|
+
|
|
|
+ password.oninput = () => {
|
|
|
+ this.onChange(password.value);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.onChange = () => {};
|
|
|
+
|
|
|
+ this.setPassword = function (someVal) {
|
|
|
+ password.value = someVal;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.getPassword = function () {
|
|
|
+ return password.value;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+let form1 = new Password(task1, true);
|
|
|
+
|
|
|
+form1.setPassword("qwerty");
|
|
|
+
|
|
|
+console.log(form1.getPassword());
|
|
|
+
|
|
|
+//-------------------------------------------------------LoginForm--------------------------------------------------------------------
|
|
|
+
|
|
|
+function Password2(parent, open = false) {
|
|
|
+ let password = document.createElement("input");
|
|
|
+ parent.append(password);
|
|
|
+ password.setAttribute("type", open ? "text" : "password");
|
|
|
+ password.setAttribute("placeholder", "Password");
|
|
|
+
|
|
|
+ let showPassword = document.createElement("input");
|
|
|
+ parent.append(showPassword);
|
|
|
+ showPassword.setAttribute("type", "checkbox");
|
|
|
+
|
|
|
+ let login = document.createElement("input");
|
|
|
+ parent.append(login);
|
|
|
+ login.setAttribute("type", "text");
|
|
|
+ login.setAttribute("placeholder", "Login");
|
|
|
+
|
|
|
+ let loginButton = document.createElement("button");
|
|
|
+ parent.append(loginButton);
|
|
|
+ loginButton.innerText = "__OK__";
|
|
|
+ loginButton.disabled = true;
|
|
|
+
|
|
|
+ showPassword.checked = open;
|
|
|
+
|
|
|
+ showPassword.onclick = () => {
|
|
|
+ password.setAttribute("type", showPassword.checked ? "text" : "password");
|
|
|
+ }
|
|
|
+
|
|
|
+ password.oninput = () => {
|
|
|
+ this.onChange(password.value);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.onChange = () => {};
|
|
|
+
|
|
|
+ this.setPassword = function (someVal) {
|
|
|
+ password.value = someVal;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.getPassword = function () {
|
|
|
+ return password.value;
|
|
|
+ }
|
|
|
+
|
|
|
+ // if(password.value && login.value) {
|
|
|
+ // loginButton.disabled = falce;
|
|
|
+ // }
|
|
|
+}
|
|
|
+
|
|
|
+let form2 = new Password2(task2, true);
|