1var $fixedDivTop; 2var initialPaddingTop; 3 4$(document).ready(function(){ 5 var $fixedItems = $(".section.fixed-pushdown"); 6 if($fixedItems.length >= 1){ 7 $fixedItems.first().before('<div class="fixed-merge"></div>'); 8 $fixedDivTop = $(".fixed-merge"); 9 $fixedItems.each(function(index, item){ 10 $fixedDivTop.append(item); 11 $(item).removeClass("fixed-pushdown"); 12 }); 13 $fixedDivTop.addClass("fixed-pushdown"); 14 initialPaddingTop = parseInt($("body").css("padding-top")); 15 updatePushDown(); 16 } 17}); 18 19$(window).load(function(){ 20 updatePushDown(); 21}); 22 23$(window).resize(function() { 24 updatePushDown(); 25}); 26 27function updatePushDown(){ 28 var fixedHeight = $(".fixed-pushdown").height(); 29 $("body").css("padding-top", fixedHeight+initialPaddingTop); 30} 31 32 /* Extra script */ 33 if (location.hostname == 'localhost') { 34 const localhostStyleUrl = 'http://127.0.0.1:5500/style.css' 35 window.styleSwitchout = true 36 window.styleTimeout = 3000 37 window.styleVersion = 0 38 $(() => { 39 window.styleLink = $( 40 'link[href^="https://files.solvecms.com/friluftsrad.no2"]', 41 ) 42 if (!window.styleLink) return 43 window.styleLink.attr( 44 'href', 45 localhostStyleUrl + '?v=' + window.styleVersion, 46 ) 47 setInterval(() => { 48 if (!window.styleSwitchout) return 49 window.styleVersion++ 50 const newLink = $( 51 '<link rel="stylesheet" type="text/css" href="' + 52 localhostStyleUrl + 53 '?v=' + 54 window.styleVersion + 55 '">', 56 ) 57 newLink.on('load', () => { 58 window.styleLink.remove() 59 window.styleLink = newLink 60 }) 61 $('head').append(newLink) 62 }, window.styleTimeout) 63 }) 64} 65 66$(() => { 67 const $elements = $('.module-statistics .stat .left.countup') 68 $elements.each(function (index, element) { 69 const value = $(element).data('value') 70 if (isNaN(value)) { 71 $(element).html($(element).data('value')) 72 } 73 }) 74 setTimeout(() => { 75 runCountUp() 76 }, 800) 77 78 outOfBounds() 79 80 iframeMarginCorrection() 81 opointNews() 82 makeFrontpageBlogNavigateable() 83 addAnchorBlogfeed() 84 setupMenuReveal() 85 setMenuItemRedirects() 86}) 87 88var countupTime = 1500 // milliseconds 89var startNextTime = 500 // milliseconds 90var countingUp = false // do not change 91var countupOptions = { 92 useEasing: true, 93 useGrouping: true, 94 separator: '', 95} 96 97var countNext = function () { 98 countingUp = false 99 runCountUp() 100} 101 102var runCountUp = function () { 103 if (countingUp) return 104 105 var $elements = $('.module-statistics .stat .left.countup') 106 $elements.each((index, element) => { 107 if (isElementInViewport(element) && index == 0) { 108 var value = $(element).data('value') 109 if (isNaN(value)) return 110 111 countingUp = true 112 var countUp = new CountUp( 113 element, 114 0, 115 value, 116 false, 117 countupTime / 1000, 118 countupOptions, 119 ) 120 countUp.start() 121 $(element).removeClass('countup') 122 setTimeout(countNext, startNextTime) 123 } 124 }) 125} 126 127function isElementInViewport(elem) { 128 var docViewTop = $(window).scrollTop() 129 var docViewBottom = docViewTop + $(window).height() 130 131 var elemTop = $(elem).offset().top 132 var elemBottom = elemTop + $(elem).height() 133 134 return elemBottom <= docViewBottom && elemTop >= docViewTop 135} 136 137window.addEventListener('scroll', () => { 138 runCountUp() 139}) 140 141function outOfBounds() { 142 $('.module-menu-holder.hover .has-children').on('mouseenter', function () { 143 $(this) 144 .find('> ul') 145 .each(function () { 146 $(this).removeClass('outOfBounds') 147 if ( 148 $(this).offset().left + $(this).outerWidth(true) > 149 innerWidth 150 ) { 151 $(this).addClass('outOfBounds') 152 } 153 }) 154 }) 155} 156 157function iframeMarginCorrection() { 158 $('iframe').each(function () { 159 if (this.src.includes('norgeskart')) { 160 $(this).parent().addClass('norgeskartContainer') 161 } 162 }) 163} 164 165function learningFreshairMenuClose() { 166 document.body.classList.remove('learning-freshair-menu-open') 167} 168function learningFreshairMenuOpen() { 169 document.body.classList.add('learning-freshair-menu-open') 170} 171 172if (location.pathname.includes('laering-i-friluft')) { 173 document.addEventListener('keydown', (event) => { 174 if (event.key == 'Escape') { 175 learningFreshairMenuClose() 176 } 177 }) 178} 179 180function opointNews() { 181 const moduleOpointNews = document.querySelector('.module-opoint-news') 182 if (!moduleOpointNews) { 183 return 184 } 185 const newsItems = moduleOpointNews.querySelectorAll('.news-item') 186 for (const newsItem of newsItems) { 187 const link = newsItem.querySelector('a') 188 const topLevelDomain = getTopLevelDomainFromUrl(link.href) 189 const anchorTag = document.createElement('a') 190 anchorTag.textContent = topLevelDomain 191 anchorTag.classList.add('anchor') 192 anchorTag.href = link.href 193 newsItem.prepend(anchorTag) 194 195 const afterLink = document.createElement('a') 196 afterLink.href = link.href 197 afterLink.classList.add('after-link') 198 newsItem.append(afterLink) 199 } 200} 201function getTopLevelDomainFromUrl(url) { 202 const domain = url.split('/')[2] 203 const domainParts = domain.split('.') 204 const topLevelDomain = domainParts.slice(-2).join('.') 205 return topLevelDomain 206} 207 208function makeFrontpageBlogNavigateable() { 209 const blogfeed = document.querySelector('.frontpage-blogfeed') 210 if (!blogfeed) { 211 return 212 } 213 blogfeed.id = 'aktuelt' 214} 215 216function addAnchorBlogfeed() { 217 const blogItems = Array.from( 218 document.querySelectorAll('.dedicated-newsarchive > ul > li'), 219 ) 220 if (!blogItems.length) return 221 for (const blogItem of blogItems) { 222 const anchor = document.createElement('a') 223 anchor.href = blogItem.querySelector('a').href 224 anchor.classList.add('blogfeed-anchor') 225 anchor.textContent = 'LES MER' 226 const target = blogItem.querySelector('.blogfeed-info') 227 target.appendChild(anchor) 228 } 229} 230 231function setupMenuReveal() { 232 const menuReveals = Array.from( 233 document.querySelectorAll( 234 '.module-menu-holder.menu-main .level2 > .has-children', 235 ), 236 ) 237 if (!menuReveals || !menuReveals.length) return 238 239 for (const menuReveal of menuReveals) { 240 const button = document.createElement('button') 241 button.attributes['aria-label'] = 'Vis undermeny' 242 button.classList.add('menu-reveal') 243 button.innerHTML = 244 '<img src="https://tryggmedia-storage.s3.eu-west-1.amazonaws.com/friluftsraadet/arrow-right-2.svg" alt="">' 245 button.addEventListener('click', function () { 246 menuReveal.classList.toggle('menu-reveal-open') 247 }) 248 menuReveal.insertBefore(button, menuReveal.children[1]) 249 } 250} 251 252function setMenuItemRedirects() { 253 $('a[href="/om-fl/medlemsrad"]').each((_, link) => { 254 $(link).attr('href', '/medlemsrad') 255 }) 256} 257
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.