-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.min.js
1 lines (1 loc) · 6.1 KB
/
script.min.js
1
const toggleSwitch=document.querySelector(".js_switch"),labelClair=document.querySelectorAll(".js_switch-clair"),labelSombre=document.querySelectorAll(".js_switch-sombre"),currentMode=localStorage.getItem("mode");if(currentMode)if(document.documentElement.setAttribute("data-mode",currentMode),"light"===currentMode){toggleSwitch.checked=!0;for(let e=0;e<labelClair.length;e++)labelClair[e].classList.add("hide");for(let e=0;e<labelSombre.length;e++)labelSombre[e].classList.remove("hide")}else{for(let e=0;e<labelClair.length;e++)labelClair[e].classList.remove("hide");for(let e=0;e<labelSombre.length;e++)labelSombre[e].classList.add("hide")}else{document.documentElement.setAttribute("data-mode","dark"),localStorage.setItem("mode","dark");for(let e=0;e<labelClair.length;e++)labelClair[e].classList.add("hide")}function switchMode(e){if(e.target.checked){document.documentElement.setAttribute("data-mode","light"),localStorage.setItem("mode","light");for(let e=0;e<labelClair.length;e++)labelClair[e].classList.add("hide");for(let e=0;e<labelSombre.length;e++)labelSombre[e].classList.remove("hide")}else{document.documentElement.setAttribute("data-mode","dark"),localStorage.setItem("mode","dark");for(let e=0;e<labelClair.length;e++)labelClair[e].classList.remove("hide");for(let e=0;e<labelSombre.length;e++)labelSombre[e].classList.add("hide")}}toggleSwitch.addEventListener("change",switchMode,!1);const url="https://docs.google.com/spreadsheets/d/",ssid="1wBen3ShPLi-YsjLcY0wHEhOvtq8GqTvcwiSnkNWbz54",query1="/gviz/tq?",endpoint1=""+url+ssid+query1;function controle(e,t){var l,r=e.statut;for(let e=0;e<r.length;e++)r[e].checked&&(l=r[e].value);var n,c=e.type;for(let e=0;e<c.length;e++)c[e].checked&&(n=c[e].value);var o,u=e.stock;for(let e=0;e<u.length;e++)u[e].checked&&(o=u[e].value);window.filtreLecture=[];for(const s of window.allLectures)window.filtreLecture.push(s);if("all"!=l){for(let e=0;e<filtreLecture.length;e++)filtreLecture[e].statut!=l&&delete filtreLecture[e];filtreLecture=filtreLecture.filter(function(e){return e})}if("all"!=n){for(let e=0;e<filtreLecture.length;e++)filtreLecture[e].type!=n&&delete filtreLecture[e];filtreLecture=filtreLecture.filter(function(e){return e})}if("all"!=o){for(let e=0;e<filtreLecture.length;e++)filtreLecture[e].stock!=o&&delete filtreLecture[e];filtreLecture=filtreLecture.filter(function(e){return e})}if(ordreParNote=[],t){for(var a=0,i=0;i<filtreLecture.length;i++)filtreLecture[i].note>a&&(a=filtreLecture[i].note);for(let t=a;0<=t;t--)for(let e=0;e<filtreLecture.length;e++)filtreLecture[e].note==t&&ordreParNote.push(filtreLecture[e]);filtreLecture=ordreParNote}update(filtreLecture),filtre.classList.add("hide"),contenu.classList.remove("hide")}function update(e){e={lectures:e},e=Handlebars.compile(document.querySelector("#handlebars-template").innerHTML)(e);document.querySelector("#handlebars-output").innerHTML=e}fetch(endpoint1).then(e=>e.text()).then(e=>{e=e.substr(47).slice(0,-2);const t=JSON.parse(e).table.rows;e=t.map(function(e){return{article:null===e.c[0]?"":e.c[0].v,titre:null===e.c[1]?"":e.c[1].v,volume:null===e.c[2]?"":e.c[2].v,note:null===e.c[3]?"":e.c[3].v,notePourcentage:null===e.c[3]?"":10*e.c[3].v,noteSur5:null===e.c[3]?"":e.c[3].v/2,info:null===e.c[4]?"":e.c[4].v,statut:null===e.c[5]?"":e.c[5].v,stock:null===e.c[6]?"":e.c[6].v,type:null===e.c[7]?"":e.c[7].v}});window.allLectures=[];for(const l of e)window.allLectures.push(l);Handlebars.registerHelper("ifEquals",function(e,t,l){return e==t?l.fn(this):l.inverse(this)}),Handlebars.registerHelper("ifSuperieur",function(e,t,l){return t<e?l.fn(this):l.inverse(this)}),update(e),document.getElementById("encours").checked=!0,document.getElementById("possede").checked=!0,document.getElementById("btnPreference").click()});const filtre=document.querySelector(".js_filtre"),filtreBtn=document.querySelector(".js_filtre-btnDisplay"),filtreAchat=document.querySelector(".js_fitre-achat"),filtreChanger=document.querySelector(".js_filtre-changer");function changerFiltre(){filtre.classList.remove("hide"),contenu.classList.add("hide")}filtreBtn.addEventListener("click",function(){filtre.classList.contains("hide")&&(filtre.classList.remove("hide"),contenu.classList.add("hide"),masqueMenu())}),filtreAchat.addEventListener("click",function(){document.getElementById("encours").checked=!0,document.getElementById("possede").checked=!0,document.getElementById("btnPreference").click(),masqueMenu()});const btnLargeurMenu=document.querySelector(".js_largeurMenu-btn"),currentLargeur=localStorage.getItem("largeurMenu");currentLargeur?document.documentElement.dataset.menuLargeur=currentLargeur:(document.documentElement.dataset.menuLargeur="small",localStorage.setItem("largeurMenu","small")),btnLargeurMenu.addEventListener("click",function(){"small"==document.documentElement.dataset.menuLargeur?(document.documentElement.dataset.menuLargeur="large",localStorage.setItem("largeurMenu","large")):(document.documentElement.dataset.menuLargeur="small",localStorage.setItem("largeurMenu","small"))});const menuBtnAffiche=document.querySelectorAll(".js_menu-btnAffiche"),menuBtnFermer=document.querySelector(".js_menu-btnFermer"),contenu=document.querySelector(".js_contenu"),menu=document.querySelector(".js_menu"),menuBtn=document.querySelectorAll(".js_menu-btn"),app=document.querySelector(".js_app");function masqueMenu(){"oui"==document.documentElement.dataset.menuAffiche&&(menu.classList.remove(":visible"),document.documentElement.dataset.menuAffiche="")}function afficheMenu(){document.documentElement.dataset.menuAffiche="oui";var e=this.offsetWidth,t=window.event.offsetX;document.documentElement.dataset.positionX=t<=e/2?"gauche":"droite",document.documentElement.dataset.positionY=this.dataset.positionY,menu.classList.add(":visible"),filtre.classList.contains("hide")||(filtre.classList.add("hide"),contenu.classList.remove("hide"))}for(let e=0;e<menuBtnAffiche.length;e++)menuBtnAffiche[e].addEventListener("click",afficheMenu,!1);contenu.addEventListener("click",masqueMenu,!1),menuBtnFermer.addEventListener("click",masqueMenu,!1);var animation=bodymovin.loadAnimation({container:document.querySelector(".js--loader"),path:"json/synchronize-cloud.json",renderer:"svg",loop:!0,autoplay:!0});