perf(storage): move theme choice to localstorage
This commit is contained in:
parent
e240980d48
commit
8389af6c6e
3 changed files with 9 additions and 9 deletions
|
@ -25,7 +25,7 @@ Don't judge me
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
document.cookie = `theme=${theme}`
|
window.sessionStorage.setItem('theme', theme)
|
||||||
}
|
}
|
||||||
|
|
||||||
theme.addEventListener('change', function () {
|
theme.addEventListener('change', function () {
|
||||||
|
@ -34,8 +34,8 @@ Don't judge me
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
let cookies = document.cookie.split('; ');
|
cookies = document.cookie.split('; ');
|
||||||
let banner_cookie = document.cookie.split('; ').filter(e => e.startsWith('cookie-banner='))[0];
|
banner_cookie = document.cookie.split('; ').filter(e => e.startsWith('cookie-banner='))[0];
|
||||||
|
|
||||||
if (banner_cookie === undefined || banner_cookie.split('cookie-banner=')[1] !== 'hidden') {
|
if (banner_cookie === undefined || banner_cookie.split('cookie-banner=')[1] !== 'hidden') {
|
||||||
cookie_notification = UIkit.notification(
|
cookie_notification = UIkit.notification(
|
||||||
|
@ -51,9 +51,9 @@ Don't judge me
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
let theme_cookie = document.cookie.split('; ').filter(e => e.startsWith('theme='))[0];
|
theme_session = window.sessionStorage.getItem('theme')
|
||||||
if (theme_cookie !== undefined) {
|
if (theme_session !== null) {
|
||||||
applyTheme(theme_cookie.split('theme=')[1]);
|
applyTheme(theme_session);
|
||||||
window.theme.checked = theme_cookie.split('theme=')[1] === 'dark'
|
window.theme.checked = theme_session === 'dark'
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
|
@ -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
|
#: apps/gnous_eu/templates/layouts/foot.html:42
|
||||||
msgid "Bla bla bla... bannière alakon pour dire qu&on utilise des cookies (pour la langue et cette bannière)"
|
msgid "Bla bla bla... bannière alakon pour dire qu&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."
|
||||||
|
|
||||||
|
|
|
@ -167,4 +167,4 @@ msgstr ""
|
||||||
|
|
||||||
#: apps/gnous_eu/templates/layouts/foot.html:42
|
#: apps/gnous_eu/templates/layouts/foot.html:42
|
||||||
msgid "Bla bla bla... bannière alakon pour dire qu&on utilise des cookies (pour la langue et cette bannière)"
|
msgid "Bla bla bla... bannière alakon pour dire qu&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."
|
||||||
|
|
Loading…
Reference in a new issue