spanish-quizzer

An app to quiz you on Spanish vocabulary and verb conjugations
git clone https://git.ashermorgan.net/spanish-quizzer/
Log | Files | Refs | README

commit 54cdb0f73501be9430b3e219055c10d401009f73
parent 912507f5a8177fee5f925f8dca32ebb4c79e3ec7
Author: AsherMorgan <59518073+AsherMorgan@users.noreply.github.com>
Date:   Sat, 20 Mar 2021 17:30:39 -0700

Detect and apply prefered theme on first visit

Diffstat:
Mjs/global.js | 12++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/js/global.js b/js/global.js @@ -39,6 +39,12 @@ function getSettings() { multipleAnswers: "Require all", }; + // Detect prefered theme + try { + settings.darkTheme = (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches); + } + catch { } + // Parse settings let parsedSettings; try { @@ -51,12 +57,6 @@ function getSettings() { if ([true, false].includes(parsedSettings.darkTheme)) { settings.darkTheme = parsedSettings.darkTheme; } - else { - try { - settings.darkTheme = (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) - } - catch { } - } if ([true, false].includes(parsedSettings.conjugationColors)) { settings.conjugationColors = parsedSettings.conjugationColors; }