From d3f325389ff7f75f932281b5b5861b974b2952a7 Mon Sep 17 00:00:00 2001 From: Tatsiana-Drozd Date: Thu, 17 Apr 2025 23:56:09 +0300 Subject: [PATCH 1/4] Update script.js --- script.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/script.js b/script.js index 4e2ff72..a39f2a5 100644 --- a/script.js +++ b/script.js @@ -13,3 +13,32 @@ /* При генерации нового предсказания старое предсказание должно добавляться в начало списка «Мои предсказания» — .forecasts */ /* Для добавления предсказания в список воспользуйся шаблоном forecast-item */ + +function getRandom(min, max) { + return (Math.floor(Math.random() * (max - min) + min)); +} + + +const btn = document.querySelector('.forecast-btn'); +btn.addEventListener('click', function() { + + let predictionNumber = getRandom(1, 6); + let predictionText = ""; + + if (predictionNumber == 1) { + predictionText = "Ваша цель достижима."; + } else if (predictionNumber == 2) { + predictionText = "Ориентируйся на маленькие победы - они повлекут за собой большие!"; + } else if (predictionNumber == 3) { + predictionText = "Осторожно, впереди волна впечатлений!"; + } else if (predictionNumber == 4) { + predictionText = "Улыбайся! Кто-то может влюбиться в твою улыбку!"; + } else { + predictionText = "Не оставляйте усилий и получите желаемое!"; + } +}); + + +const current_forecast = document.querySelector('.current-forecast'); +let currentForecastH1 = current_forecast.querySelector('h1'); +currentForecastH1.textContent = predictionText; \ No newline at end of file From 2618a5941a40aa20067314c49a94e99c9b485145 Mon Sep 17 00:00:00 2001 From: Tatsiana-Drozd Date: Wed, 30 Apr 2025 22:40:03 +0300 Subject: [PATCH 2/4] =?UTF-8?q?=D0=B4=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=D0=BB=D0=B0=20=D0=BF=D1=80=D0=BE=D0=B5=D0=BA=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 3 +++ script.js | 24 ++++++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..6f3a291 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} \ No newline at end of file diff --git a/script.js b/script.js index a39f2a5..9bb8dca 100644 --- a/script.js +++ b/script.js @@ -15,14 +15,16 @@ /* Для добавления предсказания в список воспользуйся шаблоном forecast-item */ function getRandom(min, max) { - return (Math.floor(Math.random() * (max - min) + min)); + let rand = min + Math.random() * (max - min); + return Math.round(rand); } + const btn = document.querySelector('.forecast-btn'); btn.addEventListener('click', function() { - let predictionNumber = getRandom(1, 6); + let predictionNumber = getRandom(1, 5); let predictionText = ""; if (predictionNumber == 1) { @@ -36,9 +38,19 @@ btn.addEventListener('click', function() { } else { predictionText = "Не оставляйте усилий и получите желаемое!"; } -}); + const currentForecast = document.querySelector('.current-forecast'); + let currentForecastH1 = currentForecast.querySelector('h1'); + currentForecastH1.textContent = predictionText; + + const currentForecastP = currentForecast.querySelector('p'); + currentForecastP.textContent = getRandom(1, 100); + + const template = document.querySelector('#forecast-item'); + const myTemplate = template.content.cloneNode(true); + myTemplate.querySelector('h3').textContent = predictionText; + myTemplate.querySelector('p').textContent = currentForecastP; -const current_forecast = document.querySelector('.current-forecast'); -let currentForecastH1 = current_forecast.querySelector('h1'); -currentForecastH1.textContent = predictionText; \ No newline at end of file + const forecasts = document.querySelector('.forecasts'); + forecasts.append(myTemplate); +}); \ No newline at end of file From a199c93f46453977133bcb8e32d3c883c9b4b00f Mon Sep 17 00:00:00 2001 From: Tatsiana-Drozd Date: Sat, 3 May 2025 21:32:14 +0300 Subject: [PATCH 3/4] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=BD=D1=8B=D0=B9=20=D0=B2=D0=B0=D1=80=D0=B8=D0=B0?= =?UTF-8?q?=D0=BD=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/script.js b/script.js index 9bb8dca..1122ca1 100644 --- a/script.js +++ b/script.js @@ -14,14 +14,19 @@ /* Для добавления предсказания в список воспользуйся шаблоном forecast-item */ +const btn = document.querySelector('.forecast-btn'); +const currentForecast = document.querySelector('.current-forecast'); +const currentForecastP = currentForecast.querySelector('p'); +const currentForecastH1 = currentForecast.querySelector('h1'); +const template = document.querySelector('#forecast-item'); +const forecasts = document.querySelector('.forecasts'); + + function getRandom(min, max) { - let rand = min + Math.random() * (max - min); - return Math.round(rand); + return (Math.floor(Math.random() * (max - min) + min)); } - -const btn = document.querySelector('.forecast-btn'); btn.addEventListener('click', function() { let predictionNumber = getRandom(1, 5); @@ -38,19 +43,14 @@ btn.addEventListener('click', function() { } else { predictionText = "Не оставляйте усилий и получите желаемое!"; } - const currentForecast = document.querySelector('.current-forecast'); - let currentForecastH1 = currentForecast.querySelector('h1'); + currentForecastH1.textContent = predictionText; - const currentForecastP = currentForecast.querySelector('p'); currentForecastP.textContent = getRandom(1, 100); - const template = document.querySelector('#forecast-item'); const myTemplate = template.content.cloneNode(true); - myTemplate.querySelector('h3').textContent = predictionText; - myTemplate.querySelector('p').textContent = currentForecastP; + myTemplate.querySelector('p').textContent = getRandom(1, 100); - const forecasts = document.querySelector('.forecasts'); forecasts.append(myTemplate); }); \ No newline at end of file From d8bab25c91675129c8d4832ce6763b8e59030dde Mon Sep 17 00:00:00 2001 From: Tatsiana-Drozd Date: Sat, 3 May 2025 21:37:33 +0300 Subject: [PATCH 4/4] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=BD=D1=8B=D0=B9=20=D0=B2=D0=B0=D1=80=D0=B8=D0=B0?= =?UTF-8?q?=D0=BD=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script.js | 1 - 1 file changed, 1 deletion(-) diff --git a/script.js b/script.js index 1122ca1..d8223dd 100644 --- a/script.js +++ b/script.js @@ -45,7 +45,6 @@ btn.addEventListener('click', function() { } currentForecastH1.textContent = predictionText; - currentForecastP.textContent = getRandom(1, 100); const myTemplate = template.content.cloneNode(true);