server/assets/production/scripts/organization.js

1 line
No EOL
2.9 KiB
JavaScript

document.querySelectorAll(".schedule-category").forEach(e=>{let t=!1,o=e.querySelector(".schedule-category-collapse-icon"),i=e.querySelector(".schedule-category-table");e.querySelector(".schedule-category-header").onclick=()=>{t?(o.style.transform="rotate(180deg)",i.style.maxHeight=null):(o.style.transform="rotate(0deg)",i.style.maxHeight=i.scrollHeight+"px"),t=!t}});let description=document.querySelector(".description-cutted"),descriptionActions=document.querySelector(".description-actions-container"),descriptionOpened=!1,defaultMaxHeight="";if(null!==description){let e=document.querySelector(".description-btn");e.onclick=()=>{descriptionOpened?(descriptionActions.className+=" closed",description.style.maxHeight=defaultMaxHeight,e.textContent="Ouvrir la description"):(descriptionActions.className=descriptionActions.className.replace(" closed",""),defaultMaxHeight=description.style.maxHeight,description.style.maxHeight=description.scrollHeight+"px",e.textContent="Fermer la description"),descriptionOpened=!descriptionOpened}}let mediaModal=document.querySelector("#media-modal"),mediaModalContent=document.querySelector("#media-modal-content"),openModal=(e,t)=>{mediaModal.style.visibility="visible",mediaModal.style.opacity=1,mediaModalContent.innerHTML="";let o=document.createAttribute("src");o.value=e;let i=null;if(t){i=document.createElement("video"),i.setAttribute("controls",""),i.setAttribute("autoplay",""),i.setAttribute("name","media");let t=document.createElement("source");t.setAttribute("src",e),t.setAttribute("type","video/mp4"),i.appendChild(t)}else i=document.createElement("img"),i.attributes.setNamedItem(o);mediaModalContent.appendChild(i),document.body.style.overflow="hidden",document.body.style.touchAction="none",setTimeout(()=>{const e=t=>{!mediaModalContent.contains(t.target)&&isVisible(mediaModalContent)&&(closeModal(),document.removeEventListener("click",e))};document.addEventListener("click",e)},100)};const isVisible=e=>!!e&&!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length);let closeModal=()=>{mediaModal.style.visibility="hidden",mediaModal.style.opacity=0,document.body.style.overflow="initial",document.body.style.height="initial",document.body.style.touchAction="initial";let e=document.querySelector("#media-modal video");null!==e&&e.pause()},formatPhone=e=>{0===e.indexOf("+33")&&(e="0"+e.substr(3));let t="",o=!1;for(var i=0;i<e.length;i++)t+=e.charAt(i),!0===o&&(t+=" "),o=!o;return["+33"+e.substr(1),t]};document.querySelectorAll(".offuscated").forEach(e=>{let t=e.getAttribute("data-source"),o=e.getAttribute("data-source-type");t=t.replace(/'/gm,'"').replace(/%_/gm,""),t=t.replace(/\$/gm,"A"),t=t.replace(/£/gm,"c"),t=t.replace(/ù/gm,"b"),t=t.replace(/#/gm,"d"),t=t.replace(/µ/gm,"e"),t=t.replace(/§/gm,"z"),t=t.replace(/à/gm,"i"),t=t.replace(/\|/gm,"f"),t=JSON.parse(t).join(""),t=atob(t),"phone"===o?(t=formatPhone(t),e.href=e.href.replace("data",t[0]),t=t[1]):e.href=e.href.replace("data",t),e.textContent=t});