From c2b401cb8b7be04b4f0088cf248d47e30dc39ef4 Mon Sep 17 00:00:00 2001 From: Abdalwahab Date: Sun, 15 Feb 2026 19:11:31 +0300 Subject: [PATCH 1/6] Fix dark mode toggle and other improvements --- script.js | 20 +++++++++++++------- styles.css | 29 +++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/script.js b/script.js index 43cfa50..adfd705 100644 --- a/script.js +++ b/script.js @@ -25,15 +25,19 @@ document.addEventListener('DOMContentLoaded', function() { }); function toggleTheme() { + const body = document.body; const themeIcon = document.querySelector('.theme-icon'); - - if (themeIcon.textContent === '🌙') { - themeIcon.textContent = '☀️'; + + // toggle dark mode class + body.classList.toggle('dark-mode'); + + // change icon + if (body.classList.contains('dark-mode')) { + themeIcon.textContent = '☀️'; // sun icon for light mode } else { - themeIcon.textContent = '🌙'; + themeIcon.textContent = '🌙'; // moon icon for dark mode } } - function switchTab(tabName) { const tabs = document.querySelectorAll('.tab-content'); tabs.forEach(tab => tab.classList.remove('active')); @@ -57,9 +61,11 @@ function loadWordBank() { } function saveWordBank() { - localStorage.setItem('devopsWords', JSON.stringify(wordBank)); -} + // save fix + + localStorage.setItem('wordBank', JSON.stringify(wordBank)); +} function displayWordBank() { const wordList = document.getElementById('wordList'); const wordCount = document.getElementById('wordCount'); diff --git a/styles.css b/styles.css index 2d7f786..1c35a92 100644 --- a/styles.css +++ b/styles.css @@ -527,3 +527,32 @@ body.dark-mode .add-word-form input { body.dark-mode .empty-state { color: #999; } + +/* Default light theme */ +body { + background-color: #fff; + color: #000; +} + +/* Dark mode */ +body.dark-mode { + background-color: #121212; + color: #eee; +} + +/* Optional: adjust buttons and other elements */ +body.dark-mode .word-item, +body.dark-mode .key { + background-color: #1f1f1f; + color: #eee; + border: 1px solid #444; +} + +body.dark-mode .tab-content { + background-color: #1a1a1a; +} + +body.dark-mode .game-status.show { + background-color: #333; + color: #fff; +} \ No newline at end of file From 7960a63263470f11229a0486c317f836fb078dcb Mon Sep 17 00:00:00 2001 From: Abdalwahab Date: Sun, 15 Feb 2026 19:15:15 +0300 Subject: [PATCH 2/6] Fix empty words accepted 4 --- script.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/script.js b/script.js index adfd705..fc167ad 100644 --- a/script.js +++ b/script.js @@ -101,12 +101,17 @@ function addWord() { const input = document.getElementById('newWord'); const word = input.value.trim().toUpperCase(); + // ignore empty input + if (word === '') { + alert('Please enter a word before adding.'); + return; + } + wordBank.push(word); input.value = ''; saveWordBank(); displayWordBank(); } - function editWord(index) { const newWord = prompt('Edit word:', wordBank[index]); if (newWord) { From 5574f49e0971433f02ad12621caa2a34d209ab60 Mon Sep 17 00:00:00 2001 From: Abdalwahab Date: Sun, 15 Feb 2026 19:33:19 +0300 Subject: [PATCH 3/6] Fix: prevent adding empty words and trim input 4 --- script.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/script.js b/script.js index fc167ad..034ea37 100644 --- a/script.js +++ b/script.js @@ -101,9 +101,15 @@ function addWord() { const input = document.getElementById('newWord'); const word = input.value.trim().toUpperCase(); - // ignore empty input - if (word === '') { - alert('Please enter a word before adding.'); + // Reject empty input + if (!word) { + alert('⚠️ Cannot add an empty word!'); + return; + } + + // Reject duplicate words + if (wordBank.includes(word)) { + alert('⚠️ Word already exists in the bank!'); return; } @@ -112,6 +118,7 @@ function addWord() { saveWordBank(); displayWordBank(); } + function editWord(index) { const newWord = prompt('Edit word:', wordBank[index]); if (newWord) { From 7f69d3eb93659e8c761049cc1effa16d88c91a98 Mon Sep 17 00:00:00 2001 From: Abdalwahab Date: Sun, 15 Feb 2026 19:40:44 +0300 Subject: [PATCH 4/6] Fix:dark mode #1 --- styles.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/styles.css b/styles.css index 1c35a92..8a28cfb 100644 --- a/styles.css +++ b/styles.css @@ -545,7 +545,7 @@ body.dark-mode .word-item, body.dark-mode .key { background-color: #1f1f1f; color: #eee; - border: 1px solid #444; + border: 4px solid #444; } body.dark-mode .tab-content { From 58e91e65fa39ee501457d4dfd823371ff800cd37 Mon Sep 17 00:00:00 2001 From: Abdalwahab Date: Sun, 15 Feb 2026 19:44:27 +0300 Subject: [PATCH 5/6] Fix:edit delete bug #2 --- script.js | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/script.js b/script.js index 034ea37..6ccb59a 100644 --- a/script.js +++ b/script.js @@ -120,14 +120,26 @@ function addWord() { } function editWord(index) { - const newWord = prompt('Edit word:', wordBank[index]); - if (newWord) { - wordBank.splice(index, 1); - saveWordBank(); - displayWordBank(); + const currentWord = wordBank[index]; + const newWord = prompt('Edit word:', currentWord); + + if (!newWord) { + alert('⚠️ You must enter a word.'); + return; } -} + const formattedWord = newWord.trim().toUpperCase(); + + if (wordBank.includes(formattedWord) && formattedWord !== currentWord) { + alert('⚠️ This word already exists in the bank!'); + return; + } + + // update the word + wordBank[index] = formattedWord; + saveWordBank(); + displayWordBank(); +} function deleteWord(index) { if (confirm('Are you sure you want to delete this word?')) { saveWordBank(); From 7f86dbe35a845d36bffdad92ec378239a2d20aef Mon Sep 17 00:00:00 2001 From: Abdalwahab Date: Sun, 15 Feb 2026 19:48:00 +0300 Subject: [PATCH 6/6] Fix:duplicate bug #3 --- script.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/script.js b/script.js index 6ccb59a..a685cd8 100644 --- a/script.js +++ b/script.js @@ -101,18 +101,19 @@ function addWord() { const input = document.getElementById('newWord'); const word = input.value.trim().toUpperCase(); - // Reject empty input - if (!word) { - alert('⚠️ Cannot add an empty word!'); + // ignore empty input + if (word === '') { + alert('Please enter a word before adding.'); return; } - // Reject duplicate words + // check for duplicates if (wordBank.includes(word)) { - alert('⚠️ Word already exists in the bank!'); + alert('This word already exists in the bank!'); return; } + // add the word wordBank.push(word); input.value = ''; saveWordBank();