From 6478e978941e95f56f56fcce2ae2fa9ebeb80df8 Mon Sep 17 00:00:00 2001 From: PrestonT500 Date: Wed, 2 Oct 2024 13:34:14 -0700 Subject: [PATCH] Made darkmode actually work (V1) --- index.html | 5 +++-- js/darkmoderewrite.js | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 js/darkmoderewrite.js diff --git a/index.html b/index.html index 06b3841..151a6b7 100644 --- a/index.html +++ b/index.html @@ -14,14 +14,15 @@ - +

Welcome to EaglerCraftX

- + +

Site views counter:

diff --git a/js/darkmoderewrite.js b/js/darkmoderewrite.js new file mode 100644 index 0000000..b34c854 --- /dev/null +++ b/js/darkmoderewrite.js @@ -0,0 +1,26 @@ +$(document).ready(function() { + function updateDarkMode() { + var isChecked = $("#darkModeCheckbox").is(":checked"); + if (isChecked) { + const body = document.querySelector('body'); + body.style.backgroundColor = '#404040'; + + const text = document.querySelector('.footer'); + text.style.backgroundColor = 'grey'; + + } else { + const body = document.querySelector('body'); + body.style.backgroundColor = '#f1f1f1'; + + const text = document.querySelector('.footer'); + text.style.backgroundColor = '#ddd'; + + } + } + + $("#darkModeCheckbox").on("change", function() { + updateDarkMode(); + }); + + updateDarkMode(); +});