2020-05-16 12:49:06 +02:00
{% load static %}
{% load i18n %}
<!-- /
Je suis spécialisé en python, pas en js...
Don't judge me
/-->
2020-05-17 00:37:22 +02:00
< script src = "{% static 'javascripts/uikit/uikit.min.js' %}" > < / script >
< script src = "{% static 'javascripts/uikit/uikit-icons.min.js' %}" > < / script >
2020-05-16 12:49:06 +02:00
< script >
window.theme = document.querySelector('input[name=theme]');
theme.checked = document.documentElement.getAttribute('data-theme') === 'dark';
2020-05-16 13:43:12 +02:00
window.applyTheme = function(theme) {
document.documentElement.setAttribute('data-theme', theme);
2020-05-16 12:49:06 +02:00
let cards = document.querySelectorAll(".uk-card.uk-card-default,.uk-card.uk-card-secondary");
cards.forEach(card => {
2020-05-16 13:43:12 +02:00
if (theme === 'dark') {
card.classList.replace("uk-card-default", `uk-card-secondary`)
2020-05-16 12:49:06 +02:00
} else {
2020-05-16 13:43:12 +02:00
card.classList.replace("uk-card-secondary", `uk-card-default`)
2020-05-16 12:49:06 +02:00
}
})
2020-05-16 13:43:12 +02:00
2020-05-16 14:12:46 +02:00
window.sessionStorage.setItem('theme', theme)
2020-05-16 13:43:12 +02:00
}
theme.addEventListener('change', function () {
applyTheme(theme.checked ? 'dark' : 'light')
2020-05-16 12:49:06 +02:00
})
< / script >
< script >
2020-05-16 14:12:46 +02:00
cookies = document.cookie.split('; ');
banner_cookie = document.cookie.split('; ').filter(e => e.startsWith('cookie-banner='))[0];
2020-05-16 12:49:06 +02:00
2020-05-16 13:43:12 +02:00
if (banner_cookie === undefined || banner_cookie.split('cookie-banner=')[1] !== 'hidden') {
2020-05-16 12:49:06 +02:00
cookie_notification = UIkit.notification(
'< span data-uk-icon = "quote-right" > < / span > {% trans "Bla bla bla... bannière alakon pour dire qu& on utilise des cookies (pour la langue et cette bannière)" %}',
{pos: 'bottom-center'}
);
UIkit.util.on(document, 'close', function (evt) {
if (evt.detail[0] === cookie_notification) {
document.cookie = 'cookie-banner=hidden'
}
});
}
< / script >
< script >
2020-05-16 14:12:46 +02:00
theme_session = window.sessionStorage.getItem('theme')
if (theme_session !== null) {
applyTheme(theme_session);
window.theme.checked = theme_session === 'dark'
2020-05-16 13:43:12 +02:00
}
2020-05-16 12:49:06 +02:00
< / script >