makstravm преди 3 години
родител
ревизия
c8a0fa8d51
променени са 3 файла, в които са добавени 174 реда и са изтрити 0 реда
  1. 33 0
      HW8/index.html
  2. 74 0
      HW8/main.js
  3. 67 0
      HW8/style.css

+ 33 - 0
HW8/index.html

@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html lang="en-ru">
+
+<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">
+  <link rel="stylesheet" href="style.css">
+  <title>HW8</title>
+
+</head>
+
+
+<body>
+  <div id='root'></div>
+
+  <div class="calc">
+    <div class="calc__inner">
+      <input id='numOne' type="number">
+      <input id='numTwo' type="number"> =
+      <input id='result' type="number" disabled>
+    </div>
+    <div class="btn__inner">
+      <button id='plus' class="btn">+</button>
+      <button id='minus' class="btn">-</button>
+      <button id='division' class="btn">/</button>
+      <button id='multiplication' class="btn">*</button>
+    </div>
+  </div>
+  <script src="main.js"></script>
+</body>
+
+</html>

+ 74 - 0
HW8/main.js

@@ -0,0 +1,74 @@
+let table = document.createElement('table')
+for (let rowIndex = 0; rowIndex <= 10; rowIndex++) {
+  let tr = document.createElement('tr')
+  rowIndex % 2 === 0 ? tr.className = "tr-odd" : tr.className = "tr-even"
+  table.append(tr)
+  if (rowIndex === 0) {
+    for (let k = 0; k <= 10; k++) {
+      let th = document.createElement('th')
+      th.className = 'th'
+      th.append(k)
+      tr.append(th)
+    }
+  } else {
+    for (let colIndex = 0; colIndex <= 10; colIndex++) {
+      let td = document.createElement('td')
+      td.onmouseover = function () {
+        let array = [...this.parentElement.parentElement.children]
+        for (let row = 0; row <= tr.rowIndex; row++) {
+          for (let cell = 0; cell <= td.cellIndex; cell++) {
+            if (cell === td.cellIndex) {
+              [...array[row].children][cell].style.backgroundColor = '#fffbcc'
+            }
+            [...this.parentElement.children][cell].style.backgroundColor = '#fffbcc'
+          }
+        }
+        this.style.backgroundColor = 'red'
+      }
+      td.onmouseout = function () {
+        this.style.backgroundColor = ''
+        let array = [...this.parentElement.parentElement.children]
+        for (let cell = 0; cell <= tr.rowIndex; cell++) {
+          for (let row = 0; row <= td.cellIndex; row++) {
+            [...array[cell].children][row].style.backgroundColor = ''
+          }
+        }
+      }
+      if (colIndex === 0) {
+        let th = document.createElement('th')
+        th.className = 'th'
+        th.append((rowIndex) * (colIndex + 1))
+        tr.append(th)
+      } else if (colIndex === rowIndex) {
+        td.className = 'tdtd'
+        td.append((rowIndex) * (colIndex))
+        tr.append(td)
+      } else {
+        td.append((rowIndex) * (colIndex))
+        tr.append(td)
+      }
+    }
+  }
+}
+root.append(table)
+
+
+plus.addEventListener('click', () => {
+  result.value = +numOne.value + +numTwo.value
+})
+minus.addEventListener('click', () => {
+  result.value = +numOne.value - +numTwo.value
+})
+division.addEventListener('click', () => {
+  result.value = +numOne.value / +numTwo.value
+})
+multiplication.addEventListener('click', () => {
+  result.value = +numOne.value * +numTwo.value
+})
+numOne.addEventListener('input', () => {
+  result.value = +numOne.value + +numTwo.value
+})
+numTwo.addEventListener('input', () => {
+  result.value = +numOne.value + +numTwo.value
+})
+

+ 67 - 0
HW8/style.css

@@ -0,0 +1,67 @@
+body {
+  max-width: 1200px;
+  padding: 15px;
+  box-sizing: border-box;
+  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
+}
+table {
+  text-align: center;
+  border-spacing: 0;
+  font-size: 20px;
+  width: 50%;
+  margin: 0 auto;
+  height: 450px;
+  margin-bottom: 50px;
+}
+
+td,
+th {
+  border: 1px solid #000;
+}
+td {
+  cursor: pointer;
+}
+
+.th,
+.th .th {
+  background-color: rgba(48, 48, 48, 0.867);
+  color: rgb(72, 255, 0);
+  font-weight: 700;
+}
+.tdtd {
+  background-color: rgba(0, 255, 242, 0.582);
+  color: rgb(3, 3, 43);
+  font-weight: 500;
+}
+.tr-even {
+  background-color: rgba(233, 233, 233, 0.867);
+}
+.calc {
+  text-align: center;
+}
+.calc__inner input {
+  text-align: center;
+  font-size: 16px;
+  line-height: 30px;
+  margin-bottom: 20px;
+  border: none;
+  box-shadow: 0px 0px 14px 0px rgba(83, 19, 19, 0.25);
+}
+.btn__inner {
+  display: flex;
+  justify-content: center;
+  align-items: center;
+}
+.btn {
+  cursor: pointer;
+  border: none;
+  background-color: transparent;
+  font-size: 22px;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  width: 35px;
+  height: 35px;
+  margin: 0 10px;
+  box-shadow: 0px 0px 14px 0px rgba(83, 19, 19, 0.25);
+}