From a702051aef4b32fca7fd516a34415fcbb1e8c871 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Sun, 3 Dec 2023 12:07:07 +0100 Subject: Move theme switcher to bottom; add 'use device theme' --- public/static/js/collapse.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'public/static/js') diff --git a/public/static/js/collapse.js b/public/static/js/collapse.js index 2beead1..30e111e 100644 --- a/public/static/js/collapse.js +++ b/public/static/js/collapse.js @@ -4,6 +4,19 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ +function setLang(lang) { + document.cookie = 'lang=' + lang; + location.reload(); +} + +function setTheme(theme) { + localStorage.setItem('theme', theme); + if (!otherTheme.hasOwnProperty(theme)) { + theme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'; + } + addStyleSheet(theme, 'theme'); +} + function reload_app() { // TODO use a variable instead of window.location.href, as // window.location.href may be /z/... -- cgit v1.2.3