perf(storage): move theme choice to localstorage

This commit is contained in:
Romain J 2020-05-16 14:12:46 +02:00
parent e240980d48
commit 8389af6c6e
3 changed files with 9 additions and 9 deletions

View file

@ -25,7 +25,7 @@ Don't judge me
}
})
document.cookie = `theme=${theme}`
window.sessionStorage.setItem('theme', theme)
}
theme.addEventListener('change', function () {
@ -34,8 +34,8 @@ Don't judge me
</script>
<script>
let cookies = document.cookie.split('; ');
let banner_cookie = document.cookie.split('; ').filter(e => e.startsWith('cookie-banner='))[0];
cookies = document.cookie.split('; ');
banner_cookie = document.cookie.split('; ').filter(e => e.startsWith('cookie-banner='))[0];
if (banner_cookie === undefined || banner_cookie.split('cookie-banner=')[1] !== 'hidden') {
cookie_notification = UIkit.notification(
@ -51,9 +51,9 @@ Don't judge me
</script>
<script>
let theme_cookie = document.cookie.split('; ').filter(e => e.startsWith('theme='))[0];
if (theme_cookie !== undefined) {
applyTheme(theme_cookie.split('theme=')[1]);
window.theme.checked = theme_cookie.split('theme=')[1] === 'dark'
theme_session = window.sessionStorage.getItem('theme')
if (theme_session !== null) {
applyTheme(theme_session);
window.theme.checked = theme_session === 'dark'
}
</script>

View file

@ -175,5 +175,5 @@ msgstr "Let's discuss your proposal in more detail! We are open to any partnersh
#: apps/gnous_eu/templates/layouts/foot.html:42
msgid "Bla bla bla... bannière alakon pour dire qu&amp;on utilise des cookies (pour la langue et cette bannière)"
msgstr "GnousEU uses cookies in order to save the language of the site you are using, its theme and the closing of this banner."
msgstr "GnousEU uses cookies in order to save the language of the site you are using and the closing of this banner."

View file

@ -167,4 +167,4 @@ msgstr ""
#: apps/gnous_eu/templates/layouts/foot.html:42
msgid "Bla bla bla... bannière alakon pour dire qu&amp;on utilise des cookies (pour la langue et cette bannière)"
msgstr "GnousEU utilise des cookies afin de sauvegarder la langue du site que vous utilisez, son theme ainsi que pour la fermeture de cette bannière."
msgstr "GnousEU utilise des cookies afin de sauvegarder la langue du site que vous utilisez ainsi que pour la fermeture de cette bannière."