7 changed files with 143 additions and 3 deletions
  1. 24 3
      js/09/index.html
  2. 11 0
      js/10/index.html
  3. 19 0
      js/10/script.js
  4. 24 0
      js/11/index.html
  5. 0 0
      js/11/style.css
  6. 58 0
      js/чат/index.html
  7. 7 0
      js/чат/style.css

+ 24 - 3
js/09/index.html

@@ -52,12 +52,33 @@
             ram: 2,
             color: "black",
         };
-        function filter(arr) {
+        function filter(arr, func) {
             for (let k in arr) {
-                return 
+                if (!func(k, arr[k])) {
+                    delete arr[k]
+                } 
             }
+            return arr;
         }
-        filter(phone,(key,value));
+        console.log(filter(phone, (key, value) => key == "color" || value == 2));
+
+        //=====================================================================================================================//
+
+        //=============================================== object map ==========================================================//
+
+        const map = function (obj, func) {
+            let objNew = {};
+            for (let key in obj) {
+                objNew = { ...objNew, ...func(key, obj[key]) };
+            }
+            return objNew;
+        };
+
+        let testObj = map({ name: "Иван", age: 17 }, function (key, value) {
+            var result = {};
+            result[key + "_"] = value + "$";
+            return result;
+        });
     </script>
 </body>
 </html>

+ 11 - 0
js/10/index.html

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

+ 19 - 0
js/10/script.js

@@ -0,0 +1,19 @@
+//                                      makeProfileTimer
+
+
+
+makeProfileTimer = function () {
+    let t = performance.now();
+    return function () {
+        return performance.now() - t;
+    };
+};
+
+// var timer = makeProfileTimer();
+// alert("Замеряем время работы этого alert");
+// alert(`Время работы кода составило ${timer()} милисекунд`);
+
+//============================================================================================
+
+//                                      makeSaver
+

+ 24 - 0
js/11/index.html

@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <link rel="stylesheet" href="./style.css">
+    <title>Document</title>
+</head>
+<body>
+   
+    <script>
+        function Password(parent, open = true){
+            
+            this.inputPassword = document.createElement("input");
+            parent.append(this.inputPassword);
+            this.inputPassword.placeholder = 'password';
+            
+            this.checkbox = document.createElement("input");
+            parent.append(this.inputPassword);
+            this.checkbox.type = 'checked';
+    }
+    </script>
+</body>
+</html>

+ 0 - 0
js/11/style.css


+ 58 - 0
js/чат/index.html

@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <link rel="stylesheet" href="./style.css">
+    <title>Document</title>
+</head>
+<body>
+    <input type="text" id="nick">
+    <input type="text" id="mess">
+    <button id="btn">submit</button>
+    <div id="chat-history">
+
+    </div>
+    <script>
+        function jsonPost(url, data) {
+        return new Promise((resolve, reject) => {
+        var x = new XMLHttpRequest();   
+        x.onerror = () => reject(new Error('jsonPost failed'))
+        //x.setRequestHeader('Content-Type', 'application/json');
+        x.open("POST", url, true);
+        x.send(JSON.stringify(data))
+
+        x.onreadystatechange = () => {
+            if (x.readyState == XMLHttpRequest.DONE && x.status == 200){
+                resolve(JSON.parse(x.responseText))
+            }
+            else if (x.status != 200){
+                reject(new Error('status is not 200'))
+            }
+        }
+    })
+}
+let btn = document.querySelector('button')
+let myNick = document.querySelector('#nick')
+let myMess = document.querySelector('#mess')
+let chatHistory = document.querySelector('#chat-history')
+btn.onclick = () => {
+    let nickValue = myNick.value;
+    let myMessValue = myMess.value;
+    
+    jsonPost("http://students.a-level.com.ua:10012", {
+        func: 'addMessage', 
+        nick: `${nickValue}`, 
+        message: `${myMessValue}`
+    })
+    myMessValue = '';
+}
+    jsonPost("http://students.a-level.com.ua:10012", {func: "getMessages", messageId: 2900}).then(r => {
+        for (let i in r.data) {
+            chatHistory.innerHTML += `${r.data[i].nick}: ${r.data[i].message} </br>` 
+        }
+    })
+    </script>
+    
+</body>
+</html>

+ 7 - 0
js/чат/style.css

@@ -0,0 +1,7 @@
+#chat-history {
+    width: 100%;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+    flex-direction: column-reverse;
+}