Skip to content
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
96 changes: 96 additions & 0 deletions 01.06/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<!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>
</head>

<body>
<script>
const table = document.createElement("table");
table.style.borderCollapse = 'collapse';
table.style.width = '240px';
table.style.height = '240px';
function initChess() {
for (let row = 0; row < 8; row++) {
const tr = document.createElement('tr');
for (let col = 0; col < 8; col++) {
const td = document.createElement('td');
if (row % 2 == col % 2) {
td.style.backgroundColor = 'white'
} else {
td.style.backgroundColor = 'black'
}
tr.appendChild(td);
}
table.appendChild(tr);
}
document.body.appendChild(table);
}
initChess();
</script>


<script>
const cart = [
item1 = {
name: 'фитинг',
price: 210,
quantity: 5
},
item2 = {
name: 'уголок',
price: 195,
quantity: 7
},
item3 = {
name: 'переход',
price: 95,
quantity: 4
},
item4 = {
name: 'муфта',
price: 77,
quantity: 14
},
item5 = {
name: 'тройник',
price: 275,
quantity: 5
},
item6 = {
name: 'труба',
price: 321,
quantity: 2
}
];


let totalPrice = 0;
function countBasketPrice() {
for (let i = 0; i < cart.length; i++) {
totalPrice += cart[i].price * cart[i].quantity;
}
return totalPrice;
}
console.log(countBasketPrice(cart))



const myDiv = document.createElement("div");
const i = document.createElement('i');
myDiv.appendChild(i);
if (totalPrice == 0) {
i.innerHTML = 'Корзина пуста'
} else {
i.innerHTML = 'В корзине ' + cart.length + ' товаров на сумму ' + totalPrice + ' рублей';
}
console.log(i.innerHTML);
alert(i.innerHTML);
</script>
</body>

</html>
76 changes: 76 additions & 0 deletions 28.05/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<!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>
</head>

<body>
<script>

function transform(number) {
let obj = {};
if (number > 999) return obj;
let a = Math.floor(number / 100);
console.log(obj);
let b = Math.floor((number - a * 100) / 10);
let c = (number - a * 100) - b * 10;
obj.units = c;
obj.ten = b;
obj.hundr = a;


}
console.log(transform(765));




const cart = [
item1 = {
name: 'фитинг',
price: 210,
quantity: 5
},
item2 = {
name: 'уголок',
price: 195,
quantity: 7
},
item3 = {
name: 'переход',
price: 95,
quantity: 4
},
item4 = {
name: 'муфта',
price: 77,
quantity: 14
},
item5 = {
name: 'тройник',
price: 275,
quantity: 5
},
item6 = {
name: 'труба',
price: 321,
quantity: 2
}
];
function countBasketPrice() {
let totalPrice = 0;
for (let i = 0; i < cart.length; i++) {
totalPrice += cart[i].price * cart[i].quantity;
}
return totalPrice;
}
console.log(countBasketPrice(cart))
alert(countBasketPrice(cart));
</script>
</body>

</html>
157 changes: 157 additions & 0 deletions 8.06/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
<!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>Catalog</title>
</head>

<body>

<div class="catalog">
<h2>Каталог</h2>
</div>
<div class="cart">
<h2>Корзина</h2>
</div>
<script>

const catalogBlock = {
render(item) {
return `<div class="item">
<div><b>Наименование</b>: ${item.name}</div>
<div><b>Цена за шт.</b>: ${item.price} руб.</div>
<button class="item-btn" data-id_product="${item.id_product}">Купить</button>
</div>`;
}
};

const cartBlock = {
render(unit) {
// let quantity = 1;
return `<div class="item">
<div><b>Наименование</b>: ${unit.name}</div>
<div><b>Цена за шт.</b>: ${unit.price} руб.</div>
<p>Количество: ${unit.quantity} шт.</p>
</div>`
}
};

const catalog = {
catalogListBlock: null,
catalogBlock,
cart: null,
items: [
{
name: 'фитинг',
id_product: 1,
price: 210,
},
{
name: 'уголок',
id_product: 2,
price: 195,
},
{
name: 'переход',
id_product: 3,
price: 95,
},
{
name: 'муфта',
id_product: 4,
price: 77,
},
{
name: 'тройник',
id_product: 5,
price: 275,
},
{
name: 'труба',
id_product: 6,
price: 321,
}
],


Init() {
this.catalogListBlock = document.querySelector('.catalog');
this.cart = cart;
this.render();
this.addEventHandlers();
},

render() {
this.items.forEach(item => {
this.catalogListBlock.insertAdjacentHTML('beforeend', this.catalogBlock.render(item));
});
},

addEventHandlers() {
this.catalogListBlock.addEventListener('click', event => this.addToCart(event))
},

addToCart(event) {
if (!event.target.classList.contains('item-btn')) return;
const product = +event.target.dataset.id_product;
const addProduct = this.items.find((item) => item.id_product == product);
if (this.cart.units.length == 0) {
addProduct.quantity = 1;
this.cart.units.push(addProduct);
} else {
if (addProduct == this.cart.units.find((item) => item.id_product == addProduct.id_product)) {
addProduct.quantity++;
} else {
addProduct.quantity = 1;
this.cart.units.push(addProduct)
};

};

let totalPrice = 0;
let total = this.cart.units.length;
this.cart.units.forEach(unit => { totalPrice += unit.quantity * unit.price });
cart.init(total, totalPrice);
}
};

const cart = {
cartListBlock: null,
cartBlock,
units: [
// {
// name: 'фитинг',
// price: 210,
// },
],

init(total, totalPrice) {
this.cartListBlock = document.querySelector('.cart');
this.renderCart(total, totalPrice);
},

renderCart(total, totalPrice) {
this.cartListBlock.innerHTML = '<h2>Корзина</h2>';
this.units.forEach(unit => {
this.cartListBlock.insertAdjacentHTML('beforeend', this.cartBlock.render(unit));
});
// this.cartListBlock.insertAdjacentHTML('beforeend', this.score(total, totalPrice));
},





};

catalog.Init();
// cart.init();


</script>
</body>

</html>
24 changes: 24 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!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>
<script>
var Tc = +prompt("Задайте температуру по цельсию");
var Tf = (9 / 5) * Tc + 32;
alert(Tf);

var name = 'Василий';
var admin = name;
alert(admin);
</script>
</head>

<body>

</body>

</html>