From 38db9cd9cf56df51e1c6143f6cfa891f46a4ef1d Mon Sep 17 00:00:00 2001 From: FURK4NGG <105324908+FURK4NGG@users.noreply.github.com> Date: Mon, 24 Feb 2025 20:56:52 +0300 Subject: [PATCH] Update 1.js --- JAVASCRIPT/1.js | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/JAVASCRIPT/1.js b/JAVASCRIPT/1.js index 3f19ae4..24b4bed 100644 --- a/JAVASCRIPT/1.js +++ b/JAVASCRIPT/1.js @@ -1,27 +1,20 @@ /*CHANGE THEME*/ +// Darkmode instance'ını oluştur const darkmode = new Darkmode(); document.getElementById("darkmode-toggle").addEventListener("click", function () { darkmode.toggle(); // Dark mode'u aç/kapat let metaTheme = document.getElementById("themeMeta"); - - // MutationObserver ile class değişimini takip et - const observer = new MutationObserver(() => { - if (document.body.classList.contains("darkmode--activated")) { - metaTheme.setAttribute("content", "#100f2c"); // Dark mode theme rengi - } else { - metaTheme.setAttribute("content", "#F8F6E3"); // Light mode theme rengi - } - }); - - // Sadece class değişikliklerini izle - observer.observe(document.body, { attributes: true, attributeFilter: ["class"] }); - - // 1 saniye sonra observer'ı kapat (gereksiz yükü engellemek için) - setTimeout(() => observer.disconnect(), 1000); + + // Karanlık modun aktif olup olmadığını localStorage'dan al + const isDarkMode = darkmode.isActivated(); + + // Doğrudan theme color'ı değiştir + metaTheme.setAttribute("content", isDarkMode ? "#100f2c" : "#F8F6E3"); }); + /*SERVICES VISIBILITY*/ const boxes = document.querySelectorAll('.services_id');