Skip to content

Commit

Permalink
Update visitors.js
Browse files Browse the repository at this point in the history
update v1.1
  • Loading branch information
margregorioschurch authored Dec 21, 2024
1 parent 2180216 commit 98bcba6
Showing 1 changed file with 40 additions and 40 deletions.
80 changes: 40 additions & 40 deletions js/visitors.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,46 @@ document.addEventListener('DOMContentLoaded', function () {
}
});
});

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

// Check the saved theme in localStorage
const savedMode = localStorage.getItem('darkMode');
const isDarkMode = savedMode ? JSON.parse(savedMode) : false; // Default to false if no saved mode

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

// Set the initial state of the checkbox
if (darkModeToggle) {
darkModeToggle.checked = isDarkMode;

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

// Save the preference in localStorage
localStorage.setItem('darkMode', JSON.stringify(newMode));
});
}
});

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

// Apply the dark mode or light mode class to the body element
body.classList.toggle('dark-mode', isDarkMode);
body.classList.toggle('light-mode', !isDarkMode);

// Apply dark mode to other containers if necessary
const allContainers = document.querySelectorAll('.container, .header, .footer'); // Adjust based on your needs
allContainers.forEach(container => {
container.classList.toggle('dark-mode', isDarkMode);
});
};
// Debug script.js
var h = document.getElementById("tsparticles")
, i = performance.timing;
Expand Down Expand Up @@ -69,45 +109,5 @@ function k(a) {
}
console.log("> Cookie-Enabled:", navigator.cookieEnabled, "\n", f),
g();
// Dark Theme script.js
document.addEventListener('DOMContentLoaded', function () {
const darkModeToggle = document.getElementById('darkModeToggle');

// Check the saved theme in localStorage
const savedMode = localStorage.getItem('darkMode');
const isDarkMode = savedMode ? JSON.parse(savedMode) : false; // Default to false if no saved mode

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

// Set the initial state of the checkbox
if (darkModeToggle) {
darkModeToggle.checked = isDarkMode;

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

// Save the preference in localStorage
localStorage.setItem('darkMode', JSON.stringify(newMode));
});
}
});

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

// Apply the dark mode or light mode class to the body element
body.classList.toggle('dark-mode', isDarkMode);
body.classList.toggle('light-mode', !isDarkMode);

// Apply dark mode to other containers if necessary
const allContainers = document.querySelectorAll('.container, .header, .footer'); // Adjust based on your needs
allContainers.forEach(container => {
container.classList.toggle('dark-mode', isDarkMode);
});
}


//const countEl=document.getElementById("CounterVisitor");function updateVisitCount(){fetch("https://api.countapi.xyz/update/mgm/visits/?amount=1").then(t=>t.json()).then(t=>{countEl.innerHTML=t.value})}updateVisitCount();

0 comments on commit 98bcba6

Please sign in to comment.