From 15999581a8178064df1fa50d72080db9b5f8e12f Mon Sep 17 00:00:00 2001 From: Fovway Date: Sun, 9 Mar 2025 12:45:28 +0000 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=B2=20=C2=AB?= =?UTF-8?q?/=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ratingColor.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 ratingColor.js diff --git a/ratingColor.js b/ratingColor.js new file mode 100644 index 0000000..4893f16 --- /dev/null +++ b/ratingColor.js @@ -0,0 +1,20 @@ + function updateRating(){ + let cardVote = document.querySelectorAll('.card__vote'); + for(let voteCard of cardVote){ + if (voteCard.innerHTML >= 0 && voteCard.innerHTML <= 3.9) { + voteCard.style.color = "red"; + } else if (voteCard.innerHTML >= 4 && voteCard.innerHTML <= 6.9) { + voteCard.style.color = "orange"; + } else if (voteCard.innerHTML >= 7 && voteCard.innerHTML <= 7.9) { + voteCard.style.color = "lightgreen"; + } else if (voteCard.innerHTML >= 8 && voteCard.innerHTML <= 10) { + voteCard.style.color = "lawngreen"; + } + } + } + document.addEventListener("DOMContentLoaded", function () { + setTimeout(updateRating, 500); + }); + + const observer = new MutationObserver(updateRating); + observer.observe(document.body, { childList: true, subtree: true });