From 272e75646eb0788b75a27cdbec11c1f45a0aedbf Mon Sep 17 00:00:00 2001 From: Origami Date: Mon, 11 Aug 2025 01:32:19 +0300 Subject: [PATCH 1/2] editHW --- script.js | 1 + 1 file changed, 1 insertion(+) diff --git a/script.js b/script.js index cdddbbc..9c29a93 100644 --- a/script.js +++ b/script.js @@ -34,6 +34,7 @@ function startGameOne() { } } + // Игра "Камень, ножницы, бумага" const playGameRockPaperScissors = () => { const choices = ["камень", "ножницы", "бумага"]; From 79f0f33fc64d2219506bfb229f3c178c59424b14 Mon Sep 17 00:00:00 2001 From: Origami Date: Sun, 14 Sep 2025 19:28:54 +0300 Subject: [PATCH 2/2] HW last --- img/Star 2.png | Bin 0 -> 3260 bytes index.html | 36 +++++++------ script.js | 134 ++++++++++++++++++++++++++++++++++++++++++++++++- styles.css | 73 ++++++++++++++++++--------- tasks.html | 60 ++++++++++++++++++++++ tasks.js | 113 +++++++++++++++++++---------------------- 6 files changed, 313 insertions(+), 103 deletions(-) create mode 100644 img/Star 2.png create mode 100644 tasks.html diff --git a/img/Star 2.png b/img/Star 2.png new file mode 100644 index 0000000000000000000000000000000000000000..db3c82cffeb5b674ce33eed6dc569ff858acd901 GIT binary patch literal 3260 zcmcgvZA?>V6n;wu3=G*=B8wGeMqQSPEHNolHp({qU>LtLWx~>$CDJUks|izzvfes% zLdY^RGl;2rHy5{L$*dUzM#Np1EdEezrpsz!S!=Tt5s|X;QOfPTJMYK6v~k(LtqGTe z`}Vx&Jm)#jb7I&o4NH0Xv%u=j!Q>9e zn*G>1F76ZkDb8q7tfRd!KA6K##lDtf2kl>(isx?gSz(r0Dw?oOlA0_f!&$e)DO-fx z5{J`OG(a>tz}n;+<$5UMGsoD&3a+!i*4KDTcXoEvAL_=LOBQF*OA#+WAm^bbt`Fzt zO*2*pJDlD$$55!A!r-}1UbIFFT;2wp_>kyFPWxKn(DX%<&Td7`o)moA>35K~Jqz(| zLTA5Ob62^JD?$sx1mL6I*614K@@NYJqJN=zXAkK-wbQetQ?X4Z6sdz$MI_l4yz`3+Tn5fm|VMP_k z2_((l6r-*;bdWYoZr9`+7vNG2)xpHrE%&{*ew?h;Li8#eeNm-2O`*jX2tScVx7rI_ zeiGjI@^S?)ask}y*Er^AM}?#@|MHY1Dhqkd1;|bD~f+5Y?fgGz`L6IDz}dc-T(g&a0rj z9)<);h=xjP z;RT$iFyHaFpl{ETM(e|aIc_3)bgH-$iiWW%!$((BEhz;>0;LAEV)i1Zkr&m$F6I{I z$a3&D)1OqUwlprz-lwvxl&}EsRL_p5JEPkbA8dKSsKe?=g?dPQj)IxPv#bp+t{C-m zpOf^mdca&XZbEKEB+M$gXoH(QjC}ln0B{;eQ;E&ABa4xFn&Bp$m*^TM$G)EX(B3`_ z3HX+oH4W68+y|nwS0UGI8w|wh$L^97%1dWV7x77jF=|%-bn+}*zVTl#*HVY>P62oy z66vmJRJH_*bds7f%HfmzO9OzNRv4$}wTfj3cX9dH886wbfi7za&Da*PK(lM+`=k`Y z(}sdxR#JPU*>pAZLEf*=W3iO^yKslZPdgP|6X-Y!2AQYGXW<6WgBRHi9c;4RAS}{7 zPOn3d&QVpEqLqqUqynpm7{S)_jB-X@nykh$EHO+S5DbIDF{YR+XdEhME_o@5z;+0# zdSJn1wIT{>phvz)+RUsl{E3^B2i$D=gXD=nf!$Lve4mJgiq0jheJqs}3Le9aTMOvy zAZWl$VRTw@iP~D}GG>nOU{Z#=$r@XisLn3A5z6UH&XwA`x(5zp4VlIoGM@-ix=wDD zmq3tvD)M$}y^1EeHBjrLq*~KhYsgwzC3+fgk6x%I@x0A79@J1)IzqzIfz_F$02)Dkc^OkcWjGv1m#~k fyffhu{^WVicHXe_y^r9(5>&o%TiK=8_I>y_s?m|B literal 0 HcmV?d00001 diff --git a/index.html b/index.html index 752cd12..c55fb2c 100644 --- a/index.html +++ b/index.html @@ -25,12 +25,18 @@

Поехали! -
-
ВИКТОРИНА
-
УГАДАЙ ЧИСЛО
-
ПЕРЕВЕРНИ ТЕКСТ
-
ПРОСТАЯ АРИФМЕТИКА
-
+
+
+
ВИКТОРИНА
+
УГАДАЙ ЧИСЛО
+
ПЕРЕВЕРНИ ТЕКСТ
+
ПРОСТАЯ АРИФМЕТИКА
+
ВИКТОРИНА
+
УГАДАЙ ЧИСЛО
+
ПЕРЕВЕРНИ ТЕКСТ
+
ПРОСТАЯ АРИФМЕТИКА
+
+
@@ -144,14 +150,14 @@

Угадай число

- game

Простая арифметика

Решай примеры на сложение, вычитание, умножение и деление

- +
+ game
@@ -161,21 +167,21 @@

Переверни текст

Введи текст и получи его в обратном порядке

- + game
- game

Викторина

Проверь свои знания в разных областях

- +
+ game
@@ -185,22 +191,22 @@

Камень, ножницы, бумага

Сыграй в классическую игру против компьютера

- + game
- game
-

Генератор случайных чисел

+

Генератор случайного цвета

Игра, в которой при клике на кнопку фон страницы меняется на случайный.

- +
+ game
diff --git a/script.js b/script.js index 9c29a93..9c8d0ed 100644 --- a/script.js +++ b/script.js @@ -34,6 +34,46 @@ function startGameOne() { } } +function startMathGame() { + let num1, num2, operation, question, correctAnswer; + + let operations = ["+", "-", "*", "/"]; + operation = operations[Math.floor(Math.random() * operations.length)]; + + if (operation === "/") { + num2 = Math.floor(Math.random() * 19) + 1; + correctAnswer = Math.floor(Math.random() * 10) + 1; + num1 = num2 * correctAnswer; + } else { + num1 = Math.floor(Math.random() * 20) + 1; + num2 = Math.floor(Math.random() * 20) + 1; + switch (operation) { + case "+": + correctAnswer = num1 + num2; + break; + case "-": + correctAnswer = num1 - num2; + break; + case "*": + correctAnswer = num1 * num2; + break; + } + } + + question = `${num1} ${operation} ${num2}`; + + + let userAnswer = prompt(`Реши пример: ${question}`); + + if (Number(userAnswer) === correctAnswer) { + alert("Верно!"); + } else { + alert(`Ошибка! Правильный ответ: ${correctAnswer}`); + } +} + + + // Игра "Камень, ножницы, бумага" const playGameRockPaperScissors = () => { @@ -72,4 +112,96 @@ function startGameOne() { alert(`Ваш выбор: ${userChoice}\nВыбор компьютера: ${computerChoice}\nРезультат: ${result}`); }; - \ No newline at end of file + + function startReverseTextGame() { + let userText = prompt("Введите текст, который нужно перевернуть:"); + + if (userText !== null) { + let reversed = userText.split("").reverse().join(""); + + alert("Перевернутый текст: " + reversed); + } +} + + +function startQuizGame() { + const quiz = [ + { + question: "Какой цвет небо?", + options: ["1. Красный", "2. Синий", "3. Зеленый"], + correctAnswer: 2 + }, + { + question: "Сколько дней в неделе?", + options: ["1. Шесть", "2. Семь", "3. Восемь"], + correctAnswer: 2 + }, + { + question: "Сколько у человека пальцев на одной руке?", + options: ["1. Четыре", "2. Пять", "3. Шесть"], + correctAnswer: 2 + } + ]; + + let score = 0; + + for (let i = 0; i < quiz.length; i++) { + let q = quiz[i]; + let userAnswer = prompt(q.question + "\n" + q.options.join("\n")); + + if (Number(userAnswer) === q.correctAnswer) { + score++; + } + } + + alert("Вы ответили правильно на " + score + " из " + quiz.length + " вопросов!"); +} + +function playRockPaperScissors() { + const options = ["камень", "ножницы", "бумага"]; + + let userChoice = prompt("Выберите: камень, ножницы или бумага").toLowerCase(); + + if (!options.includes(userChoice)) { + alert("Ошибка! Нужно ввести: камень, ножницы или бумага."); + return; + } + + let computerChoice = options[Math.floor(Math.random() * options.length)]; + + let result = ""; + + if (userChoice === computerChoice) { + result = "Ничья!"; + } else if ( + (userChoice === "камень" && computerChoice === "ножницы") || + (userChoice === "ножницы" && computerChoice === "бумага") || + (userChoice === "бумага" && computerChoice === "камень") + ) { + result = "Вы выиграли! 🎉"; + } else { + result = "Вы проиграли 😢"; + } + + alert( + "Ваш выбор: " + userChoice + + "\nВыбор компьютера: " + computerChoice + + "\nРезультат: " + result + ); +} + + +function startRandomColorGame() { + const letters = "0123456789ABCDEF"; + let color = "#"; + for (let i = 0; i < 6; i++) { + color += letters[Math.floor(Math.random() * 16)]; + } + const sections = document.querySelectorAll(".about-games, .mini-games"); + sections.forEach(section => { + section.style.backgroundColor = color; + }); + + alert("Новый случайный цвет: " + color); +} + diff --git a/styles.css b/styles.css index 6f330b0..f3e0867 100644 --- a/styles.css +++ b/styles.css @@ -83,6 +83,21 @@ html { align-items: center; } +.bottom-line__wrapper { + display: flex; + gap: 60px; + animation: scroll-left 15s linear infinite; +} + +@keyframes scroll-left { + 0% { + transform: translateX(0); + } + 100% { + transform: translateX(-50%); + } +} + .bottom-line__games:not(:last-child)::after { content: url(img/Star.svg); display: inline-block; @@ -109,17 +124,20 @@ html { margin: 0; } -.about-games { - background-image: url(img/aboutgames-background.jpg); - background-size: cover; - background-position: center; - background-repeat: no-repeat; +.about-games, +.mini-games { + background-color: rgba(32, 32, 39, 1); + background-image: url("img/Star 2.png"), url("img/Star 1.png"); + background-repeat: no-repeat, no-repeat; + background-position: bottom 100px left 50px, top 50px right 50px; + background-size: 120px, 300px; width: 100%; margin: 0 auto; padding: 40px; box-sizing: border-box; } + .about-games__title { color: rgb(255, 255, 255); display: flex; @@ -286,12 +304,6 @@ html { padding: 32px; } -.mini-games { - background-color: #202027; - width: 100%; - margin: 0 auto; -} - /* Контейнер для карточек игр */ .mini-games__container { display: flex; @@ -445,22 +457,33 @@ html { margin-left: 0 !important; align-self: center; } - .bottom-line { - position: absolute; - bottom: 0; - left: 0; - top: auto; - height: 51px; - padding: 0 20px; - justify-content: center; - align-items: center; - font-size: 24px; - overflow: hidden; - } - .bottom-line__games:not(:last-child)::after { - margin: 30px; +.bottom-line { + position: absolute; + bottom: 0; + left: 0; + width: 100%; + height: 51px; + padding: 0 20px; + font-size: 24px; + overflow: hidden; + background: rgb(188, 236, 48); +} + +.bottom-line__wrapper { + display: flex; + gap: 60px; + animation: scroll-left 15s linear infinite; +} + +@keyframes scroll-left { + 0% { + transform: translateX(0); } + 100% { + transform: translateX(-50%); + } +} } /* Мобильные устройства*/ diff --git a/tasks.html b/tasks.html new file mode 100644 index 0000000..caba061 --- /dev/null +++ b/tasks.html @@ -0,0 +1,60 @@ + + + + + + Document + + + + + + + + + + Document + + + +

Это заголовок!

+ + + +

Это абзац текста.

+ + + + +

Это заголовок!

+ + + + +

Это описание 1

+

Это описание 2

+

Это описание 3

+ + + +

Описание 1

+

Просто абзац

+

Описание 2

+

Примечание

+

Описание 3

+ + + + + +

Описание 1

+

Просто абзац

+

Описание 2

+

Описание 3

+ + + + + + + diff --git a/tasks.js b/tasks.js index fd66bb6..e47a47a 100644 --- a/tasks.js +++ b/tasks.js @@ -1,77 +1,66 @@ // Задание 1 -const people = [ - { name: 'Глеб', age: 29 }, - { name: 'Анна', age: 17 }, - { name: 'Олег', age: 7 }, - { name: 'Оксана', age: 47 } - ]; - - console.log(people.sort((a, b) => a.age - b.age)); +const title = document.querySelector("#main-title"); +const button = document.querySelector("#toggle-btn"); + +button.addEventListener("click", () => { + if (title.style.display === "none") { + title.style.display = "block"; + button.textContent = "Скрыть"; + } else { + title.style.display = "none"; + button.textContent = "Показать"; + } +}); + // Задание 2 -function isPositive(num) { - return num > 0; -} - -function isMale(person) { - return person.gender === 'male'; -} - -function filter(array, ruleFunction) { - const result = []; - - for (let i = 0; i < array.length; i++) { - if (ruleFunction(array[i])) { - result.push(array[i]); - } - } - - return result; -} - -console.log(filter([3, -4, 1, 9], isPositive)); // [3, 1, 9] - -const people = [ - {name: 'Глеб', gender: 'male'}, - {name: 'Анна', gender: 'female'}, - {name: 'Олег', gender: 'male'}, - {name: 'Оксана', gender: 'female'} -]; - -console.log(filter(people, isMale)); +const text = document.querySelector("#my-text"); +const button_two = document.querySelector("#color-btn"); -// Задание 3 -const intervalId = setInterval(() => { - console.log(new Date()); -}, 3000); +button_two.addEventListener("click", () => { + text.style.color = "blue"; +}); -setTimeout(() => { - clearInterval(intervalId); - console.log('30 секунд прошло'); -}, 30000); +// Задание 3 +const title_two = document.querySelector("#main-title_two"); +const changeTextBtn = document.querySelector("#change-text-btn"); +changeTextBtn.addEventListener("click", () => { + title_two.textContent = "Привет, мир!"; +}); // Задание 4 -function delayForSecond(callback) { - setTimeout(callback, 1000); -} +const descriptions = document.querySelectorAll(".description"); -delayForSecond(function () { - console.log('Привет, Глеб!'); +descriptions.forEach(el => { + el.textContent = "Измененный текст"; }); - // Задание 5 -function delayForSecond(cb) { - setTimeout(() => { - console.log('Прошла одна секунда'); - if(cb) { cb(); } - }, 1000) -} +const descriptions1 = document.querySelectorAll(".description1"); +descriptions1.forEach(element => { + element.textContent = "Новый текст"; +}); + +// Задание 6 +const addBtn = document.querySelector("#add-btn"); -function sayHi (name) { - console.log(`Привет, ${name}!`); -} +addBtn.addEventListener("click", () => { + const newParagraph = document.createElement("p"); + newParagraph.textContent = "Новый абзац"; + + document.body.appendChild(newParagraph); +}); -delayForSecond(() => sayHi('Глеб')); + +// Задание 7 +const deleteBtn = document.querySelector("#delete-btn"); + +deleteBtn.addEventListener("click", () => { + const firstDescription = document.querySelector(".description-three"); + + if (firstDescription) { + firstDescription.remove(); + } +});