functioncreateEl(e=!1,n="div"){lett=document.createElement(n);return0!=e&&(t.className=e),t}letnavOpened=!1,oldNavText="",oldNavIcon="",navEnabler=document.getElementById("nav-enabler"),navEnablerText=document.getElementById("nav-enabler-text"),navEnablerIcon=document.getElementById("nav-enabler-icon"),navContent=document.getElementById("nav-content"),navAll=document.getElementById("nav-all"),mosaic=document.getElementById("mosaic"),mosaicCount=document.getElementById("mosaic-count"),tags=[],navEnablerExists=!1;functioncloseMenu(){navEnablerText.textContent=oldNavText,navEnablerIcon.style.transform="rotate(0deg)",navContent.style.maxHeight=null}functionshuffle(e){for(varn,t,a=e.length;0!==a;)t=Math.floor(Math.random()*a),n=e[a-=1],e[a]=e[t],e[t]=n;returne}navEnabler.onclick=async()=>{navEnablerExists=!0,navOpened?closeMenu():(oldNavText=navEnablerText.textContent,navEnablerText.textContent="Minimiser le menu",navEnablerIcon.style.transform="rotate(90eg)",navContent.style.maxHeight=navContent.scrollHeight+"px"),navOpened=!navOpened};constrandomBtn=document.getElementById("random-btn"),sortBtn=document.getElementById("sort-btn");letsort=!1;functionrenderNavItem(e){letn=createEl("nav-item"),t=createEl("nav-icon"),a=createEl(e.icon,"i");t.appendChild(a),n.appendChild(t);letr=createEl("nav-item-content"),o=createEl("nav-title");o.textContent=e.name,r.appendChild(o);letl=createEl("nav-access"),i=createEl("fas fa-chevron-right","i");returnl.appendChild(i),r.appendChild(o),r.appendChild(l),n.appendChild(r),n}functionsetAttributes(e,n){for(vartinn)attr=document.createAttribute(t),attr.value=n[t],e.attributes.setNamedItem(attr)}functionrenderCard(e){letn=createEl("card","a"),t=createEl("card-image-container"),a=createEl("card-image");a.style=`background-image: url('${mediaBaseUrl+"/"+e.thumbnail}')`,t.appendChild(a),n.appendChild(t);letr=createEl("card-content"),o=createEl(),l=createEl("card-title-container"),i=createEl("card-title","h2");i.textContent=e.name,l.appendChild(i);letc=createEl("card-icon");if(Array.isArray(e.tags)&&e.tags.length>0){letn=tags.filter(n=>e.tags[0]===n._id)[0];c.innerHTML=n.iconHTML}l.appendChild(c),o.appendChild(l);lets=createEl("card-description");s.textContent=e.description;letd="/association/"+e.slug;returnisProposed&&(d+="?version=proposed"),o.appendChild(s),r.appendChild(o),n.appendChild(r),n.href=d,n}organizations=shuffle(organizations),randomBtn.onclick=()=>{sort&&(organizations=shuffle(organizations),enableTag(currentTag),sort=!1,randomBtn.classList.add("enabled"),sortBtn.classList.remove("enabled"))},sortBtn.onclick=()=>{sort||(organizations=organizations.sort((e,n)=>{vart=e.name.toUpperCase(),a=n.name.toUpperCase();returnt<a?-1:t>a?1:0}),enableTag(currentTag),sort=!0,sortBtn.classList.add("enabled"),randomBtn.classList.remove("enabled"))};letcurrentTag=null,currentCardContainer=null;functionenableTag(e,n=!1){lett="nav-all"===e.id,a="";t||(a=e.attributes["data-tag-id"].value);letr=organizations.filter(e=>e.tags.filter(e=>e===a).length>0||t);renderMosaic(r),e.className+=" enabled",null!==currentTag&&(currentTag.className=currentTag.className.replace("enabled","")),currentTag=e,n||(null==r||r.length<=0?mosaicCount.textContent="Aucune association listée":1===r.length?mosaicCount.textContent="Une association listée":mosaicCount.textContent=r.length+" associations listées",navEnablerExists?(navOpened=!navOpened,closeMenu(),document.getElementsByClassName("content")[0].scrollIntoView(!0)):window.scrollY()>300&&document.getElementsByClassName("content")[0].scrollIntoView(!0))}functionposY(e){for(varn=e,t=0;n&&"body"!==n.tagName.toLowerCase();)t+=n.offsetTop,n=n.offsetParent;returnt}functionviewPortHeight(){vare=document.documentElement;returnwindow.innerWidth?window.innerHeight:e&&!isNaN(e.clientHeight)?e.clientHeight:0}functionscrollY(){returnwindow.pageYOffset?window.pageYOffset:Math.max(document.documentElement.scrollTop,document.body.scrollTop)}functionisVisible(e){varn=viewPortHeight(),t=scrollY();return!(posY(e)>n+t)}letrendering=!0,page=0,elementsP