1(function(){'use strict';document.addEventListener('DOMContentLoaded',function(){var filterBar=document.querySelector('.sg-filter-bar');if(filterBar){var selects=filterBar.querySelectorAll('select');selects.forEach(function(sel){sel.addEventListener('change',function(){filterBar.submit();});});} 2if(window.location.search&&document.querySelector('.sg-listing-grid')){var grid=document.querySelector('.sg-listing-grid');if(grid){grid.scrollIntoView({behavior:'smooth',block:'start'});}} 3var cityPicker=document.querySelector('[data-sg-city-picker-dialog]');if(cityPicker){var cityPickerDialog=cityPicker.querySelector('.sg-city-picker__dialog');var cityPickerIntro=cityPicker.querySelector('[data-sg-city-picker-intro]');var cityPickerOptions=cityPicker.querySelector('[data-sg-city-picker-options]');var cityPickerTrigger=null;function closeCityPicker(){cityPicker.hidden=true;document.body.classList.remove('sg-city-picker-open');if(cityPickerTrigger){cityPickerTrigger.focus();}} 4function openCityPicker(trigger){var options=[];try{options=JSON.parse(trigger.getAttribute('data-sg-city-options')||'[]');}catch(error){return;} 5if(!options.length){return;} 6cityPickerTrigger=trigger;var categoryName=trigger.getAttribute('data-sg-category-name')||'kategorien';var prompt=window.sgDirectoryLabels&&window.sgDirectoryLabels.cityPrompt?window.sgDirectoryLabels.cityPrompt:'Hvilken by vil du se %s i?';cityPickerIntro.textContent=prompt.replace('%s',categoryName);cityPickerOptions.textContent='';options.forEach(function(option){var link=document.createElement('a');link.className='sg-city-picker__option';link.href=option.url;link.textContent=option.name;cityPickerOptions.appendChild(link);});cityPicker.hidden=false;document.body.classList.add('sg-city-picker-open');cityPickerDialog.focus();} 7document.addEventListener('click',function(event){var trigger=event.target.closest('[data-sg-city-picker]');if(trigger){event.preventDefault();openCityPicker(trigger);return;} 8if(event.target.closest('[data-sg-city-picker-close]')){closeCityPicker();}});document.addEventListener('keydown',function(event){if(cityPicker.hidden){return;} 9if(event.key==='Escape'){closeCityPicker();return;} 10if(event.key==='Tab'){var focusable=Array.prototype.slice.call(cityPickerDialog.querySelectorAll('a[href], button:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(!focusable.length){event.preventDefault();cityPickerDialog.focus();return;} 11var first=focusable[0];var last=focusable[focusable.length-1];if(event.shiftKey&&(document.activeElement===first||document.activeElement===cityPickerDialog)){event.preventDefault();last.focus();}else if(!event.shiftKey&&document.activeElement===last){event.preventDefault();first.focus();}}});} 12document.querySelectorAll('[data-sg-expandable]').forEach(function(wrapper){var content=wrapper.querySelector('[data-sg-expandable-content]');var toggle=wrapper.querySelector('[data-sg-expandable-toggle]');var label=toggle?toggle.querySelector('[data-sg-expandable-label]'):null;if(!content||!toggle||!label){return;} 13wrapper.classList.add('sg-expandable-ready');var moreLabel=window.sgDirectoryLabels&&window.sgDirectoryLabels.viewMore?window.sgDirectoryLabels.viewMore:'Se mere';var lessLabel=window.sgDirectoryLabels&&window.sgDirectoryLabels.viewLess?window.sgDirectoryLabels.viewLess:'Se mindre';function updateToggleVisibility(){if(content.classList.contains('sg-expandable-content--expanded')){return;} 14toggle.hidden=content.scrollHeight<=content.clientHeight+1;} 15label.textContent=moreLabel;updateToggleVisibility();window.addEventListener('load',updateToggleVisibility);toggle.addEventListener('click',function(){var isExpanded=content.classList.toggle('sg-expandable-content--expanded');toggle.setAttribute('aria-expanded',isExpanded?'true':'false');label.textContent=isExpanded?lessLabel:moreLabel;if(!isExpanded){wrapper.scrollIntoView({behavior:'smooth',block:'nearest'});}});window.addEventListener('resize',updateToggleVisibility);});function directoryLabel(key,fallback){return window.sgDirectoryLabels&&window.sgDirectoryLabels[key]?window.sgDirectoryLabels[key]:fallback;} 16function paginationTarget(pagination,sourceDocument){var targetId=pagination.getAttribute('data-sg-pagination-target');if(targetId){return sourceDocument.getElementById(targetId);} 17return pagination.closest('section');} 18function paginationForTarget(sourceDocument,targetId){var paginations=sourceDocument.querySelectorAll('[data-sg-load-more]');for(var index=0;
18index<paginations.length;index+=1){if(paginations[index].getAttribute('data-sg-pagination-target')===targetId){return paginations[index];}} 19return null;} 20function setupLoadMore(pagination){if(pagination.getAttribute('data-sg-load-more-ready')==='true'){return;} 21var target=paginationTarget(pagination,document);var nextLink=pagination.querySelector('a.next.page-numbers');if(!target||!nextLink){return;} 22var grid=target.querySelector('[data-sg-pagination-grid], .sg-listing-grid, .sg-directory-grid, .sg-guide-grid');if(!grid){return;} 23pagination.setAttribute('data-sg-load-more-ready','true');pagination.classList.add('sg-pagination--enhanced');var button=document.createElement('button');button.type='button';button.className='sg-load-more';button.textContent=directoryLabel('loadMore','Vis flere');pagination.appendChild(button);var status=target.querySelector('[data-sg-load-more-status]');if(!status){status=document.createElement('p');status.className='sg-load-more-status';status.setAttribute('data-sg-load-more-status','');status.setAttribute('role','status');status.setAttribute('aria-live','polite');pagination.after(status);} 24button.addEventListener('click',function(){if(button.disabled){return;} 25button.disabled=true;button.textContent=directoryLabel('loadingMore','Henter flereâ¦');target.setAttribute('aria-busy','true');fetch(nextLink.href,{credentials:'same-origin'}).then(function(response){if(!response.ok){throw new Error('Pagination request failed');} 26return response.text();}).then(function(html){var sourceDocument=new DOMParser().parseFromString(html,'text/html');var targetId=pagination.getAttribute('data-sg-pagination-target');var sourceTarget=targetId?sourceDocument.getElementById(targetId):null;var sourceGrid=sourceTarget?sourceTarget.querySelector('[data-sg-pagination-grid], .sg-listing-grid, .sg-directory-grid, .sg-guide-grid'):null;var sourcePagination=paginationForTarget(sourceDocument,targetId);if(!sourceGrid||!sourcePagination){throw new Error('Pagination response did not match the current list');} 27var added=sourceGrid.children.length;Array.prototype.forEach.call(sourceGrid.children,function(item){grid.appendChild(document.importNode(item,true));});sourcePagination.removeAttribute('data-sg-load-more-ready');pagination.replaceWith(sourcePagination);status.textContent=directoryLabel('loadedResults','%d flere resultater er vist.').replace('%d',added);target.removeAttribute('aria-busy');if(sourcePagination.querySelector('a.next.page-numbers')){setupLoadMore(sourcePagination);}else{sourcePagination.remove();status.textContent=directoryLabel('loadMoreComplete','Alle resultater er vist.');}}).catch(function(){target.removeAttribute('aria-busy');button.disabled=false;button.textContent=directoryLabel('retryLoadMore','Prøv igen');status.textContent=directoryLabel('loadMoreError','Kunne ikke hente flere resultater. Prøv igen.');});});} 28document.querySelectorAll('[data-sg-load-more]').forEach(setupLoadMore);function sendClick(postId){if(!postId||!window.sgClick||!sgClick.ajaxUrl){return Promise.resolve();} 29var payload=new FormData();payload.append('action','sg_track_click');payload.append('post_id',postId);payload.append('nonce',sgClick.nonce||'');return fetch(sgClick.ajaxUrl,{method:'POST',body:payload,credentials:'same-origin',keepalive:true}).catch(function(){});} 30document.addEventListener('click',function(event){var link=event.target.closest('a');if(!link){return;} 31var card=link.closest('.sg-card, .sg-guide-card');if(!card){return;} 32var postId=card.getAttribute('data-sg-click-id');if(!postId){return;} 33var isGuideCard=!!link.closest('.sg-guide-card');var isMainClick=event.button===0&&!event.metaKey&&!event.ctrlKey&&!event.shiftKey&&!event.altKey;var sameTab=!link.target||link.target==='_self';if(isGuideCard&&isMainClick&&sameTab&&link.href){event.preventDefault();var timeoutPromise=new Promise(function(resolve){setTimeout(resolve,250);});Promise.race([sendClick(postId),timeoutPromise]).finally(function(){window.location.href=link.href;});return;} 34sendClick(postId);});var galleryEl=document.getElementById('sg-gallery');if(galleryEl){var items=galleryEl.querySelectorAll('[data-sg-lightbox]');var galleryWrap=galleryEl.closest('.sg-gallery-wrap');var prevButton=galleryWrap?galleryWrap.querySelector('.sg-gallery__control--prev'):null;var nextButton=galleryWrap?galleryWrap.querySelector('.sg-gallery__control--next'):null;var urls=[];
34items.forEach(function(item){urls.push(item.href);});var currentIndex=0;var lightbox=null;var lightboxImg=null;function createLightbox(){lightbox=document.createElement('div');lightbox.className='sg-lightbox';lightbox.innerHTML='<button class="sg-lightbox__close" aria-label="Close">×</button>'+'<button class="sg-lightbox__nav sg-lightbox__nav--prev" aria-label="Previous">‹</button>'+'<img class="sg-lightbox__img" src="" alt="" />'+'<button class="sg-lightbox__nav sg-lightbox__nav--next" aria-label="Next">›</button>';document.body.appendChild(lightbox);lightboxImg=lightbox.querySelector('.sg-lightbox__img');lightbox.querySelector('.sg-lightbox__close').addEventListener('click',closeLightbox);lightbox.querySelector('.sg-lightbox__nav--prev').addEventListener('click',function(e){e.stopPropagation();navigate(-1);});lightbox.querySelector('.sg-lightbox__nav--next').addEventListener('click',function(e){e.stopPropagation();navigate(1);});lightbox.addEventListener('click',function(e){if(e.target===lightbox){closeLightbox();}});}
35function openLightbox(index){if(!lightbox){createLightbox();} 36currentIndex=index;lightboxImg.src=urls[currentIndex];lightboxImg.alt='Image '+(currentIndex+1)+' of '+urls.length;document.body.style.overflow='hidden';lightbox.style.display='flex';requestAnimationFrame(function(){lightbox.classList.add('sg-lightbox--active');});} 37function closeLightbox(){if(!lightbox)return;lightbox.classList.remove('sg-lightbox--active');document.body.style.overflow='';setTimeout(function(){lightbox.style.display='none';},250);} 38function navigate(dir){currentIndex=(currentIndex+dir+urls.length)%urls.length;lightboxImg.src=urls[currentIndex];lightboxImg.alt='Image '+(currentIndex+1)+' of '+urls.length;} 39items.forEach(function(item,i){item.addEventListener('click',function(e){e.preventDefault();openLightbox(i);});});function updateGalleryControls(){if(!prevButton||!nextButton)return;var maxScroll=galleryEl.scrollWidth-galleryEl.clientWidth;var hasOverflow=maxScroll>2;prevButton.hidden=!hasOverflow;nextButton.hidden=!hasOverflow;prevButton.disabled=galleryEl.scrollLeft<=2;nextButton.disabled=galleryEl.scrollLeft>=maxScroll-2;} 40if(prevButton&&nextButton){prevButton.addEventListener('click',function(){galleryEl.scrollBy({left:-galleryEl.clientWidth,behavior:'smooth'});});nextButton.addEventListener('click',function(){galleryEl.scrollBy({left:galleryEl.clientWidth,behavior:'smooth'});});galleryEl.addEventListener('scroll',updateGalleryControls,{passive:true});window.addEventListener('resize',updateGalleryControls);updateGalleryControls();} 41document.addEventListener('keydown',function(e){if(!lightbox||lightbox.style.display==='none')return;if(e.key==='Escape')closeLightbox();if(e.key==='ArrowLeft')navigate(-1);if(e.key==='ArrowRight')navigate(1);});} 42var mapEl=document.getElementById('sg-map');if(mapEl&&mapEl.dataset.lat&&mapEl.dataset.lng){var lat=parseFloat(mapEl.dataset.lat);var lng=parseFloat(mapEl.dataset.lng);var title=mapEl.dataset.title||'';if(!isNaN(lat)&&!isNaN(lng)){if(!document.querySelector('link[href*="leaflet"]')){var leafletCSS=document.createElement('link');leafletCSS.rel='stylesheet';leafletCSS.href='https://unpkg.com/[email protected]/dist/leaflet.css';document.head.appendChild(leafletCSS);} 43function initMap(){if(typeof L==='undefined')return;var map=L.map(mapEl,{scrollWheelZoom:false,attributionControl:true}).setView([lat,lng],15);L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{attribution:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',maxZoom:19}).addTo(map);L.marker([lat,lng]).addTo(map).bindPopup(title).openPopup();} 44if(typeof L!=='undefined'){initMap();}else{var leafletJS=document.createElement('script');leafletJS.src='https://unpkg.com/[email protected]/dist/leaflet.js';leafletJS.onload=initMap;document.body.appendChild(leafletJS);}}} 45var testForm=document.getElementById('tests1-form');if(testForm){var totalQuestions=parseInt(testForm.getAttribute('data-total-questions')||'0',10);if(isNaN(totalQuestions)||totalQuestions<1){totalQuestions=16;} 46var progressBar=document.getElementById('myProgress');var waiting=testForm.querySelector('.waiting-load-success');testForm.addEventListener('click',function(event){var input=event.target;if(!input||input.tagName!=='INPUT'||input.type!=='radio'){return;} 47if(!/^question[0-9]+$/.test(input.name)){return;} 48var questionBlock=input.closest('.b-q-image');if(!questionBlock){return;} 49var flowIndex=parseInt(questionBlock.getAttribute('data-flow-index')||'0',10);if(isNaN(flowIndex)||flowIndex<1){return;} 50if(progressBar){var progress=Math.min(100,Math.max(0,(flowIndex/totalQuestions)*100));progressBar.style.width=progress+'%';} 51var nextQ=testForm.querySelector('.b-q-image[data-flow-index="'+(flowIndex+1)+'"]');if(nextQ&&nextQ.classList.contains('test-question')){var hiddenByCss=window.getComputedStyle(nextQ).display==='none';if(hiddenByCss){nextQ.style.display='block';nextQ.scrollIntoView({behavior:'smooth',block:'start'});return;}} 52if(flowIndex===totalQuestions){if(waiting){waiting.style.display='block';} 53setTimeout(function(){testForm.submit();},900);}});} 54document.addEventListener('click',function(event){var btn=event.target.closest('.show_results_more');
54if(!btn){return;} 55if(!btn.closest('.sg-uddannelsestest')){return;} 56var typeResult=parseInt(btn.getAttribute('data-type')||'0',10);var targetId=btn.getAttribute('data-target')||'';var target=targetId?document.getElementById(targetId):null;if(!typeResult||!target||!window.sgTest||!sgTest.ajaxUrl){return;} 57event.preventDefault();btn.setAttribute('disabled','disabled');var wrapper=btn.parentElement;var loader=wrapper?wrapper.querySelector('.loading-more-result-img'):null;if(loader){loader.style.display='inline-block';} 58var payload=new FormData();payload.append('action','sg_get_more_result');payload.append('type',String(typeResult));payload.append('nonce',sgTest.nonce||'');fetch(sgTest.ajaxUrl,{method:'POST',body:payload,credentials:'same-origin'}).then(function(response){return response.json();}).then(function(response){if(loader){loader.style.display='none';} 59btn.removeAttribute('disabled');if(!response||response.status!=='success'){return;} 60btn.remove();if(response.results){target.insertAdjacentHTML('beforeend',response.results);}}).catch(function(){if(loader){loader.style.display='none';} 61btn.removeAttribute('disabled');});});});})();
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.