From 71ab4a120db05e055de864efd09d43e901ef8aaa Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado Date: Sat, 28 May 2022 05:11:10 -0600 Subject: add support for gdscript for hljs, add wip flappy bird devlog --- static/scripts/theme.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'static/scripts/theme.js') diff --git a/static/scripts/theme.js b/static/scripts/theme.js index 9036698..a107101 100644 --- a/static/scripts/theme.js +++ b/static/scripts/theme.js @@ -1,7 +1,10 @@ -// refactored code for a better solution found in https://medium.com/@haxzie/dark-and-light-theme-switcher-using-css-variables-and-pure-javascript-zocada-dd0059d72fa2 +// refactored code for a better solution found in: +// https://medium.com/@haxzie/dark-and-light-theme-switcher-using-css-variables-and-pure-javascript-zocada-dd0059d72fa2 var local_storage = window.localStorage; -window.onload = () => { +// changed window.onload to document.addEventListener, as suggested here: +// https://stackoverflow.com/a/800010 +document.addEventListener("DOMContentLoaded", function(event) { let theme = local_storage.getItem('theme'); if(theme == null){ @@ -15,7 +18,7 @@ window.onload = () => { setTheme('theme-light'); } } -} +}) function setTheme(themeName){ local_storage.setItem('theme', themeName) -- cgit v1.2.3-54-g00ecf