2022-02-15 11:03:20 +01:00
<!doctype html>
2022-02-23 18:51:23 +01:00
<html lang="fr" data-theme="light">
2022-02-15 16:45:14 +01:00
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
2022-02-23 19:26:52 +01:00
2022-02-17 09:37:25 +01:00
<title><% if (page.title) { %><%= page.title %> <% } else { %> DarKou - My Music Library <% } %></title>
2022-02-16 15:42:02 +01:00
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff">
2022-02-23 19:26:52 +01:00
2022-02-15 16:45:14 +01:00
<link href="/css/main.css" rel="stylesheet" />
2022-02-23 19:26:52 +01:00
2022-02-15 16:45:14 +01:00
<script src="/libs/axios/axios.min.js"></script>
<script src="/libs/vue/vue.global.prod.js"></script>
2022-02-23 19:26:52 +01:00
2022-02-15 16:45:14 +01:00
<script>
2022-02-23 14:13:19 +01:00
/**
* Fonction permettant d'afficher un message dans un toastr
* @param {String} message
*/
2022-02-15 16:45:14 +01:00
function showToastr(message) {
2022-02-18 11:38:56 +01:00
let x = document.getElementById("toastr");
2022-02-15 16:45:14 +01:00
if ( message ) {
x.getElementsByTagName("SPAN")[0].innerHTML = message;
}
2022-02-23 19:26:52 +01:00
2022-02-15 16:45:14 +01:00
x.className = `${x.className} show`;
setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
};
2022-02-18 11:38:56 +01:00
2022-02-23 14:13:19 +01:00
/**
* Fonction permettant de masquer le toastr
*/
2022-02-18 11:38:56 +01:00
function hideToastr() {
let x = document.getElementById("toastr");
2022-02-23 19:26:52 +01:00
2022-02-18 11:38:56 +01:00
x.className = x.className.replace("show", "");
2022-02-23 14:13:19 +01:00
x.getElementsByTagName("SPAN")[0].innerHTML = "";
}
/**
* Fonction permettant de récupérer la valeur d'un cookie
* @param {String} cname
* @param {String} defaultValue
2022-02-23 19:26:52 +01:00
*
2022-02-23 14:13:19 +01:00
* @return {String}
*/
function getCookie(cname, defaultValue = 'false') {
let name = cname + "=";
let decodedCookie = decodeURIComponent(document.cookie);
let ca = decodedCookie.split(';');
for(let i = 0; i < ca.length; i+=1) {
let c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return defaultValue;
}
/**
* Fonction permettant de créer un cookie
* @param {String} cname
* @param {String} cvalue
* @param {Number} exdays
*/
function setCookie(cname, cvalue, exdays = 30) {
const d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
let expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
/**
* Fonction de (dé)charger le thème accessible
* @param {String} value
*/
function setAriaTheme(value) {
let body = document.body;
if ( value === 'true' ) {
let classesString = body.className || "";
if (classesString.indexOf("is-accessible") === -1) {
body.classList.add("is-accessible");
}
} else {
body.classList.remove("is-accessible");
}
}
/**
* Fonction de (dé)charger le thème accessible
*/
function switchAriaTheme() {
let body = document.body;
2022-02-23 19:26:52 +01:00
2022-02-23 14:13:19 +01:00
body.classList.toggle("is-accessible");
setCookie('ariatheme', body.classList.contains("is-accessible"));
2022-02-18 11:38:56 +01:00
}
2022-02-23 19:26:52 +01:00
2022-02-23 18:51:23 +01:00
/**
* Fonction permettant de switcher de thème clair/sombre
* @param {Object} e
*/
function switchTheme(e) {
const theme = e.target.checked ? 'dark' : 'light';
document.documentElement.setAttribute('data-theme', theme);
setCookie('theme', theme);
}
2022-02-23 14:13:19 +01:00
/**
* Ensemble d'actions effectuées au chargement de la page
*/
2022-02-15 16:45:14 +01:00
document.addEventListener('DOMContentLoaded', () => {
const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
if ($navbarBurgers.length > 0) {
$navbarBurgers.forEach( el => {
el.addEventListener('click', () => {
const target = el.dataset.target;
const $target = document.getElementById(target);
2022-02-23 19:26:52 +01:00
2022-02-15 16:45:14 +01:00
el.classList.toggle('is-active');
$target.classList.toggle('is-active');
});
});
}
2022-02-23 14:13:19 +01:00
const switchAriaThemeBtn = document.querySelector("#switchAriaTheme");
switchAriaThemeBtn.addEventListener("click", switchAriaTheme);
setAriaTheme(getCookie('ariatheme'));
2022-02-23 18:51:23 +01:00
const toggleSwitch = document.querySelector('.theme-switch input[type="checkbox"]');
toggleSwitch.addEventListener('change', switchTheme, false);
let currentThemeIsDark = getCookie('theme');
if ( currentThemeIsDark === 'false' && window.matchMedia ) {
currentThemeIsDark = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
}
console.log('currentThemeIsDark:', currentThemeIsDark);
switchTheme({target: {checked: currentThemeIsDark === 'dark'}});
toggleSwitch.checked = currentThemeIsDark === 'dark';
2022-02-15 16:45:14 +01:00
});
2022-02-23 18:51:23 +01:00
console.log('window.matchMedia:', window.matchMedia('(prefers-color-scheme: dark)').matches);
2022-02-15 16:45:14 +01:00
</script>
</head>
2022-02-18 08:14:34 +01:00
<body>
2022-02-23 13:19:55 +01:00
<nav class="navbar" aria-label="Navigation principale">
2022-02-15 16:45:14 +01:00
<div class="navbar-brand">
<a class="navbar-item" href="/">
2022-02-23 10:39:17 +01:00
<img src="/img/logo.png" alt="Logo My Music Library">
2022-02-18 08:14:34 +01:00
<span>My Music Library</span>
2022-02-15 16:45:14 +01:00
</a>
2022-02-23 19:26:52 +01:00
2022-02-23 13:19:55 +01:00
<a role="button" class="navbar-burger" aria-label="Afficher le menu" aria-expanded="false" data-target="navbar">
2022-02-15 16:45:14 +01:00
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
</div>
2022-02-23 19:26:52 +01:00
2022-02-18 08:14:34 +01:00
<div id="navbar" class="navbar-menu">
2022-02-15 16:45:14 +01:00
<% if ( user ) { %>
<div class="navbar-start">
2022-02-16 15:42:02 +01:00
<div class="navbar-item">
2022-02-18 08:14:34 +01:00
<div class="buttons">
2022-02-23 19:26:52 +01:00
<a class="button is-primary" href="/ajouter-un-album">
2022-02-23 08:41:30 +01:00
<i class="icon-plus"></i>
2022-02-16 15:42:02 +01:00
<span>
Ajouter un album
</span>
</a>
2022-02-18 08:14:34 +01:00
</div>
2022-02-16 15:42:02 +01:00
</div>
</div>
<% } %>
2022-02-23 19:26:52 +01:00
2022-02-16 15:42:02 +01:00
<div class="navbar-end">
2022-02-22 14:50:07 +01:00
<a class="navbar-item" href="/nous-contacter">
Nous contacter
</a>
2022-02-16 15:42:02 +01:00
<% if ( user ) { %>
2022-02-18 08:14:34 +01:00
<div class="navbar-item has-dropdown">
2022-02-15 16:45:14 +01:00
<a class="navbar-link">
2022-02-23 08:41:30 +01:00
<i class="icon-user"></i>
2022-02-17 09:37:25 +01:00
<span>
<%= user.username %>
</span>
2022-02-15 16:45:14 +01:00
</a>
2022-02-23 19:26:52 +01:00
2022-02-15 16:45:14 +01:00
<div class="navbar-dropdown">
<a class="navbar-item" href="/ma-collection">
Ma collection
</a>
</div>
</div>
2022-02-16 15:42:02 +01:00
<% } %>
2022-02-23 18:51:23 +01:00
<div class="navbar-item apparence">
<div class="theme-switch-wrapper">
<label class="theme-switch" for="checkbox">
<input type="checkbox" id="checkbox" />
<div class="slider round"></div>
</label>
</div>
</div>
2022-02-15 16:45:14 +01:00
<div class="navbar-item">
<div class="buttons">
2022-02-23 19:26:52 +01:00
<button type="button" class="button is-primary" id="switchAriaTheme" aria-label="Renforcer la visibilité de ce site" title="Renforcer la visibilité de ce site">
2022-02-23 14:13:19 +01:00
<i class="icon-eye"></i>
</button>
2022-02-15 16:45:14 +01:00
<% if ( !user ) { %>
2022-02-23 19:26:52 +01:00
<a class="button is-primary" href="/connexion">
2022-02-15 16:45:14 +01:00
<strong>Connexion</strong>
</a>
<% } else { %>
<a class="button is-danger" href="/se-deconnecter">
Déconnexion
</a>
<% } %>
</div>
</div>
</div>
</div>
</nav>
2022-02-18 11:38:56 +01:00
<div id="toastr">
<button class="delete" onclick="hideToastr()"></button>
2022-02-15 16:45:14 +01:00
<span></span>
2022-02-18 11:38:56 +01:00
</div>
2022-02-15 11:03:20 +01:00
2022-02-18 11:38:56 +01:00
<% if ( page.failureFlash || (error && error.length > 0 ) ) {%>
<div class="flash">
<% if ( page.failureFlash ) {%>
<div class="header">
Erreur
2022-02-15 16:45:14 +01:00
</div>
2022-02-18 11:38:56 +01:00
<div class="body">
<%= page.failureFlash %>
</div>
2022-02-23 19:26:52 +01:00
<% } %>
2022-02-18 11:38:56 +01:00
<%
if (error && error.length > 0) {
for( let i = 0 ; i < error.length ; i += 1 ) {
%>
<div class="header">
Erreur
</div>
<div class="body">
<%= error %>
2022-02-15 11:03:20 +01:00
</div>
2022-02-18 11:38:56 +01:00
<%
}
2022-02-23 19:26:52 +01:00
}
2022-02-18 11:38:56 +01:00
%>
</div>
<% } %>
2022-02-23 19:26:52 +01:00
2022-02-18 09:15:48 +01:00
<%- include(viewname) %>
2022-02-18 11:38:56 +01:00
2022-02-18 08:14:34 +01:00
<footer class="footer layout-hero">
<p>
2022-02-23 08:41:30 +01:00
<strong title="Merci Brunus ! 😜">My Music Library</strong> par <a href="https://www.darkou.fr" target="_blank" rel="noopener noreferrer">Damien Broqua <i class="icon-link"></i></a>.
2022-02-23 14:13:19 +01:00
Fait avec ❤️ à Bordeaux.
2022-02-23 08:41:30 +01:00
Le code source est sous licence <a href="https://www.gnu.org/licenses/gpl-3.0-standalone.html" target="_blank" rel="noopener noreferrer">GNU GPL-3.0-or-later <i class="icon-link"></i></a>.
2022-02-18 08:14:34 +01:00
</p>
2022-02-16 15:42:02 +01:00
</footer>
2022-02-15 11:03:20 +01:00
</body>
</html>