75 lines
No EOL
2.3 KiB
HTML
75 lines
No EOL
2.3 KiB
HTML
{% load static %}
|
|
{% load i18n %}
|
|
|
|
|
|
<!--/
|
|
Je suis spécialisé en python, pas en js...
|
|
Don't judge me
|
|
/-->
|
|
|
|
{#<script src="{% static 'javascripts/uikit/uikit.min.js' %}"></script>#}
|
|
{#<script src="{% static 'javascripts/uikit/uikit-icons.min.js' %}"></script>#}
|
|
|
|
<!-- theme -->
|
|
<script>
|
|
window.theme = document.querySelector('input[name=theme]');
|
|
theme.checked = document.documentElement.getAttribute('data-theme') === 'dark';
|
|
|
|
window.applyTheme = function(theme) {
|
|
document.documentElement.setAttribute('data-theme', theme);
|
|
|
|
let cards = document.querySelectorAll(".uk-card.uk-card-default,.uk-card.uk-card-secondary");
|
|
cards.forEach(card => {
|
|
if (theme === 'dark') {
|
|
card.classList.replace("uk-card-default", `uk-card-secondary`)
|
|
} else {
|
|
card.classList.replace("uk-card-secondary", `uk-card-default`)
|
|
}
|
|
})
|
|
|
|
window.sessionStorage.setItem('theme', theme)
|
|
}
|
|
|
|
theme.addEventListener('change', function () {
|
|
applyTheme(theme.checked ? 'dark' : 'light')
|
|
})
|
|
</script>
|
|
|
|
<!-- cookie banner -->
|
|
<script>
|
|
cookies = document.cookie.split('; ');
|
|
banner_cookie = document.cookie.split('; ').filter(e => e.startsWith('cookie-banner='))[0];
|
|
banner_cookie_div = document.getElementById("banner_cookie_div");
|
|
|
|
if (banner_cookie === undefined || banner_cookie.split('cookie-banner=')[1] !== 'hidden') {
|
|
banner_cookie_div.addEventListener('click', event => {
|
|
document.cookie = 'cookie-banner=hidden';
|
|
banner_cookie_div.style.display = "none"
|
|
});
|
|
} else {
|
|
banner_cookie_div.style.display = "none"
|
|
}
|
|
</script>
|
|
|
|
<!-- sidebar -->
|
|
<script>
|
|
offcanvas_nav = document.getElementById("offcanvas-nav");
|
|
trigger = document.querySelector("a.uk-navbar-toggle")
|
|
|
|
trigger.addEventListener("click", e => {
|
|
offcanvas_nav.classList.add("uk-offcanvas", "uk-offcanvas-overlay", "uk-open")
|
|
})
|
|
|
|
offcanvas_nav.querySelector("button.uk-close").addEventListener("click", e => {
|
|
offcanvas_nav.classList.remove("uk-offcanvas-overlay", "uk-open")
|
|
})
|
|
</script>
|
|
|
|
<!-- save theme -->
|
|
<script>
|
|
theme_session = window.sessionStorage.getItem('theme')
|
|
if (theme_session !== null) {
|
|
applyTheme(theme_session);
|
|
window.theme.checked = theme_session === 'dark'
|
|
}
|
|
</script> |