Daria10 3 년 전
부모
커밋
1510f01199
5개의 변경된 파일305개의 추가작업 그리고 0개의 파일을 삭제
  1. 12 0
      js_homework_09/index.html
  2. 58 0
      js_homework_09/main.js
  3. 12 0
      js_homework_10_oop/index.html
  4. 223 0
      js_homework_10_oop/main.js
  5. 0 0
      test.txt

+ 12 - 0
js_homework_09/index.html

@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+    <script src="main.js"></script>
+</head>
+<body>
+    
+</body>
+</html>

+ 58 - 0
js_homework_09/main.js

@@ -0,0 +1,58 @@
+// /////////////////////////makeProfileTimer
+function makeProfileTimer() {
+    let startTime = performance.now();
+    return function () {
+        return performance.now() - startTime;
+    }
+};
+const timer = makeProfileTimer();
+
+alert('Замеряем время работы этого alert');
+alert(`Time for this alert running is: ${timer()}`);
+
+// ////////////////////// makeSaver
+function makeSaver(func) {
+    let run1 = true;
+    let saveResult;
+    return function () {
+        if (run1) {
+            saveResult = func();
+            run1 = false;
+            console.log(`Result is saved: ${saveResult}`);
+        }
+        return saveResult;
+    }
+}
+
+var saver = makeSaver(Math.random);
+
+var value1 = saver();
+var value2 = saver();
+value1 === value2;
+
+var saver2 = makeSaver(() => console.log('saved function called') || [null, undefined, false, '', 0, Math.random()][Math.ceil(Math.random() * 6)]);
+var value3 = saver2();
+var value4 = saver2();
+
+value3 === value4;
+
+// //////////////////////////Final Countdown
+function finalCountdown() {
+    for (let i = 0; i < 5; i++) {
+        setTimeout(() => console.log(5 - i), 1000 * i)
+    }
+    setTimeout(() => console.log("поехали !"), 5000)
+}
+
+// ////////////////////////////myBind
+function myBind(func, tempThis, tempArray) {
+    return function (...arguments) {
+        let i = 0;
+        let newTempArray = tempArray.map((value) => (value === undefined ? arguments[i++] : value));
+
+        return func.apply(tempThis, newTempArray); 
+    };
+}
+
+
+

+ 12 - 0
js_homework_10_oop/index.html

@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+    <script src="main.js"></script>
+</head>
+<body>
+    <input>
+</body>
+</html>

+ 223 - 0
js_homework_10_oop/main.js

@@ -0,0 +1,223 @@
+//................................Password 
+
+let task1 = document.createElement('div');
+task1.innerText = 'Password'
+task1.className = 'box1';
+document.body.append(task1);
+
+function Password(parent,open = true) {
+  this.inputPassword = document.createElement("input");
+  parent.append(this.inputPassword);
+  this.inputPassword.placeholder = 'password'
+
+  this.buttonShowPassword = document.createElement("button");
+  parent.append(this.buttonShowPassword);
+  this.buttonShowPassword.innerText = "password";
+  this.eye = document.createElement('img');
+  this.buttonShowPassword.append(this.eye);
+
+  if (open) this.eye.src = './images/show.png'
+   else this.eye.src = './images/close.png'
+
+   this.inputPassword.type = open ? "" : "password";
+
+   this.checked = open;
+ 
+   this.setValue = function (data) {
+     this.inputPassword.value = data;
+   };
+ 
+   this.getValue = function () {
+     return this.inputPassword.value;
+   };
+ 
+
+  this.onOpenChange = function () {}  
+
+  this.setOpen = function (boolean) {
+    this.inputPassword.type = boolean ? "" : "password";
+    boolean = this.inputPassword.type;
+    if (this.inputPassword.type == 'password') this.eye.src = './images/close.png'
+    else this.eye.src = './images/show.png'
+    this.onOpenChange(boolean);
+  };
+
+  this.getOpen = function () {
+    return open;
+  };
+ 
+  if (!this.inputPassword.value) this.buttonShowPassword.disabled = false;
+
+  this.onChange = function () {}
+
+  this.inputPassword.oninput  =  (data) => {
+    data = this.inputPassword.value
+    this.onChange(data);
+
+    if (this.inputPassword.value) this.buttonShowPassword.disabled = false;
+    else this.buttonShowPassword.disabled = true;
+
+  }
+  this.checked = open;
+
+  this.buttonShowPassword.onclick = (open) => {
+    this.checked = !this.checked;
+    if (this.inputPassword.type = this.checked) {
+      this.eye.src = './images/show.png'
+    } else this.eye.src = './images/close.png'
+    this.inputPassword.type = this.checked ? "" : "password";
+    open = this.inputPassword.type;
+    this.onOpenChange(open);
+  };
+
+
+}
+
+let taskPassword = new Password(task1)
+
+//................................LoginForm 
+
+let task2 = document.createElement('div');
+task2.innerText = 'LoginForm '
+task2.className = 'box2';
+document.body.append(task2);
+
+
+function LoginForm(parent) {
+  this.inputLogin = document.createElement("input");
+  parent.append(this.inputLogin);
+  this.inputLogin.placeholder = 'login';
+
+  let password = new Password(parent)
+
+  this.buttonLogin = document.createElement('button');
+  parent.append(this.buttonLogin);
+  this.buttonLogin.innerText = 'login';
+
+  this.buttonLogin.disabled = true;
+
+  password.inputPassword.oninput = this.inputLogin.oninput = () => {
+
+    if (password.inputPassword.value && this.inputLogin.value) this.buttonLogin.disabled = false;
+    else this.buttonLogin.disabled = true;
+
+    }
+}
+
+let loginForm = new LoginForm(task2, true);
+
+//................................ FormConstructor
+
+let task3 = document.createElement('div');
+task3.innerText = 'Form Constructor '
+task3.className = 'box3';
+document.body.append(task3);
+
+function FormConstructor(parent,open = true) {
+  
+  this.inputLogin = document.createElement("input");
+  parent.append(this.inputLogin);
+  this.inputLogin.placeholder = 'login';
+
+
+  this.setLogin = function (login) {
+    this.inputLogin.value = login
+  }
+
+  this.getLogin = function(){
+    return this.inputLogin.value
+  }
+
+  this.inputLogin.oninput  =  (data) => {
+    
+  }
+
+  this.inputPassword = document.createElement("input");
+  parent.append(this.inputPassword);
+  this.inputPassword.placeholder = 'password'
+
+  this.buttonShowPassword = document.createElement("button");
+  parent.append(this.buttonShowPassword);
+  this.buttonShowPassword.innerText = "password";
+  this.eye = document.createElement('img');
+  this.buttonShowPassword.append(this.eye);
+
+  if (open) this.eye.src = './images/show.png'
+   else this.eye.src = './images/close.png'
+
+   this.inputPassword.type = open ? "" : "password";
+
+  this.buttonLogin = document.createElement('button');
+  parent.append(this.buttonLogin);
+  this.buttonLogin.innerText = 'login';
+  this.buttonLogin.disabled = true;
+
+   this.checked = open;
+
+   this.setLogin = function (data) {
+    this.inputLogin.value = data;
+  };
+
+  this.getLogin = function () {
+    return this.inputLogin.value;
+  };
+ 
+   this.setPassword = function (data) {
+     this.inputPassword.value = data;
+   };
+ 
+   this.getPassword = function () {
+     return this.inputPassword.value;
+   };
+ 
+
+  this.onOpenChange = function () {}  
+
+  this.setOpen = function (boolean) {
+    this.inputPassword.type = boolean ? "" : "password";
+    boolean = this.inputPassword.type;
+    if (this.inputPassword.type == 'password') this.eye.src = './images/close.png'
+    else this.eye.src = './images/show.png'
+    this.onOpenChange(boolean);
+  };
+
+  this.getOpen = function () {
+    return open;
+  };
+ 
+  if (!this.inputPassword.value) this.buttonShowPassword.disabled = false;
+
+  this.onChangeLogin = function () {}
+
+  this.onChangePassword = function () {}
+
+  this.inputLogin.oninput= this.inputPassword.oninput  =  (data) => {
+    data = this.inputPassword.value
+    this.onChangePassword(data);
+
+    if (!this.inputLogin.value && !this.inputPassword.value) this.buttonLogin.disabled = true;
+    else this.buttonLogin.disabled = false;
+
+    data = this.inputLogin.value
+    this.onChangeLogin(data);
+
+    if (this.inputPassword.value) this.buttonShowPassword.disabled = false;
+    else this.buttonShowPassword.disabled = true;
+
+  }
+  this.checked = open;
+
+  this.buttonShowPassword.onclick = (open) => {
+    this.checked = !this.checked;
+    if (this.inputPassword.type = this.checked) {
+      this.eye.src = './images/show.png'
+    } else this.eye.src = './images/close.png'
+    this.inputPassword.type = this.checked ? "" : "password";
+    open = this.inputPassword.type;
+    this.onOpenChange(open);
+  };
+
+}
+
+let formConstructor = new FormConstructor(task3)
+

+ 0 - 0
test.txt