thuiop / magium-dev

MIT License
6 stars 3 forks source link

Move few functions from utils.js to night_mode.js #30

Closed ZiClaud closed 3 days ago

ZiClaud commented 2 weeks ago

Those functions appear on utils.js, but maybe they should be moved to night_mode.js

function setTheme(theme) {
    document.documentElement.setAttribute('data-theme', theme);
    document.cookie = 'data-theme=' + theme;
}

// On page load, set the theme based on the cookie
document.addEventListener('DOMContentLoaded', () => {
    const theme = getCookie('data-theme') || 'light'; // Default to 'light' if no cookie is found
    setTheme(theme);
});

I feel like we should remove the utils.js completely. Maybe create handle_cookie.js and save_game.js

himanshunaidu commented 2 weeks ago

Alright. I am planning to do some (hopefully non-breaking) refactoring on the stats.ejs file to move most of the static code to the stats.js file. Will try to handle this in that PR.

himanshunaidu commented 2 weeks ago

We will however, be better off at least keeping the file. We can try to have as few functions as possible.