From 531a8ff2c4e9fd36ce391d93126228be136d2a9a Mon Sep 17 00:00:00 2001 From: IngaSS Date: Mon, 25 Feb 2019 15:48:24 +0300 Subject: [PATCH 01/13] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=201=20=D0=BA=20=D1=83=D1=80=D0=BE=D0=BA=D1=83=206?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../code.js" | 1 + 1 file changed, 1 insertion(+) create mode 100644 "6 \321\203\321\200\320\276\320\272, \320\272\320\276\321\200\320\267\320\270\320\275\320\260/code.js" diff --git "a/6 \321\203\321\200\320\276\320\272, \320\272\320\276\321\200\320\267\320\270\320\275\320\260/code.js" "b/6 \321\203\321\200\320\276\320\272, \320\272\320\276\321\200\320\267\320\270\320\275\320\260/code.js" new file mode 100644 index 0000000..bdb2e7d --- /dev/null +++ "b/6 \321\203\321\200\320\276\320\272, \320\272\320\276\321\200\320\267\320\270\320\275\320\260/code.js" @@ -0,0 +1 @@ +generator.generateGoodsList(); From 682695802c341a6a61aacb518991fbef131b3dde Mon Sep 17 00:00:00 2001 From: IngaSS Date: Mon, 25 Feb 2019 15:48:31 +0300 Subject: [PATCH 02/13] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=201=20=D0=BA=20=D1=83=D1=80=D0=BE=D0=BA=D1=83=206?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config.js" | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 "6 \321\203\321\200\320\276\320\272, \320\272\320\276\321\200\320\267\320\270\320\275\320\260/config.js" diff --git "a/6 \321\203\321\200\320\276\320\272, \320\272\320\276\321\200\320\267\320\270\320\275\320\260/config.js" "b/6 \321\203\321\200\320\276\320\272, \320\272\320\276\321\200\320\267\320\270\320\275\320\260/config.js" new file mode 100644 index 0000000..ce0bb96 --- /dev/null +++ "b/6 \321\203\321\200\320\276\320\272, \320\272\320\276\321\200\320\267\320\270\320\275\320\260/config.js" @@ -0,0 +1,4 @@ +config = { + rows: 7, + cols: 4 +} From 8d0ee33dd161f8a54621f747f2577c5a6635b19b Mon Sep 17 00:00:00 2001 From: IngaSS Date: Mon, 25 Feb 2019 15:48:38 +0300 Subject: [PATCH 03/13] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=201=20=D0=BA=20=D1=83=D1=80=D0=BE=D0=BA=D1=83=206?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../functions.js" | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 "6 \321\203\321\200\320\276\320\272, \320\272\320\276\321\200\320\267\320\270\320\275\320\260/functions.js" diff --git "a/6 \321\203\321\200\320\276\320\272, \320\272\320\276\321\200\320\267\320\270\320\275\320\260/functions.js" "b/6 \321\203\321\200\320\276\320\272, \320\272\320\276\321\200\320\267\320\270\320\275\320\260/functions.js" new file mode 100644 index 0000000..3a558ce --- /dev/null +++ "b/6 \321\203\321\200\320\276\320\272, \320\272\320\276\321\200\320\267\320\270\320\275\320\260/functions.js" @@ -0,0 +1,15 @@ +function increment(event) { + let input = event.target.previousSibling; + let currentValue = Math.floor(input.value); + input.value = ++currentValue; +} + +function decrement(event) { + let input = event.target.nextSibling; + let currentValue = Math.floor(input.value); + + if (input.value > 0) { + input.value = --currentValue; + } +} + From e5f7d8723523ff7e673764f5b9e0692e493de1e4 Mon Sep 17 00:00:00 2001 From: IngaSS Date: Mon, 25 Feb 2019 15:48:43 +0300 Subject: [PATCH 04/13] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=201=20=D0=BA=20=D1=83=D1=80=D0=BE=D0=BA=D1=83=206?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../generator.js" | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 "6 \321\203\321\200\320\276\320\272, \320\272\320\276\321\200\320\267\320\270\320\275\320\260/generator.js" diff --git "a/6 \321\203\321\200\320\276\320\272, \320\272\320\276\321\200\320\267\320\270\320\275\320\260/generator.js" "b/6 \321\203\321\200\320\276\320\272, \320\272\320\276\321\200\320\267\320\270\320\275\320\260/generator.js" new file mode 100644 index 0000000..33c25e6 --- /dev/null +++ "b/6 \321\203\321\200\320\276\320\272, \320\272\320\276\321\200\320\267\320\270\320\275\320\260/generator.js" @@ -0,0 +1,56 @@ +generator = { + generateGoodsList() { + let list = document.createElement("table"); + document.body.appendChild(list); + + for (let row = 0; row <= config.rows; row++) { + let newRow = list.insertRow(row); + for (let col = 0; col < config.cols; col++) { + let newCell = newRow.insertCell(col); + + if (row === 0 && col >= 0) { + let head = ['Наименование', 'Цена', 'Количество', 'Сумма']; + for (let i = 0; i <= col; i++) { + newCell.innerHTML = head[i]; + newCell.className = 'bold'; + } + } else if (col === 0 && row > 0) { + let result = goods.map(a => a.name); + for (let i = 0; i < row; i++) { + newCell.innerHTML = result[i]; + } + } else if (row > 0 && col === 2) { + let buttonNeg = document.createElement('button'); + buttonNeg.type = 'button'; + buttonNeg.className = 'buttons'; + buttonNeg.innerText = ' - '; + newCell.appendChild(buttonNeg); + buttonNeg.addEventListener('click', decrement); + + let form = document.createElement("input"); + form.type = 'text'; + form.className = 'form'; + form.placeholder = '0'; + newCell.appendChild(form); + + let buttonPos = document.createElement('button'); + buttonPos.type = 'button'; + buttonPos.className = 'buttons'; + buttonPos.innerText = ' + '; + newCell.appendChild(buttonPos); + buttonPos.addEventListener('click', increment); + } else if (row > 0 && col === 1) { + let result = goods.map(a => a.price); + for (let i = 0; i < row; i++) { + newCell.className = 'price'; + newCell.innerHTML = result[i] + ' рублей.'; + } + } + } + } + }, + + //1. при нажатии на "+" в поле "количество" увеличивать число на 1, в поле "сумма" помещать сумму в рублях из расчета price * amount; + //2. при нажатии на "-" совершать противоположное действие; + // 3. Под таблице ввыводить строку описания состояния карзины. "В вашей карзине ...(помещать сумму всех значений 'количества') товаров на сумму ...(общая сумма из поля "сумма")"; +} From f0b69deaf025fc858e242d5dea9eee9079ca96a2 Mon Sep 17 00:00:00 2001 From: IngaSS Date: Mon, 25 Feb 2019 15:48:50 +0300 Subject: [PATCH 05/13] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=201=20=D0=BA=20=D1=83=D1=80=D0=BE=D0=BA=D1=83=206?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goods.js" | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 "6 \321\203\321\200\320\276\320\272, \320\272\320\276\321\200\320\267\320\270\320\275\320\260/goods.js" diff --git "a/6 \321\203\321\200\320\276\320\272, \320\272\320\276\321\200\320\267\320\270\320\275\320\260/goods.js" "b/6 \321\203\321\200\320\276\320\272, \320\272\320\276\321\200\320\267\320\270\320\275\320\260/goods.js" new file mode 100644 index 0000000..3b5b5e6 --- /dev/null +++ "b/6 \321\203\321\200\320\276\320\272, \320\272\320\276\321\200\320\267\320\270\320\275\320\260/goods.js" @@ -0,0 +1,68 @@ +let goods = [ + { + name: 'лампа', + price: 1200, + amount: 4, + putToBasket() { + basket.goodlist.push(this); + } + }, + { + name: 'диван', + price: 25000, + amount: 1, + putToBasket() { + basket.goodlist.push(this); + } + }, + { + name: 'тумба', + price: 4500, + amount: 2, + putToBasket() { + basket.goodlist.push(this); + } + }, + { + name: 'зеркало', + price: 5000, + amount: 4, + putToBasket() { + basket.goodlist.push(this); + } + }, + { + name: 'шкаф', + price: 35000, + amount: 1, + putToBasket() { + basket.goodlist.push(this); + } + }, + { + name: 'туалетный столик', + price: 7000, + amount: 2, + putToBasket() { + basket.goodlist.push(this); + } + }, + { + name: 'пуфик', + price: 2000, + amount: 2, + putToBasket() { + basket.goodlist.push(this); + } + } +] + +console.log(goods); +goods.forEach(function(item, i) { + if (i % 2 == 0) { + item.putToBasket(); + } else { + item.putToBasket(); + // item.putToBasket(); + } +}); From 2d19af146efd410580b535e99238bcf863d5b164 Mon Sep 17 00:00:00 2001 From: IngaSS Date: Mon, 25 Feb 2019 15:48:56 +0300 Subject: [PATCH 06/13] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=201=20=D0=BA=20=D1=83=D1=80=D0=BE=D0=BA=D1=83=206?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../index.html" | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 "6 \321\203\321\200\320\276\320\272, \320\272\320\276\321\200\320\267\320\270\320\275\320\260/index.html" diff --git "a/6 \321\203\321\200\320\276\320\272, \320\272\320\276\321\200\320\267\320\270\320\275\320\260/index.html" "b/6 \321\203\321\200\320\276\320\272, \320\272\320\276\321\200\320\267\320\270\320\275\320\260/index.html" new file mode 100644 index 0000000..4fc1aae --- /dev/null +++ "b/6 \321\203\321\200\320\276\320\272, \320\272\320\276\321\200\320\267\320\270\320\275\320\260/index.html" @@ -0,0 +1,17 @@ + + + + + + + + Document + + + + + + + + + From 5809b59346a4ae282cbed1b9c40b23590cb30838 Mon Sep 17 00:00:00 2001 From: IngaSS Date: Mon, 25 Feb 2019 15:49:03 +0300 Subject: [PATCH 07/13] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=201=20=D0=BA=20=D1=83=D1=80=D0=BE=D0=BA=D1=83=206?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../styles.css" | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 "6 \321\203\321\200\320\276\320\272, \320\272\320\276\321\200\320\267\320\270\320\275\320\260/styles.css" diff --git "a/6 \321\203\321\200\320\276\320\272, \320\272\320\276\321\200\320\267\320\270\320\275\320\260/styles.css" "b/6 \321\203\321\200\320\276\320\272, \320\272\320\276\321\200\320\267\320\270\320\275\320\260/styles.css" new file mode 100644 index 0000000..0cca106 --- /dev/null +++ "b/6 \321\203\321\200\320\276\320\272, \320\272\320\276\321\200\320\267\320\270\320\275\320\260/styles.css" @@ -0,0 +1,49 @@ +table { + background-color: grey; + border-collapse: collapse; +} + +td { + width: 150px; + height: 30px; + border: 1px solid black; +} + +.bold { + text-align: center; + font-weight: bold; +} +.text { + text-align: right; +} + +.formPrice { + width: 70px; + height: 20px; + border: 1px solid black; + margin-left: 25%; + border-radius: 2px; + text-align: center; +} + +.form { + width: 50px; + height: 20px; + border: 1px solid black; + margin-left: 10%; + border-radius: 2px; + text-align: center; +} + +.buttons { + width: 25px; + height: 20px; + margin-left: 7%; + text-align: center; + border: 0.5px solid black; + border-radius: 2px; +} + +.price { + text-align: center; +} From 0856a97317e5073e833aaf85c00d15db8a598c20 Mon Sep 17 00:00:00 2001 From: IngaSS Date: Mon, 25 Feb 2019 15:49:56 +0300 Subject: [PATCH 08/13] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=202=20=D0=BA=20=D1=83=D1=80=D0=BE=D0=BA=D1=83=206?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hw6-2/code.js | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 hw6-2/code.js diff --git a/hw6-2/code.js b/hw6-2/code.js new file mode 100644 index 0000000..aa32332 --- /dev/null +++ b/hw6-2/code.js @@ -0,0 +1,2 @@ +generator.generateForm(); + From 137abba9e227356fd41c4783d2cb808d95beade6 Mon Sep 17 00:00:00 2001 From: IngaSS Date: Mon, 25 Feb 2019 15:50:03 +0300 Subject: [PATCH 09/13] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=202=20=D0=BA=20=D1=83=D1=80=D0=BE=D0=BA=D1=83=206?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hw6-2/functions.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 hw6-2/functions.js diff --git a/hw6-2/functions.js b/hw6-2/functions.js new file mode 100644 index 0000000..3d645c1 --- /dev/null +++ b/hw6-2/functions.js @@ -0,0 +1,3 @@ +function increment(event) { + console.log(event.target); +} From f8a079e9c67b0cf6f094ceaaba724d969ee4b6cd Mon Sep 17 00:00:00 2001 From: IngaSS Date: Mon, 25 Feb 2019 15:50:09 +0300 Subject: [PATCH 10/13] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=202=20=D0=BA=20=D1=83=D1=80=D0=BE=D0=BA=D1=83=206?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hw6-2/generator.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 hw6-2/generator.js diff --git a/hw6-2/generator.js b/hw6-2/generator.js new file mode 100644 index 0000000..e89453b --- /dev/null +++ b/hw6-2/generator.js @@ -0,0 +1,40 @@ +generator = { + generateForm() { + let form = document.createElement('form'); + document.body.appendChild(form); + form.type = 'form'; + form.className = 'form'; + form.addEventListener('submit', submitForm); + + let logIn = document.createElement('input'); + logIn.type = 'text'; + logIn.name = 'login'; + logIn.className = 'login'; + logIn.placeholder = 'Введите логин'; + form.appendChild(logIn); + + let password = document.createElement('input'); + password.type = 'password'; + password.name = 'password'; + password.className = 'password'; + password.placeholder = 'Введите пароль'; + + form.appendChild(password); + + let passwordConf = document.createElement('input'); + passwordConf.type = 'password'; + passwordConf.name = 'password-confirmation'; + passwordConf.className = 'password'; + passwordConf.placeholder = 'Подтверждение пароля'; + + form.appendChild(passwordConf); + + let button = document.createElement('input'); + button.type = 'submit'; + button.className = 'button'; + button.innerText = 'Отправить'; + + form.appendChild(button); + + } +} From 129ce85699fd0cd1136b0d528ebb79a0d8c65ff9 Mon Sep 17 00:00:00 2001 From: IngaSS Date: Mon, 25 Feb 2019 15:50:19 +0300 Subject: [PATCH 11/13] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=202=20=D0=BA=20=D1=83=D1=80=D0=BE=D0=BA=D1=83=206?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hw6-2/index.html | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 hw6-2/index.html diff --git a/hw6-2/index.html b/hw6-2/index.html new file mode 100644 index 0000000..2053059 --- /dev/null +++ b/hw6-2/index.html @@ -0,0 +1,15 @@ + + + + + + + + Document + + + + + + + From 36b272e43db6a83fe8fbc0ce5cc116b70347cdf0 Mon Sep 17 00:00:00 2001 From: IngaSS Date: Mon, 25 Feb 2019 15:50:25 +0300 Subject: [PATCH 12/13] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=202=20=D0=BA=20=D1=83=D1=80=D0=BE=D0=BA=D1=83=206?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hw6-2/styles.css | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 hw6-2/styles.css diff --git a/hw6-2/styles.css b/hw6-2/styles.css new file mode 100644 index 0000000..37d1417 --- /dev/null +++ b/hw6-2/styles.css @@ -0,0 +1,43 @@ +.form { + width: 250px; + height: 300px; + background-color: beige; + margin-left: 100px; + margin-top: 50px; +} + +.login { + width: 200px; + height: 30px; + border: 1px solid saddlebrown; + border-radius: 3px; + margin-left: 25px; + margin-top: 20px; + text-indent: 10px; +} + +.password { + width: 200px; + height: 30px; + border: 1px solid saddlebrown; + border-radius: 3px; + margin-left: 25px; + margin-top: 20px; + text-indent: 10px; +} + +.button { + width: 150px; + height: 30px; + border-radius: 3px; + margin-left: 20%; + background-color: slateblue; + border: 1px solid saddlebrown; + margin-top: 20px; +} + +.p { + color: red; + font-size: 10px; + text-align: center; +} From 68f61813fe81abe99725c153063948ea7e457328 Mon Sep 17 00:00:00 2001 From: IngaSS Date: Mon, 25 Feb 2019 15:50:31 +0300 Subject: [PATCH 13/13] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=202=20=D0=BA=20=D1=83=D1=80=D0=BE=D0=BA=D1=83=206?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hw6-2/validation.js | 58 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 hw6-2/validation.js diff --git a/hw6-2/validation.js b/hw6-2/validation.js new file mode 100644 index 0000000..a9f8fea --- /dev/null +++ b/hw6-2/validation.js @@ -0,0 +1,58 @@ +function validateLogin(login) { + if (login.length > 1 && login.length < 50) { + return { valid: true }; + } else { + return { valid: false, message: 'Должно быть больше 1 одного символа и меньше 50' }; + } +} + +function validatePassword(password) { + if (password.length > 5 && password.length < 50) { + return { valid: true }; + } else { + return { valid: false, message: 'Минимум 5 символов, максимум 50' }; + } +} + +function validatePasswordConf(passwordConf, password) { + if (passwordConf === password) { + return { valid: true }; + } else { + return { valid: false, message: 'Значение должно совпадать с полем пароль.' }; + } +} + +function submitForm(event) { + event.preventDefault(); + + let login = Array.from(event.srcElement.childNodes).find(elem => elem.name == "login"); + let password = Array.from(event.srcElement.childNodes).find(elem => elem.name == "password"); + let passwordConf = Array.from(event.srcElement.childNodes).find(elem => elem.name == "password-confirmation"); + + var loginErrorMessage = document.querySelector("#loginErrorMessage"); + var passwordErrorMessage = document.querySelector("#passwordErrorMessage"); + var passwordConfErrorMessage = document.querySelector("#passwordConfErrorMessage"); + + + if (!validateLogin(login.value).valid) { + if (!loginErrorMessage) login.insertAdjacentHTML('afterEnd', '

' + validateLogin(login.value).message + '

'); + } else { + if (loginErrorMessage) loginErrorMessage.remove(); + } + + if (!validatePassword(password.value).valid) { + if(!passwordErrorMessage) password.insertAdjacentHTML('afterEnd', '

' + validatePassword(password.value).message + '

'); + } else { + if (passwordErrorMessage) passwordErrorMessage.remove(); + } + + if (!validatePasswordConf(passwordConf.value, password.value).valid) { + if(!passwordConfErrorMessage) passwordConf.insertAdjacentHTML('afterEnd', '

' + validatePasswordConf(passwordConf.value).message + '

'); + } else { + if(passwordConfErrorMessage) passwordConfErrorMessage.remove(); + } + + if (validateLogin(login.value).valid && + validatePassword(password.value).valid && + validatePasswordConf(passwordConf.value, password.value).valid) alert('Форма отправлена!'); +}