diff --git a/html/index.html b/html/index.html index b35166426..282fc2d6d 100644 --- a/html/index.html +++ b/html/index.html @@ -21,7 +21,7 @@ // This also works with older firmware that do not support password protection (will get a 404 for /v1/info) let [status_code, content] = await make_get_request("http://" + serverIP + "/v1/info"); if (status_code == 401 || status_code == 403) { - $("#banner").html(" "); + $("#bannertitle").html(" "); $("#left-nav").css("visibility", "hidden"); $("#password").val(""); $(".page").hide(); @@ -39,7 +39,7 @@ else { $("#logoutmenuitem").hide(); } - $("#banner").html(product + " HTTP Server"); + $("#bannertitle").html(product + " HTTP Server"); $("#left-nav").css("visibility", "visible"); $(".page").hide(); $("#welcome").show(); @@ -848,6 +848,35 @@ greetings: 'Ultimate 64 / II+ Remote Monitor\nhelp = list of commands\n' }); + // To add a theme, register the css class name in the array of themeNames, then themes.setTheme(themeName). + // When setTheme is called, it will unregister all classes from the themeNames and then apply then new className. + const themes = (() => { + const themeNames = ['lightmode', 'darkmode' /*, 'purple-theme' */ ]; + + const themedSelectors = [ 'body', '#left-nav', '#banner', 'a:-webkit-any-link', 'div#left-nav a', '#banner', + '#left-nav', '#darkmode-button', '#lightmode-button' + ]; + + // theme: darkmode, lightmode, ...purple-theme...etc. + const removeThemes = () => themeNames.forEach(themeName => $(themedSelectors.join(',')).removeClass(themeName)); + const setTheme = (themeName) => { removeThemes(); $(themedSelectors.join(',')).addClass(themeName); }; + const setLightMode = () => { setTheme('lightmode'); }; + const setDarkMode = () => { setTheme('darkmode'); }; + const initDisplayMode = () => { + if(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { setDarkMode(); return; } + setLightMode(); + }; + + return { + initDisplayMode, setTheme, setLightMode, setDarkMode + }; + })(); + + $('#darkmode-button').on('click', () => themes.setDarkMode() ); + $('#lightmode-button').on('click', () => themes.setLightMode() ); + + themes.initDisplayMode(); + // Kick off login/welcome screen as needed await ensureLoggedIn(); }); @@ -1347,7 +1376,6 @@
- +