From 1d0d9415b4506bde5f55018004a383ddae0dd5ea Mon Sep 17 00:00:00 2001 From: Anastasia Arefeva <89157321250@mail.ru> Date: Wed, 1 Oct 2025 15:20:12 +0300 Subject: [PATCH 1/4] index --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 6f14ae14a..aed84496d 100644 --- a/index.html +++ b/index.html @@ -65,7 +65,7 @@ From f4d6e673b22257706e67faab8a0e044ff4c7e54f Mon Sep 17 00:00:00 2001 From: Anastasia Arefeva <89157321250@mail.ru> Date: Wed, 1 Oct 2025 15:21:49 +0300 Subject: [PATCH 2/4] index --- desktop.ini | 2 ++ index.html | 80 ++++++++++++++++++++++++++++++----------------------- 2 files changed, 47 insertions(+), 35 deletions(-) create mode 100644 desktop.ini diff --git a/desktop.ini b/desktop.ini new file mode 100644 index 000000000..5f2457d6c --- /dev/null +++ b/desktop.ini @@ -0,0 +1,2 @@ +[.ShellClassInfo] +LocalizedResourceName=@webdev-dom-homework,0 diff --git a/index.html b/index.html index aed84496d..b80b37bde 100644 --- a/index.html +++ b/index.html @@ -9,40 +9,7 @@
"use strict"; - console.log("It works!"); + const comments = [ + { + name: "Глеб Фокин", + date: new Date(), + text: "Это будет первый комментарий на этой странице", + }, + { + name: "Варвара Н.", + date: new Date(), + text: "Мне нравится как оформлена эта страница! ❤", + }, + ]; + + const renderComments = () => { + const list = document.querySelector(".comments"); + + list.innerHTML = comments + .map((comment, index) => { + return ` +
  • +
    +
    ${comment.name}
    +
    ${comment.date.toLocaleDateString()}
    +
    +
    +
    + ${comment.text} +
    +
    + +
  • + `; + }) + .join(""); + + }; + +renderComments(); + From e89adf506fa256b0d8b941309cef6ac9985cdecc Mon Sep 17 00:00:00 2001 From: Anastasia Arefeva <89157321250@mail.ru> Date: Wed, 1 Oct 2025 15:27:00 +0300 Subject: [PATCH 3/4] index --- index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/index.html b/index.html index b80b37bde..ada8047d2 100644 --- a/index.html +++ b/index.html @@ -77,5 +77,6 @@ renderComments(); + From 7fbc1a56a18f8f37e6ec216ae9c5a56a50b902a1 Mon Sep 17 00:00:00 2001 From: Anastasia Arefeva <89157321250@mail.ru> Date: Wed, 1 Oct 2025 16:31:51 +0300 Subject: [PATCH 4/4] index and css --- index.html | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index ada8047d2..5af7af5f5 100644 --- a/index.html +++ b/index.html @@ -16,12 +16,14 @@ type="text" class="add-form-name" placeholder="Введите ваше имя" + id="name-input" />
    @@ -38,11 +40,15 @@ name: "Глеб Фокин", date: new Date(), text: "Это будет первый комментарий на этой странице", + likes: 3, + isliked: false, }, { name: "Варвара Н.", date: new Date(), text: "Мне нравится как оформлена эта страница! ❤", + likes: 75, + isliked: true, }, ]; @@ -64,8 +70,9 @@
    @@ -77,6 +84,26 @@ renderComments(); +const addButton = document.querySelector(".add-form-button"); +const name = document.getElementById("name-input"); +const text = document.getElementById("text-input"); + +addButton.addEventListener("click", () => { + const newComment = { + name: name.value, + date: new Date(), + text: text.value, + likes: 0, + }; + + comments.push(newComment); + + renderComments(); + + name.value = ""; + text.value = ""; +}); +