UNPKG

@here/harp-examples

Version:
1 lines 3.55 kB
(()=>{"use strict";!function(e){const t=document.getElementById("navPanel"),n=document.getElementById("exampleFrame"),s=document.getElementById("viewSource"),o=document.getElementById("exampleList");let l;const c={},i=["Getting started","Datasource","Rendering","Styling","Threejs","Miscellaneous"],a=[],d=[];let r="";var u;!function(){const e=document.getElementById("hamburgerMenu"),n=document.getElementById("closeButton");e.addEventListener("click",(e=>{t.classList.toggle("collapsed"),e.preventDefault()})),n.addEventListener("click",(e=>{t.classList.toggle("collapsed"),e.preventDefault()}))}(),Object.keys(e).sort().forEach((e=>{const t=function(e){return function(e){const t=e.lastIndexOf("/");return-1===t?e:e.substr(t+1)}(e).replace(/\.[a-z]+$/,"").split("_").join(" / ")}(e).replace(new RegExp("-","g")," "),n=t.split(" / ");let s=n.length>1?n[0]:"miscellaneous";s=s.charAt(0).toUpperCase()+s.slice(1),void 0===c[s]&&(c[s]=[]);const o=1===n.length?t:n.slice(1).join(" / "),l=function(e,t){const n=document.createElement("a");return void 0!==t&&Object.assign(n,t),n}(0,{innerText:o,href:"#"+e,className:"link"});l.nameWithCategory=t,l.nameWithoutCategory=o,c[s].push(l),a.push(l)})),Object.keys(c).sort().forEach((e=>{i.includes(e)||i.push(e)})),i.forEach((e=>{const t=document.createElement("div"),n=document.createElement("h2");n.innerHTML=e,d.push(n),t.appendChild(n);const s=c[e];void 0!==s&&(s.forEach((e=>{t.appendChild(e)})),o.appendChild(t))})),(u=document.getElementById("filterInput")).addEventListener("input",(e=>{const t=(u.value||"").trim();t.length>0&&!m&&(d.forEach((e=>{e.style.cssText="display:none;"})),document.getElementById("magnifier-placeholder").style.cssText="display:none;",document.getElementById("clearFilterButton").style.cssText="",a.forEach((e=>{e.innerText=e.nameWithCategory})),m=!0),0===t.length&&m&&h();for(const e of a){const n=e.textContent;null!==n&&(""===t||n.includes(t.toLowerCase())?e.classList.remove("filtered"):e.classList.add("filtered"))}})),document.getElementById("clearFilterButton").addEventListener("click",h);let m=!1;function h(){d.forEach((e=>{e.style.cssText=""})),document.getElementById("magnifier-placeholder").style.cssText="",document.getElementById("clearFilterButton").style.cssText="display:none;",a.forEach((e=>{e.classList.remove("filtered"),e.innerText=e.nameWithoutCategory})),document.getElementById("filterInput").value="",m=!1}function p(){if(window.location.hash){let c;r="";const i=window.location.hash.match(/([^\?]*)\?(.*)/);null!==i&&i.length>2?(c=i[1].substring(1),r="?"+i[2]):c=window.location.hash.substring(1),window.location.search&&(r=r?window.location.search+"&"+r.substr(1):window.location.search),function(c){if(document.getElementById("hamburgerMenu").classList.toggle("expanded",!t.classList.contains("collapsed")),!(c in e))return s.style.display="none",o.style.bottom="365px",void(n.contentWindow.document.body.innerHTML='<p style="color:#888;font-size:20px;font-family:sans-serif;text-align:center;top: 50%; margin-top: -100px; position: absolute; width: 100% "><strong style="font-size:80px; ">404</strong><br/>Example not found</p>');window.location.hash="#"+c,r&&(window.location.search=r),n.src=c+r,a.forEach((e=>{e.hash.substr(1)===c?e.classList.add("selected"):e.classList.remove("selected")})),l=e[c],s.style.display="block",o.style.bottom="65px",t.classList.toggle("collapsed")}(c)}}s.addEventListener("click",(()=>{l&&window.open("codebrowser.html?src="+encodeURIComponent(l))})),window.addEventListener("hashchange",p),p()}(examples)})();