Browse Source

HW js13 part

Ivar 2 years ago
parent
commit
a7a0037207
8 changed files with 139 additions and 9 deletions
  1. 6 1
      js/13/index.html
  2. 22 8
      js/13/index.js
  3. 13 0
      js/14/index.html
  4. 24 0
      js/14/index.js
  5. 13 0
      js/15/index.html
  6. 24 0
      js/15/index.js
  7. 13 0
      js/16/index.html
  8. 24 0
      js/16/index.js

+ 6 - 1
js/13/index.html

@@ -7,7 +7,12 @@
    <title>Document</title>
 </head>
 <body>
-   
+   <div id="formContainer">
+      <input type="text" id="user"/>
+      <input type="text" id="msg"/>
+      <button id="btn"></button>
+      <div id="area"></div>
+   </div>
    <script src="./index.js"></script>
 </body>
 </html>

+ 22 - 8
js/13/index.js

@@ -1,17 +1,31 @@
-htmlTree()
-function htmlTree() {
 
+
+async 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'))
+            }
+        }
+    })
 }
+jsonPost("http://students.a-level.com.ua:10012", {func: 'addMessage', nick: "ууу", message: 'УУУУУУУ'})
+
+
 
-htmlTree()
-function htmlTree() {
 
-}
 
-htmlTree()
-function htmlTree() {
 
-}
 
 htmlTree()
 function htmlTree() {

+ 13 - 0
js/14/index.html

@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+   <meta charset="UTF-8">
+   <meta http-equiv="X-UA-Compatible" content="IE=edge">
+   <meta name="viewport" content="width=device-width, initial-scale=1.0">
+   <title>Document</title>
+</head>
+<body>
+   
+   <script src="./index.js"></script>
+</body>
+</html>

+ 24 - 0
js/14/index.js

@@ -0,0 +1,24 @@
+htmlTree()
+function htmlTree() {
+
+}
+
+htmlTree()
+function htmlTree() {
+
+}
+
+htmlTree()
+function htmlTree() {
+
+}
+
+htmlTree()
+function htmlTree() {
+
+}
+
+htmlTree()
+function htmlTree() {
+
+}

+ 13 - 0
js/15/index.html

@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+   <meta charset="UTF-8">
+   <meta http-equiv="X-UA-Compatible" content="IE=edge">
+   <meta name="viewport" content="width=device-width, initial-scale=1.0">
+   <title>Document</title>
+</head>
+<body>
+   
+   <script src="./index.js"></script>
+</body>
+</html>

+ 24 - 0
js/15/index.js

@@ -0,0 +1,24 @@
+htmlTree()
+function htmlTree() {
+
+}
+
+htmlTree()
+function htmlTree() {
+
+}
+
+htmlTree()
+function htmlTree() {
+
+}
+
+htmlTree()
+function htmlTree() {
+
+}
+
+htmlTree()
+function htmlTree() {
+
+}

+ 13 - 0
js/16/index.html

@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+   <meta charset="UTF-8">
+   <meta http-equiv="X-UA-Compatible" content="IE=edge">
+   <meta name="viewport" content="width=device-width, initial-scale=1.0">
+   <title>Document</title>
+</head>
+<body>
+   
+   <script src="./index.js"></script>
+</body>
+</html>

+ 24 - 0
js/16/index.js

@@ -0,0 +1,24 @@
+htmlTree()
+function htmlTree() {
+
+}
+
+htmlTree()
+function htmlTree() {
+
+}
+
+htmlTree()
+function htmlTree() {
+
+}
+
+htmlTree()
+function htmlTree() {
+
+}
+
+htmlTree()
+function htmlTree() {
+
+}