From 52e3d506f1f3a37d75f4b66654fedd55ec667b32 Mon Sep 17 00:00:00 2001 From: FURK4NGG <105324908+FURK4NGG@users.noreply.github.com> Date: Thu, 20 Feb 2025 18:17:03 +0300 Subject: [PATCH] Update 1.js --- JAVASCRIPT/1.js | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/JAVASCRIPT/1.js b/JAVASCRIPT/1.js index 711116a..05ac8ed 100644 --- a/JAVASCRIPT/1.js +++ b/JAVASCRIPT/1.js @@ -217,7 +217,34 @@ const options = { saveInCookies: true, // default: true, label: '◐', // default: '' autoMatchOsTheme: true // default: true -} +} + +function updateThemeColor() { + let themeColorMeta = document.querySelector('meta[name="theme-color"]'); + + if (!themeColorMeta) { + themeColorMeta = document.createElement('meta'); + themeColorMeta.setAttribute('name', 'theme-color'); + document.head.appendChild(themeColorMeta); + } + + if (darkmode.isActivated()) { + document.body.style.backgroundColor = "#100f2c"; // Arka plan siyah + themeColorMeta.setAttribute("content", "#100f2c"); // Tarayıcı rengi siyah + } else { + document.body.style.backgroundColor = "#fff"; // Açık moda dön + themeColorMeta.setAttribute("content", "#fff"); // Tarayıcı rengi beyaz + } +} + +// Sayfa açıldığında ve toggle butonuna basıldığında güncelle +updateThemeColor(); + +document.addEventListener("click", function(event) { + if (event.target.classList.contains("darkmode-toggle")) { + setTimeout(updateThemeColor, 500); // Butona basılınca 0.5s gecikmeli güncelle + } +}); /*GALLERY IMAGES*/