diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 065d6be..e176fa0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,5 @@ # Add your Github username below if you are contributing to this project. 1. zetabug -1. jjakk \ No newline at end of file +2. jjakk +3. khamal45 diff --git a/app.js b/app.js index 8acbdef..ab2c5c9 100644 --- a/app.js +++ b/app.js @@ -1,7 +1,7 @@ const options = ["rock", "paper", "scissor"]; let score = { you: 0, - computer: 0 + computer: 0, }; const WIN_GREEN = "#6ac475"; const LOSE_RED = "#c4736a"; @@ -19,12 +19,11 @@ btns.forEach((btn) => { btn.addEventListener("click", () => { document.querySelector(".hands .player-hand").src = "rock.png"; document.querySelector(".hands .computer-hand").src = "rock.png"; - playerHand.classList.add('shakePlayer') - computerHand.classList.add('shakeComputer') + playerHand.classList.add("shakePlayer"); + computerHand.classList.add("shakeComputer"); const playerA = btn.querySelector("label").innerText; const playerB = options[getRandomInt()]; - setTimeout(()=>compare(playerA, playerB),1000) - + setTimeout(() => compare(playerA, playerB), 1000); }); }); @@ -108,11 +107,10 @@ function update(player, computer) { } else if (computer == "scissor") { computerHand.src = scissor; } - playerHand.classList.remove('shakePlayer') - computerHand.classList.remove('shakeComputer') + playerHand.classList.remove("shakePlayer"); + computerHand.classList.remove("shakeComputer"); } - //Reset Game Button --------------------------------- const resetBtn = document.querySelector(".reset"); resetBtn.addEventListener("click", () => { @@ -125,6 +123,27 @@ resetBtn.addEventListener("click", () => { document.querySelector(".hands .computer-hand").src = "rock.png"; }); +document.addEventListener("DOMContentLoaded", () => { + const toggleButton = document.getElementById("toggleTheme"); + + const body = document.body; + + // Load the theme from localStorage + const currentTheme = localStorage.getItem("theme") || "dark-mode"; + body.classList.add(currentTheme); + + toggleButton.addEventListener("click", () => { + if (body.classList.contains("dark-mode")) { + body.classList.remove("dark-mode"); + body.classList.add("light-mode"); + localStorage.setItem("theme", "light-mode"); + } else { + body.classList.remove("light-mode"); + body.classList.add("dark-mode"); + localStorage.setItem("theme", "dark-mode"); + } + }); +}); // // Mapping // // 0 -> rock, 1->paper, 2->scissor diff --git a/index.html b/index.html index d855c7d..5932597 100644 --- a/index.html +++ b/index.html @@ -43,28 +43,35 @@