Skip to content

Commit

Permalink
Update visitors.js
Browse files Browse the repository at this point in the history
initial commit
  • Loading branch information
margregorioschurch authored Jan 5, 2024
1 parent f96ab05 commit c040bd8
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion js/visitors.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,39 @@ function setDarkMode(isDarkMode) {
} else {
body.classList.remove('dark-mode');
body.classList.add('light-mode');
darkModeContainer.classList.remove('dark-mode-container');

}
};

// script.js
document.addEventListener('DOMContentLoaded', function () {
const darkModeToggle = document.getElementById('darkModeToggle');

// Set initial mode (false for light mode, true for dark mode)
const isDarkMode = false;

// Set initial mode based on the default
setDarkMode(isDarkMode);

// Set the initial state of the checkbox
darkModeToggle.checked = isDarkMode;

// Toggle dark mode when the checkbox is clicked
darkModeToggle.addEventListener('change', function () {
const newMode = darkModeToggle.checked;
setDarkMode(newMode);
});
});

function setDarkMode(isDarkMode) {
const body = document.body;
const darkModeContainer = document.getElementById('darkModeContainer');

body.classList.toggle('dark-mode', isDarkMode);
body.classList.toggle('light-mode', !isDarkMode);

if (darkModeContainer) {
darkModeContainer.classList.toggle('dark-mode-container', isDarkMode);
}
};

Expand Down

0 comments on commit c040bd8

Please sign in to comment.