Browse Source

re dz4, 5(Fn1) 6(dom)

Andrii Kozhyn 2 years ago
parent
commit
8985ec79dd
5 changed files with 423 additions and 11 deletions
  1. 3 11
      HW_js_5/index.html
  2. 34 0
      HW_js_6/index.html
  3. 190 0
      HW_js_6/scriptDz5(function1).js
  4. 34 0
      HW_js_7/index.html
  5. 162 0
      HW_js_7/scriptDZ6Dom.js

+ 3 - 11
HW_js_5/index.html

@@ -8,19 +8,11 @@
     <link rel="stylesheet" href="style.css">
 </head>
 <body>
-  
-     <h3>Обменка $ к UAH</h3>
-     <div class="menu">
-         Отдаете $: <input class="inp" type="number" placeholder="Количество Долларов" onchange="convert(this.value)">
 
-         <button id="cash"> w </button>
-         <p class="get">
-         Получаете:  <span id="out" ></span> uah
-            
-         </p>
-     </div>
-    
 
+
+
+   
     <script src="scriptDz4(objectsInJson).js"></script>
 </body>
 </html>

+ 34 - 0
HW_js_6/index.html

@@ -0,0 +1,34 @@
+<!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>
+    <link rel="stylesheet" href="style.css">
+</head>
+<body>
+
+
+
+
+     <div>
+        
+        <input type="number" id="val">
+        
+         <select name="calcFn" id="calcFn">
+            <option value="pluss" id="pluss"> + </option>
+            <option value ="minuss" id="minuss"> - </option>
+            <option value ="times" id="times"> * </option>
+            <option value = "splitt"id="split"> / </option>
+        </select>
+        <input type="number" id="val2">
+        <div style= "display: inline"> = </div>
+        <input type="number" id="sum">
+         <input type="button" id="calc2" onclick="liveReload()" value="Запуск раcчета">
+        
+    </div>
+   
+    <script src="scriptDz5(function1).js"></script>
+</body>
+</html>

+ 190 - 0
HW_js_6/scriptDz5(function1).js

@@ -0,0 +1,190 @@
+// задание a
+
+// function a(all) {
+//    alert(all);
+// }
+
+// a("Добрый день!")
+
+// // cube
+
+// function cube(b) {
+//     return (b ** 3);
+// }
+
+// // cube(4);
+
+
+
+// // avg2____________________________
+
+// function avg2(a, b) {
+//     return(a+b) / 2;
+// }
+
+// avg2(1,2)
+// avg2(10,5)
+
+
+// sum3_________________________________
+
+// function sum3(a,b,c = 0){
+//     return (a + b + c);
+// }
+
+// console.log(sum3(5,10))
+// console.log(sum3(5,10,100500))
+// console.log(sum3(1,2,3))
+
+// intRandom____________________________
+
+
+// function intRandom(max =0, min = 0) {
+//     return Math.round(Math.random() * (max - min) + min) 
+//  };
+//  console.log (intRandom(0,1))
+
+
+// greetAll_____________________________
+
+// function greetAll() {
+//     let value = `Hello`;
+//     for (let i of arguments) {
+//         value += " " + i + ",";
+//     }
+//     value = value.slice(0, -1);
+//     alert(value);
+//   }
+
+
+//   alert(greetAll("Superman"));
+
+
+// sum__________________________________
+
+
+// function sum3(a, b, c) {
+//     if (c === undefined) {
+//         return (a+b);
+//     }else {
+//         return a + b + c;
+//     };
+// };
+
+// console.log(sum3(2,3,4));
+
+
+// Union
+
+const valueNumber = prompt ("Введите номер задания")
+switch (valueNumber) {
+    case '1' : a()
+
+
+    // задание a
+
+    function a(all) {
+        alert("Добрый день!");
+    }
+
+
+    
+
+    break;
+
+
+    case 'cube' : cube(4)
+
+        function cube(b) {
+            return (b ** 3);
+        }
+
+        console.log(cube(4));
+
+        break;
+
+    case 'avg2' :
+
+        function avg2(a, b) {
+                return(a+b) / 2;
+            }
+            
+           console.log( avg2(1,2));
+           break;
+
+    case 'sum3' :    
+    
+            function sum3(a,b,c = 0){
+            return (a + b + c);
+            }
+
+            console.log(sum3(5,10,100500))
+            break;
+
+    case 'intRandom' :
+        
+            function intRandom(max = 0, min = 0) {
+            return Math.round(Math.random() * (max - min) + min) 
+            };
+            console.log(intRandom(0,1))
+            break;
+
+       case 'greetAll' :
+
+        function greetAll() {
+            let value = `Hello`;
+            for (let i of arguments) {
+                value += " " + i + ",";
+            }
+            value = value.slice(0, -1);
+            alert(value);
+        }
+
+
+        alert(greetAll("Superman"));
+        break;
+
+
+        case 'sum' :
+
+        function sum3(a, b, c) {
+            if (c === undefined) {
+                return (a+b);
+            }else {
+                return a + b + c;
+            };
+        };
+
+        console.log(sum3(2,3,4));
+        break;
+
+}
+
+
+// // unionDeclarative()
+
+// function unionDeclarative() {
+
+//     let value = prompt("укажите номер задания")
+    
+//     function some () {
+//         const result = {
+//             one: function(onchange) {
+//                 return a()
+//             },
+//             cubes: function () {
+//                 return  cube()
+//             },
+
+//             avg21: () => avg2(),
+//             sum44: () => sum3(),
+//             intr:  () => intRandom(),
+//             gta:   () => greetAll(),
+//             sum:   () => sum3(),
+//         }
+//         return result [onchange.toLowerCase()]?.() || console.log("Укажие верное значение")
+//     }
+// }
+
+
+

+ 34 - 0
HW_js_7/index.html

@@ -0,0 +1,34 @@
+<!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>
+    <link rel="stylesheet" href="style.css">
+</head>
+<body>
+
+
+
+
+     <div>
+        
+        <input type="number" id="val">
+        
+         <select name="calcFn" id="calcFn">
+            <option value="pluss" id="pluss"> + </option>
+            <option value ="minuss" id="minuss"> - </option>
+            <option value ="times" id="times"> * </option>
+            <option value = "splitt"id="split"> / </option>
+        </select>
+        <input type="number" id="val2">
+        <div style= "display: inline"> = </div>
+        <input type="number" id="sum">
+         <input type="button" id="calc2" onclick="liveReload()" value="Запуск раcчета">
+        
+    </div>
+   
+    <script src="scriptDZ6Dom.js"></script>
+</body>
+</html>

+ 162 - 0
HW_js_7/scriptDZ6Dom.js

@@ -0,0 +1,162 @@
+// Таблица умножения________________
+
+// let table = document.createElement('table');
+// for (let i = 0; i < 10; i++){
+  
+//     let tr = document.createElement('tr');
+
+//   if (i % 2 === 0) tr.setAttribute('bgColor', 'white')
+//   else tr.setAttribute('bgColor', '#FFFFCC');
+
+// for (let m = 0; m < 10; m++){
+//     let td = document.createElement('td');
+//     let value = i * m;
+
+//   if (value === 0) {
+//     value = i || m;
+//   }
+
+//   td.innerText = value;
+//   tr.appendChild(td);
+// }
+// table.appendChild(tr);
+// }
+// document.body.appendChild(table);
+
+
+// table.setAttribute('borderColor', 'black');
+// table.setAttribute('border', '2');
+// table.setAttribute('cellPadding', '8');
+
+// Подсветить ячейку
+
+// let table = document.createElement('table');
+// for (let i = 0; i < 10; i++){
+  
+//     let tr = document.createElement('tr');
+
+//   if (i % 2 === 0) tr.setAttribute('bgColor', 'white')
+//   else tr.setAttribute('bgColor', 'E2FFFF');
+
+
+//   for (let m = 0; m < 10; m++){
+//     let td = document.createElement('td');
+
+//   td.onmouseover = function() {
+//     this.style.backgroundColor = '#039A2B';
+//   };
+//   td.onmouseout = function() {
+//     this.style.backgroundColor = '';
+//   };
+
+//   let value = i * m;
+
+//   if (value === 0) {
+//     value = i || m;
+//   }
+
+//   td.innerText = value;
+//   tr.appendChild(td);
+// }
+// table.appendChild(tr);
+// }
+// document.body.appendChild(table);
+
+
+// table.setAttribute('borderColor', 'black');
+// table.setAttribute('border', '2');
+// table.setAttribute('cellPadding', '8');
+
+// Подсветить строку и столбец
+
+// let changeBg = (event, color) => {
+//   let target = event.target;
+//   if (target.tagName === 'TD') {
+//     target.style.background = color;
+//     target.parentElement.style.background = color;
+//     let index = event.target.cellIndex;
+//     let rows = document.querySelectorAll('tr');
+//     rows.forEach((row) => row.childNodes[index].style.background = color);
+//   }
+// }
+
+// table.onmouseover = (event) => changeBg(event, '#92FDAF');
+// table.onmouseout = (event) => changeBg(event, '');
+
+
+
+
+
+
+// Calc
+
+let input1 = document.querySelector('#val');
+let input2 = document.querySelector('#val2');
+let sumAll = document.querySelector('#sum');
+let pluss = document.querySelector('#pluss');
+let minuss = document.querySelector('#minuss');
+let times = document.querySelector('#times');
+let splitt = document.querySelector('#split');
+calc2.onclick = function liveReload() {
+  var ddl = document.getElementById("calcFn");
+  var selectedValue = ddl.options[ddl.selectedIndex].value;
+  if(selectedValue == "pluss"){
+  
+  sumAll.value = (+val.value) + (+val2.value) 
+}else if(selectedValue == "minuss") {
+ 
+    sumAll.value = (+val.value) - (+val2.value)
+  }
+  else if(selectedValue == "times") {
+  
+    sumAll.value = (+val.value) * (+val2.value)
+  }
+  else if(selectedValue == "splitt") {
+
+    sumAll.value = (+val.value) / (+val2.value)
+  }
+}
+
+
+
+
+
+
+// Calc Live
+
+// let input1 = document.querySelector('#val');
+// let input2 = document.querySelector('#val2');
+// let sumAll = document.querySelector('#sum');
+// let pluss = document.querySelector('#pluss');
+// let minuss = document.querySelector('#minuss');
+// let times = document.querySelector('#times');
+// let splitt = document.querySelector('#split');
+
+// function liveReload() {
+
+//   var ddl = document.getElementById("calcFn");
+//   var selectedValue = ddl.options[ddl.selectedIndex].value;
+
+//   if(selectedValue == "pluss"){
+ 
+//   sumAll.value = (+val.value) + (+val2.value) 
+// }else if(selectedValue == "minuss") {
+
+//     sumAll.value = (+val.value) - (+val2.value)
+//   }
+//   else if(selectedValue == "times") {
+  
+//     sumAll.value = (+val.value) * (+val2.value)
+//   }
+//   else if(selectedValue == "splitt") {
+
+//     sumAll.value = (+val.value) / (+val2.value)
+//   }
+// }
+
+
+// input1.oninput = liveReload;
+// input2.oninput = liveReload;
+
+
+