PageSourceSearch

https://valdresmusea.no/assets/gen/m24-autoplay.js?b7cf120d

js valdresmusea.no collected 2026-10-02 07:20:02 UTC 11,031 bytes, 42 lines download raw bytes

1var footer=null;var footerdebug=false;var _videoScriptLoadTime=performance.now();var enable_debug=false;var enable_debug_full=false;var force_hlsjs=false;if(typeof VIDEO_DEBUG!=='undefined'&&VIDEO_DEBUG){enable_debug=true;}
2if(typeof VIDEO_DEBUG_FULL!=='undefined'&&VIDEO_DEBUG_FULL){enable_debug_full=true;}
3if(typeof VIDEO_FORCE_HLS!=='undefined'&&VIDEO_FORCE_HLS){force_hlsjs=true;}
4if(AUTOPLAY_VIDEO){console.log("AUTOPLAY_VIDEO is set, forcing use of hls.js where possible");force_hlsjs=true;}
5var hlsStreams={};var hlsIntances={};let desiredLevel=null;function logging(msg,obj){if(enable_debug||enable_debug_full){console.log(msg,obj||'');}
6if(enable_debug_full){footer=footer||document.getElementById("m24top")||document.body;if(!footer){return;}
7var message=document.createElement('div');message.innerHTML=msg+(obj?JSON.stringify(obj):'');footer.appendChild(message);}}
8var userAgent=window.navigator.userAgent;logging(userAgent);var isAndroidChrome=userAgent.includes("Android")&&userAgent.includes("Chrome");var isIOSSafari=/iPad|iPhone|iPod/.test(userAgent)&&!window.MSStream&&userAgent.includes("Safari")&&!userAgent.includes("Chrome");if(force_hlsjs){logging("VIDEO_FORCE_HLS is set, forcing use of hls.js where possible");isIOSSafari=false;}
9var isMobileDevice=window.innerWidth<=767;logging("isMobileDevice: "+isMobileDevice);function prepareHLSVideo(){var videoElements=document.getElementsByTagName('video');logging("Video tags on this page:"+videoElements.length);for(var i=0;i<videoElements.length;i++){var video=videoElements[i];if(typeof Hls!=='undefined'&&Hls&&Hls.isSupported()&&!isIOSSafari){logging("Video can be supported by hls.js");}else{if(video.canPlayType('application/vnd.apple.mpegurl')&&isIOSSafari){var src=video.dataset.url||undefined;if(src){video.src=src;}}}
10video.addEventListener('ended',videoEndedHandler,false);video.addEventListener('playing',videoPlayingHandler,false);video.addEventListener('play',videoPlayHandler,false);}}
11if(typeof Hls!=='undefined'&&Hls){prepareHLSVideo();}else{document.addEventListener('hlsjs:ready',function(){prepareHLSVideo();});}
12function play(video,calledFrom){var sincePageLoad=(performance.now()/1000).toFixed(2);var sinceScriptLoad=((performance.now()-_videoScriptLoadTime)/1000).toFixed(2);console.log("⏱ play() | siden sidestart: "+sincePageLoad+"s | siden script-last: "+sinceScriptLoad+"s | fra: "+calledFrom);logging("FUNCTION:play()",{video:video,calledFrom:calledFrom});setTimeout(function(){video.classList.add('video-force-opacity');},3000);if(typeof Hls!=='undefined'&&Hls.isSupported()&&!isIOSSafari){playHls(video);if(video.muted){video.parentElement.parentElement.classList.add('video--muted');}else{video.parentElement.parentElement.classList.remove('video--muted');}
13logging("Video can be supported by hls.js");}else{console.log("played with native mpegurl support");logging("Video cannot be supported by hls.js, check for native support for mpegurl");if(video.canPlayType('application/vnd.apple.mpegurl')){var src=video.dataset.url||undefined;if(!video.src&&src){video.src=src;}
14logging("PLAY:NATIVE",src);video.play();}}}
15function stop(video){if(video.play){var pausePromise=video.pause();if(pausePromise!==undefined){pausePromise.then(function(){video.parentElement.parentElement.classList.add('video--pause');}).catch(function(){});}}}
16function toggleVideoPlay(id){logging("toggleVideoPlay()",id);var video=document.getElementById(id);if(video.getElementsByTagName("video")[0]){video=video.getElementsByTagName("video")[0];}
17if(video){if(video.paused){if(typeof Hls!=='undefined'&&Hls.isSupported()&&!isIOSSafari){playHls(video);}else
18if(video.canPlayType('application/vnd.apple.mpegurl')){video.classList.add('videodata-loaded');play(video,"toggleVideoPlay: play native mpegurl");}}else if(video.play){video.pause();video.parentElement.parentElement.classList.add('video--pause');}else{if(typeof Hls!=='undefined'&&Hls.isSupported()&&!isIOSSafari){playHls(video);}else{if(video.canPlayType('application/vnd.apple.mpegurl')){console.log("apple:play:videodata-loaded");video.classList.add('videodata-loaded');
18play(video,"toggleVideoPlay: play native mpegurl");}}}}}
19function videoPlayingHandler(e){var video=document.getElementById(e.target.id);e.target.parentElement.parentElement.classList.add('video--playing');e.target.parentElement.parentElement.classList.remove('video--pause');e.target.parentElement.parentElement.classList.remove('video--end');}
20function videoPlayHandler(e){var video=document.getElementById(e.target.id);if(video._hlsStarted)return;logging("videoPlayHandler: "+video.src);logging("videoPlayHandler:canPlayType('application/vnd.apple.mpegurl'): "+video.canPlayType('application/vnd.apple.mpegurl'));if(typeof Hls!=='undefined'&&Hls.isSupported()&&!isIOSSafari){logging("videoPlayHandler: Video can be supported by hls.js so this will be preferred");playHls(video);}else{logging("videoPlayHandler: Video cannot be supported by hls.js, check for native support for mpegurl");if(video.canPlayType('application/vnd.apple.mpegurl')){console.log("Video played with native mpegurl support");logging("videoPlayHandler: Native browser support for mpegurl");video.addEventListener('loadedmetadata',function(){logging("event:loadedmetadata.. add .videodata-loaded class");video.classList.add('videodata-loaded');});}
21e.target.parentElement.parentElement.classList.add('video--playing');e.target.parentElement.parentElement.classList.remove('video--pause');e.target.parentElement.parentElement.classList.remove('video--end');}}
22function videoEndedHandler(e){console.log("The video has ended:",e.target.id);e.target.parentElement.parentElement.classList.add('video--end');}
23function playHls(element){console.log("Hls.js is supported:",Hls.isSupported());var video=element;var id=element.id;if(video.classList.contains("hls")&&typeof Hls!=='undefined'&&Hls.isSupported()){logging("FUNCTION:playHls()");var src=video.dataset.url||undefined;logging("playHls(): video contains hls src",src);var abrEstimate=isMobileDevice?2500000:10000000;var abrEstimateMax=isMobileDevice?5000000:20000000;var startLevel=isMobileDevice?2:(VIDEO_LEVEL||-1);var hlsConfig={debug:enable_debug_full||false,startLevel:startLevel,capLevelToPlayerSize:true,abrEwmaDefaultEstimate:abrEstimate,abrEwmaDefaultEstimateMax:abrEstimateMax,maxBufferLength:isMobileDevice?15:30,maxBufferHole:isMobileDevice?0.25:0.5,enableWorker:true}
24logging("playHls(): HLS config",hlsConfig);if(Hls.isSupported()&&src){console.log("Video played with hls.js");if(!hlsStreams[id]){logging("playHls(): Setting up HLS");var hls=new Hls(hlsConfig);hls.loadSource(src);hls.attachMedia(video);hlsStreams[id]=true;hlsIntances[id]=hls;hls.on(Hls.Events.MANIFEST_PARSED,function(event,data){logging("playHls(): Setting up HLS...Manifest_parsed:start play");logging("playHls(): Levels::",data.levels.length);var elapsed=((performance.now()-_videoScriptLoadTime)/1000).toFixed(2);console.log("⏱ Video play() "+elapsed+"s etter script-last:",id);var playPromise=video.play();video._hlsStarted=true;if(playPromise!==undefined){playPromise.then(function(){var elapsed=((performance.now()-_videoScriptLoadTime)/1000).toFixed(2);console.log("⏱ Video startet avspilling "+elapsed+"s etter script-last:",id);logging("playHls(): videodata-loaded");video.classList.add('videodata-loaded');}).catch(function(){video.parentElement.parentElement.classList.add('video--pause');var banner_controls=video.parentElement.parentElement.querySelectorAll('.banner__controls')[0];if(banner_controls){banner_controls.dataset.playing="false";}});}});hls.on(Hls.Events.LEVEL_SWITCHED,(event,data)=>{desiredLevel=data.level;logging(`playHls():Level switched to ${data.level}`);});}else{logging("playHls(): Playing HLS in existing hls-stream");video.play();}}
25}else{logging("playHls: playing in low-quality video");video.play();}}
26function toggleVideoSound(id){var video=document.getElementById(id);if(video.getElementsByTagName("video")[0]){video=video.getElementsByTagName("video")[0];}
27if(video){if(video.muted){video.muted=false;video.volume=0.5;video.parentElement.parentElement.classList.remove('video--muted');}else{video.muted=true;video.parentElement.parentElement.classList.add('video--muted');}}}
28function restartVideo(id){var video=document.getElementById(id);if(video.getElementsByTagName("video")[0]){video=video.getElementsByTagName("video")[0];}
29if(video){video.currentTime=0;video.play();}}
30var videovolume=false;function videoVolume(id,direction){var video=document.getElementById(id);var slider=document.getElementById(id+"_slider");if(video.getElementsByTagName("video")[0]){video=video.getElementsByTagName("video")[0];}
31if(video){if(!videovolume||videovolume<0.1){video.volume=0.5;}
32video.muted=false;video.parentElement.parentElement.classList.remove('video--muted');if(direction==='up'&&video.volume<1){video.volume=(video.volume+0.1).toFixed(2);}
33if(direction==='down'&&video.volume>
33=0.1){video.volume=(video.volume-0.1).toFixed(2);if(video.volume===0){video.parentElement.parentElement.classList.add('video--muted');}}
34videovolume=video.volume.toFixed(2);if(slider){slider.value=videovolume;}}}
35function changeVolume(id,val){var video=document.getElementById(id);if(video.getElementsByTagName("video")[0]){video=video.getElementsByTagName("video")[0];}
36if(video){video.volume=val;if(video.volume===0){video.parentElement.parentElement.classList.add('video--muted');}
37videovolume=video.volume.toFixed(2);}}
38(function(){var autoplayVideo=document.getElementsByClassName('inviewAutoPlay');for(var i=0;i<autoplayVideo.length;i++){new Waypoint({element:autoplayVideo[i],handler:function(direction){if(direction=="down"){logging("Video inviewAutoPlay START offset 60",this.element.id);play(this.element,"waypoints.common.banners.autoplay: offset 60%");}},offset:'60%'})};for(var i=0;i<autoplayVideo.length;i++){new Waypoint({element:autoplayVideo[i],handler:function(direction){if(direction=="up"){logging("Video inviewAutoPlay START offset -50%",this.element.id);play(this.element,"waypoints.common.banners.autoplay: offset -50%");}
39if(direction=="down"){logging("Video inviewAutoPlay STOP -50 % (below)",this.element.id);stop(this.element);}},offset:'-50%'})};for(var i=0;i<autoplayVideo.length;i++){new Waypoint({element:autoplayVideo[i],handler:function(direction){if(direction=="up"){logging("Video inviewAutoPlay STOP 90 % (above)",this.element.id);stop(this.element);}},offset:'90%'})};var sections=document.getElementsByClassName('section');for(var i=0;i<sections.length;i++){new Waypoint({element:sections[i],handler:function(direction){this.element.classList.add('inView');},offset:'40%'})
40new Waypoint({element:sections[i],handler:function(direction){if(direction=="down"){this.element.classList.remove('inView');}
41if(direction=="up"){this.element.classList.add('inView');}},offset:function(){return-this.element.clientHeight}})
42new Waypoint({element:sections[i],handler:function(direction){if(direction=="up"){this.element.classList.remove('inView');}},offset:'101%'})}})();

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.