diff --git a/layouts/partials/header.html b/layouts/partials/header.html index 775f2e3..2e7512d 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -28,15 +28,15 @@ function setPrefTheme(theme) { localStorage.setItem("pref-theme", theme); } -const toggleThemeCallbacks = [] -toggleThemeCallbacks.push((isDark) => { +const toggleThemeCallbacks = {} +toggleThemeCallbacks['main'] = (isDark) => { // console.log('window toggle-theme 1') if (isDark) { setPrefTheme('light'); } else { setPrefTheme('dark'); } -}) +} // listen to set-theme event, // because window is never changed by InstantClick, @@ -44,7 +44,9 @@ toggleThemeCallbacks.push((isDark) => { window.addEventListener('toggle-theme', function() { // console.log('window toggle-theme') const isDark = isDarkTheme() - toggleThemeCallbacks.forEach(callback => callback(isDark)) + for (const key in toggleThemeCallbacks) { + toggleThemeCallbacks[key](isDark) + } }); - - diff --git a/layouts/partials/telegram_widget.html b/layouts/partials/telegram_widget.html index 786f19a..df75a59 100644 --- a/layouts/partials/telegram_widget.html +++ b/layouts/partials/telegram_widget.html @@ -4,6 +4,24 @@ - -