Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web-4 #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/.~lock.lr4.pdf.odg#
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
,polina,polina,21.12.2024 03:20,file:///home/polina/.config/libreoffice/4;
Binary file added docs/lr4.pdf
Binary file not shown.
31 changes: 31 additions & 0 deletions projects/checkbox/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!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>
<style>
label{display:inline-block; width: 100px;}
div{margin-bottom: 20px;}
</style>
</head>
<body>
<p>Выберите товары:</p>
<div>
<input type="checkbox" id="goodChoice1" name="food" value="120">
<label for="goodChoice1">Пирог с яблоком - 120р</label>
</div>
<div>
<input type="checkbox" id="goodChoice2" name="food" value="80">
<label for="goodChoice2">Шоколадный кекс - 80р</label>
</div>
<div>
<input type="checkbox" id="goodChoice3" name="food" value="180">
<label for="goodChoice3">Чизкейк - 180р</label>
</div>
<button class="btn">Выбрать</button>
<p>Общая стоимость: <span class="result"></span></p>
<script src="js/main.js"></script>
</body>
</html>
14 changes: 14 additions & 0 deletions projects/checkbox/js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
btnElement = document.querySelector(".btn");
resultElement = document.querySelector(".result");
radioButtons = document.querySelectorAll('[name="food"]');
resultElement.textContent = "0 руб"

btnElement.addEventListener("click", function(){
let selectedContactValues = [];
for (const radioButton of radioButtons){
if(radioButton.checked){
selectedContactValues.push(radioButton.value);
}
}
resultElement.textContent = `${selectedContactValues.reduce((a, b) => parseInt(a) + parseInt(b), 0)} руб`;
});
Empty file added projects/checkbox/style.css
Empty file.
34 changes: 34 additions & 0 deletions projects/form/index.html
Original file line number Diff line number Diff line change
@@ -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>
<style>
label{display:inline-block; width: 100px;}
div{margin-bottom: 20px;}
</style>
</head>
<body>
<p>Имя:
<input class="input" type="text" name="first_name"></p>
<p>Фамилия:
<input class="input" type="text" name="second_name"></p>
<!-- <div>
<input type="checkbox" id="goodChoice1" name="food" value="120">
<label for="goodChoice1">Пирог с яблоком - 120р</label>
</div>
<div>
<input type="checkbox" id="goodChoice2" name="food" value="80">
<label for="goodChoice2">Шоколадный кекс - 80р</label>
</div>
<div>
<input type="checkbox" id="goodChoice3" name="food" value="180">
<label for="goodChoice3">Чизкейк - 180р</label>
</div> -->
<button class="btn">Отправить</button>
<p>Ответ: <span class="result"></span></p>
<script src="js/main.js"></script>
</body>
</html>
8 changes: 8 additions & 0 deletions projects/form/js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
btnElement = document.querySelector(".btn");
resultElement = document.querySelector(".result");
first_name = document.querySelector('[name="first_name"]');
second_name = document.querySelector('[name="second_name"]');

btnElement.addEventListener("click", function() {
resultElement.textContent = `Здравствуйте, ${first_name.value} ${second_name.value}!`
});
141 changes: 141 additions & 0 deletions projects/store/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body{
font-family: 'Oswald', sans-serif;
}
.header{
width: 100%;
height: 80px;
display: flex;
align-items: center;
justify-content: center;
}
.title{
font-weight: 500;
font-size: 36px;
line-height: 53px;
text-align: center;
text-transform: uppercase;
}
.order{
background: #817070;
padding: 50px 0;
display: flex;
flex-direction: column;
justify-content: center;
width: 100%;
}
.order__fio{
display: flex;
justify-content: center;
margin-bottom: 20px;
}
.order__coffee{
display: flex;
flex-direction: column;
margin-right: 150px;
}
.orders{
width: 100%;
display: flex;
justify-content: center;
}
.order__food{
display: flex;
flex-direction: column;
}
input{
border: 3px solid #fff;
padding: 10px;
background: #817070;
margin: 0 10px 10px 10px;
color: #fff;
text-align: center;
font-size: 20px;
outline: none;
}
input[type="number"]{
width: 60px;
-moz-appearance: textfield;
}
input::placeholder{
color: #fff;
font-family: 'Oswald', sans-serif;
text-align: center;
}
label{
color: #fff;
font-size: 20px;
}
.btn{
font-size: 20px;
line-height: 30px;
text-align: center;
text-transform: uppercase;
color: #817070;
background: #FFFFFF;
border: 3px solid #FFFFFF;
width: fit-content;
padding: 10px;
cursor: pointer;
font-family: 'Oswald', sans-serif;
text-align: right;
display: flex;
align-self: center;
}
.btn:hover{
color: #fff;
background: #817070;
}
.total{
color: #FFFFFF;
text-align: center;
font-size: 26px;
margin: 20px;
}
.item{
display: flex;
justify-content: space-between;
align-items: baseline;
width: 300px;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
}

.checkbox {
position: absolute;
z-index: -1;
opacity: 0;
}
.checkbox + label {
position: relative;
padding: 0 0 0 40px;
cursor: pointer;
}
.checkbox + label:before {
content: '';
position: absolute;
top: 2px;
left: 0;
width: 26px;
height: 26px;
background: #ebe2e2;
}
.checkbox + label:after {
content: '';
position: absolute;
top: 6px;
left: 4px;
width: 18px;
height: 18px;
background: #817070;
}
.checkbox:checked + label:after {
background: #6a4646;
}
77 changes: 77 additions & 0 deletions projects/store/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<!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="css/style.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Oswald:wght@200;300;400;500;600;700&display=swap" rel="stylesheet">
</head>
<body>
<header class="header">
<p class="title">COFFEE HOUSE</p>
</header>
<section class="order">
<div class="order__fio">
<input type="text" name="surname" placeholder="Введите Фамилию">
<input type="text" name="name" placeholder="Введите Имя">
</div>

<div class="orders">
<div class="order__coffee">
<div class="item">
<input class="checkbox" id="checkbox1" type="checkbox" name="goods" value="80" data-goods="expresso">
<label for="checkbox1">Эспрессо 80р.</label>
<input type="number" id="expresso" value="0">
</div>
<div class="item">
<input class="checkbox" id="checkbox2" type="checkbox" name="goods" value="110" data-goods="americano">
<label for="checkbox2">Американо 110р.</label>
<input type="number" id="americano" value="0">
</div>
<div class="item">
<input class="checkbox" id="checkbox3" type="checkbox" name="goods" value="120" data-goods="latte">
<label for="checkbox3">Латте 120р.</label>
<input type="number" id="latte" value="0">
</div>
<div class="item">
<input class="checkbox" id="checkbox4" type="checkbox" name="goods" value="90" data-goods="capuchino">
<label for="checkbox4">Капучино 90р.</label>
<input type="number" id="capuchino" value="0">
</div>
</div>
<div class="order__food">
<div class="item">
<input class="checkbox" id="checkbox5" type="checkbox" name="goods" value="80" data-goods="chocolate_muffin">
<label for="checkbox5">Шоколадный кекс 80р.</label>
<input type="number" id="chocolate_muffin" value="0">
</div>
<div class="item">
<input class="checkbox" id="checkbox6" type="checkbox" name="goods" value="90" data-goods="blueberry_muffin">
<label for="checkbox6">Черничный кекс 90р.</label>
<input type="number" id="blueberry_muffin" value="0">
</div>
<div class="item">
<input class="checkbox" id="checkbox7" type="checkbox" name="goods" value="100" data-goods="apple_tart">
<label for="checkbox7">Яблочный тарт 100р.</label>
<input type="number" id="apple_tart" value="0">
</div>
</div>
</div>
<p class="total">Итого: <span class="sum">0 р.</span></p>
<button class="btn">Оформить заказ</button>
</section>
<script src="js/main.js"></script>
</body>
</html>








76 changes: 76 additions & 0 deletions projects/store/js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
const userSurname = document.querySelector('[name="surname"]');
const userName = document.querySelector('[name="name"]');

const goodsElements = document.querySelectorAll('[name="goods"]');
const countElements = document.querySelectorAll('[type="number"]');

const btn = document.querySelector(".btn");
const resultElem = document.querySelector(".sum");

let s = 0;

const countGoods = {
"expresso": 0,
"americano": 0,
"latte": 0,
"capuchino": 0,
"chocolate_muffin": 0,
"blueberry_muffin": 0,
"apple_tart": 0
}

const choicePriceGoods = {
"expresso": 0,
"americano": 0,
"latte": 0,
"capuchino": 0,
"chocolate_muffin": 0,
"blueberry_muffin": 0,
"apple_tart": 0
}

function count() {
s = 0;
for (var key in countGoods) {
s += countGoods[key] * choicePriceGoods[key];
}
resultElem.textContent = `${s} руб.`
}

countElements.forEach(elem => {
elem.addEventListener("change", function(){
countGoods[elem.id] = elem.value;
if (elem.value < 0) {
elem.value = 0;
countGoods[elem.id] = 0;
}
elem.value = elem.value.replace(/^0+/, '');
count();
})
})

goodsElements.forEach(product => {
product.addEventListener("change", function() {
if (product.checked) {
choicePriceGoods[product.dataset.goods] = product.value;
if (countGoods[product.dataset.goods] === 0) {
countGoods[product.dataset.goods] = 1;
document.querySelector(`#${product.dataset.goods}`).value = 1;
}
} else {
choicePriceGoods[product.dataset.goods] = 0;
document.querySelector(`#${product.dataset.goods}`).value = 0;
countGoods[product.dataset.goods] = 0;
}
count();
})
});

btn.addEventListener("click", function() {
let st = "";
if (userName.value != "" || userSurname.value != "") {
st += `Заказчик: ${userSurname.value} ${userName.value}\n`
}
st += `Итого: ${s} р.`
alert(st);
})