diff --git a/5/cart/cart.html b/5/cart/cart.html new file mode 100644 index 0000000..0c00e98 --- /dev/null +++ b/5/cart/cart.html @@ -0,0 +1,28 @@ + + + + + Document + + +
+
+ +

avocado

+ + +
+
+ +

carrot

+ + +
+
+ +
+
+ + + + \ No newline at end of file diff --git a/5/cart/cart.js b/5/cart/cart.js new file mode 100644 index 0000000..0f4852b --- /dev/null +++ b/5/cart/cart.js @@ -0,0 +1,60 @@ +let items = { + 'carrot': 25, + 'avocado': 100 +}; + +let cart = { + 'carrot': 0, + 'avocado': 0 +}; + +document.onclick = event => { + if (event.target.classList.contains("plus")){ + plusFunc(event.target.dataset.id); + }; + if (event.target.classList.contains("minus")){ + minusFunc(event.target.dataset.id); + + }; + if (event.target.classList.contains("basket")){ + basketAlert(); + }; +}; +// plus +const plusFunc = (id) => { + cart[id]++; + renderCart(); +}; + +//minus +const minusFunc = (id) => { + if(cart[id] - 1 == 0){ + deleteFunc(id); + "button".opacity = 0; + + return true + }; + cart[id]--; + renderCart(); +}; + +const renderCart = () => { + console.log(cart) +}; + +//delete +const deleteFunc = id => { + delete cart[id]; + renderCart(); +}; + + +const basketAlert = () => { + var price = 0 + for(var i in cart){ + price = price + (cart[i] * items[i]) + }; + console.log(price); +}; + +renderCart(); \ No newline at end of file diff --git a/5/cart/img/avocado.png b/5/cart/img/avocado.png new file mode 100644 index 0000000..ea8d58b Binary files /dev/null and b/5/cart/img/avocado.png differ diff --git a/5/cart/img/basket.png b/5/cart/img/basket.png new file mode 100644 index 0000000..ed353a6 Binary files /dev/null and b/5/cart/img/basket.png differ diff --git a/5/cart/img/carrot.jpg b/5/cart/img/carrot.jpg new file mode 100644 index 0000000..411cd29 Binary files /dev/null and b/5/cart/img/carrot.jpg differ diff --git a/5/chess/base.html b/5/chess/base.html new file mode 100644 index 0000000..4f3145c --- /dev/null +++ b/5/chess/base.html @@ -0,0 +1,12 @@ + + + + + Document + + + +
+ + + \ No newline at end of file diff --git a/5/chess/chess.js b/5/chess/chess.js new file mode 100644 index 0000000..ff93b74 --- /dev/null +++ b/5/chess/chess.js @@ -0,0 +1,17 @@ +function chess(){ + let mainBlock = document.querySelector('.main-block'); + let block; + let flag = true; + for (let i = 0; i<8; i++){ + for(let j = 0; j<8; j++){ + if (j == 0) flag = !flag + block = document.createElement('div'); + if (flag) block.className = 'block black'; + else block.className = 'block white'; + mainBlock.appendChild(block); + flag = !flag; + } + } +} + +chess(); \ No newline at end of file diff --git a/5/chess/styles.css b/5/chess/styles.css new file mode 100644 index 0000000..f27dca3 --- /dev/null +++ b/5/chess/styles.css @@ -0,0 +1,17 @@ +.main-block { + width: 560px; + height: 560px; + margin: 30px auto; + border: 1px solid black; +} +.block { + width: 70px; + height: 70px; + float:left; +} +.black { + background:black; +} +.white { + background: whitesmoke; +} \ No newline at end of file