PageSourceSearch

https://nat.museum-digital.de/js/_md_page_collections-overview.min.js?v00064

js museum-digital.de collected 2026-09-24 09:02:27 UTC 6,559 bytes, 20 lines download raw bytes

1(async function(){"use strict";const PER_PAGE=100;const tls=JSON.parse(document.body.getAttribute("data-tl"));let searchResultNo;let pageData;let page=1;const resultsCounter=document.getElementById("searchResultNo");const searchbar=document.getElementById("collectionSearchBar");const domSection=document.getElementById("collectionSection");let searchTerm=searchbar.value;const pageUrl=new URL(window.location.toLocaleString());const pageParams=pageUrl.searchParams;function setSearchterm(){page=1;searchTerm=searchbar.value.toLowerCase();reloadFully();pageParams.set('q',searchTerm);pageParams.set('page',1);window.history.pushState('',document.title,pageUrl)}
2searchbar.addEventListener('change',function(){setSearchterm()});searchbar.form.addEventListener('submit',function(e){e.preventDefault();e.stopPropagation();setSearchterm()});const pageFromUrl=pageParams.get('page');if(pageFromUrl!==undefined&&pageFromUrl!==null){page=parseInt(pageFromUrl)}
3function generateListTab(){function buildCollectionTab(list,collectionData){let colSuperordinates={};let nodes={};let nodeChildren={};function generateCollectionNode(col){const parent=document.createElement("li");const tile=document.createElement("div");tile.classList.add("threeColHorizTile");const imgA=document.createElement("a");imgA.classList.add("tileImg");imgA.setAttribute("tabindex","-1");imgA.href="/collection/"+encodeURIComponent(col.id);if(col.image_path!==''){const img=document.createElement("img");img.setAttribute("loading","lazy");img.src='/'+col.image_path;img.alt="";imgA.appendChild(img)}else imgA.setAttribute("aria-hidden","true");tile.appendChild(imgA);const titleA=document.createElement("a");titleA.classList.add("tileTitle");titleA.href="/collection/"+encodeURIComponent(col.id);titleA.textContent=col.name;tile.appendChild(titleA);if(col.object_count!==0){const objects=document.createElement("a");objects.classList.add("tileSummary");objects.href="/objects?s=collection:"+encodeURIComponent(col.id);objects.textContent=col.object_count+' '+tls.objects;tile.appendChild(objects)}else{const objects=document.createElement("span");objects.classList.add("tileSummary");objects.textContent='0 '+tls.objects;tile.appendChild(objects)}
4parent.appendChild(tile);const childrenWrapper=document.createElement("ul")
5parent.appendChild(childrenWrapper);colSuperordinates[col.id]=col.superordinate;nodes[col.id]=parent;nodeChildren[col.id]=childrenWrapper}
6for(let col of collectionData){generateCollectionNode(col)}
7for(let col of collectionData){let id=col.id;if(col.superordinate===0){list.appendChild(nodes[id])}
7else{try{nodeChildren[col.superordinate].appendChild(nodes[id])}catch(error){nodes[id].classList.add("markedLBorder");list.appendChild(nodes[id])}}}}
8const wrapper=document.createElement("div");wrapper.classList.add("twoColSimilarSize");for(let inst of pageData){const instArea=document.createElement("div");instArea.classList.add("tileWHeaderImg");const hl=document.createElement("a");hl.classList.add("headerImg");hl.href="/institution/"+encodeURIComponent(inst.institution_id);if(inst.image!==''){hl.style.backgroundImage='url(/'+inst.image+')'}
9const h2=document.createElement("h2");h2.textContent=inst.name;hl.appendChild(h2);instArea.appendChild(hl);const list=document.createElement("ul");list.classList.add("hierarchyList");buildCollectionTab(list,inst.collections);instArea.appendChild(list);wrapper.appendChild(instArea)}
10domSection.appendChild(wrapper)}
11async function generatePagination(pagination){function genPaginationLink(targetPos,rel=""){let url=new URL(window.location.toLocaleString());url.searchParams.set('page',targetPos);const link=document.createElement("a");link.classList.add("pag");link.textContent=targetPos;link.href=url;if(rel!=='')link.setAttribute('rel',rel);link.addEventListener('click',function(e){e.preventDefault();page=targetPos;pageParams.set('page',targetPos);window.history.pushState('',document.title,pageUrl);reloadPageOnly()});return link}
12function genPaginationPeriod(){const output=document.createElement("span");output.textContent="...";return output}
13const lastPage=Math.ceil(searchResultNo/PER_PAGE);console.log(lastPage);if(page-5>0){pagination.appendChild(genPaginationLink(1));pagination.appendChild(genPaginationPeriod())}else if(page-4>0){pagination.appendChild(genPaginationLink(1))}
14if(page-3>0)pagination.appendChild(genPaginationLink(page-3));if(page-2>0)pagination.appendChild(genPaginationLink(page-2));if(page-1>0)pagination.appendChild(genPaginationLink(page-1,"prev"));const cur=document.createElement("span");cur.classList.add("selected");cur.textContent=page;pagination.appendChild(cur);if(page+1<=lastPage)pagination.appendChild(genPaginationLink(page+1,"next"));if(page+2<=lastPage)pagination.appendChild(genPaginationLink(page+2));if(page+3<=lastPage)pagination.appendChild(genPaginationLink(page+3));if(page+5<=lastPage){pagination.appendChild(genPaginationPeriod());pagination.appendChild(genPaginationLink(lastPage))}else if(page+4<=lastPage){pagination.appendChild(genPaginationLink(lastPage))}}
15function reloadSubPage(){domSection.classList.remove("loading");while(domSection.firstChild){domSection.removeChild(domSection.firstChild)}
16if(searchResultNo>PER_PAGE){const pagination=document.createElement("div");pagination.classList.add("pagination");generatePagination(pagination);domSection.appendChild(pagination)}
17generateListTab()}
18function reloadPageOnly(){domSection.classList.add("loading");window.fetch('/api.php?subject=collections_by_institutions&object=&q='+encodeURIComponent(searchTerm)+'&limit=100&offset='+encodeURIComponent((page-1)*100),{method:'GET',cache:'no-cache',credentials:'same-origin',}).then(function(response){return response.json()}).then(function(elements){pageData=elements.results;reloadSubPage()})}
19function reloadFully(){domSection.classList.add("loading");let loaded=0;window.fetch('/json/collections_by_institutions_total?q='+encodeURIComponent(searchTerm),{method:'GET',cache:'no-cache',credentials:'same-origin',}).then(function(response){return response.json()}).then(function(elements){searchResultNo=elements.results;resultsCounter.textContent=elements.results;loaded++;if(loaded===2)reloadSubPage();});window.fetch('/json/collections_by_institutions?q='+encodeURIComponent(searchTerm)+'&limit=100&offset='+encodeURIComponent((page-1)*100),{method:'GET',cache:'no-cache',credentials:'same-origin',}).then(function(response){return response.json()}).then(function(elements){pageData=elements.results;loaded++;if(loaded===2)reloadSubPage();})}
20reloadFully()})()

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.