1/*! 2 * iframemanager v1.1.0 3 * Author Orest Bida 4 * Released under the MIT License 5 * Modified by Codingfreaks for Typo3 CMS integration 6 */ 7(function(){'use strict';var iframeDivs={},preconnects=[],preloads=[],stopObserver=!1,currLang='',services=null,serviceNames=[],doc=document,disallowedProps=['onload','onerror','src'];function getVideoProp(div){var dataset=div.dataset;var attrs={};for(var prop in dataset){if(prop.lastIndexOf('iframe')===0){attrs[prop.slice(6).toLowerCase()]=dataset[prop]}} 8return{_id:dataset.id,_title:dataset.title,_thumbnail:dataset.thumbnail,_params:dataset.params,_thumbnailPreload:'thumbnailpreload' in dataset,_autoscale:'autoscale' in dataset,_div:div,_backgroundDiv:null,_hasIframe:!1,_hasNotice:!1,_showNotice:!0,_iframeAttributes:attrs}};function lazyLoadThumnails(serviceName,thumbnailUrl){var videos=iframeDivs[serviceName];if("IntersectionObserver" in window){var thumbnailObserver=new IntersectionObserver(function(entries){entries.forEach(function(entry){if(entry.isIntersecting){let thumbUrl=thumbnailUrl;if(typeof thumbUrl==='string'){const videoUrl=videos[entry.target.dataset.index]._id;const params=`cf_width=${entry.boundingClientRect.width}&cf_height=${entry.boundingClientRect.height}`;const encodedParams=params;thumbUrl=thumbUrl.replace('##CF-BUILDTHUMBNAIL##',btoa(videoUrl.includes('?')?`${videoUrl}&${encodedParams}`:`${videoUrl}?${encodedParams}`))} 9loadThumbnail(thumbUrl,videos[entry.target.dataset.index]);thumbnailObserver.unobserve(entry.target)}})});videos.forEach(function(video){thumbnailObserver.observe(video._div)})}else{for(var i=0;i<videos.length;i++){loadThumbnail(thumbnailUrl,videos[i])}}};function fetchImage(url){return fetch(url).then(response=>response.blob()).then(blob=>URL.createObjectURL(blob))} 10function loadThumbnail(url,video){if(typeof video._thumbnail==='string'&&video._thumbnail.length>=1){video._thumbnailPreload&&preloadThumbnail(video._thumbnail);video._thumbnail!==''&&loadBackgroundImage(video._thumbnail,video)}else{if(typeof url==="function"){url(video._id,function(src){preconnect(src);video._thumbnailPreload&&preloadThumbnail(src);loadBackgroundImage(src,video)})}else if(typeof url==='string'){var src=url.replace('{data-id}',video._id);preconnect(src);video._thumbnailPreload&&preloadThumbnail(src);fetchImage(src).then(imageUrl=>loadBackgroundImage(imageUrl,video))}} 11async function loadBackgroundImage(src,video){video._backgroundDiv.style.backgroundImage="url('"+src+"')";const img=new Image();img.src=src;await new Promise((resolve,reject)=>{img.onload=resolve;img.onerror=reject});video._backgroundDiv.classList.add('loaded')}};var _createNode=function(type){var el=document.createElement(type);if(type==='button'){el.setAttribute('type',type)} 12return el} 13function createIframe(video,service){if(video._hasIframe) 14return;video._hasIframe=!0;if(typeof service.onAccept==='function'){service.onAccept(video._div,function(iframe){video._iframe=iframe;video._hasIframe=!0;video._div.classList.add('c-h-b')});return} 15video._iframe=createNode('iframe');var iframeParams=video._params||(service.iframe&&service.iframe.params);var embedUrl=service.embedUrl||'';var scripts=document.querySelectorAll('script[data-service]');var _loadScripts=function(scripts,index){if(index<scripts.length){var curr_script=scripts[index];var curr_script_category=curr_script.getAttribute("data-service");if(cc.allowedCategory(curr_script_category)!==!1){console.log(curr_script_category);return} 16if(service.cookie.name!==curr_script_category){return} 17curr_script.type='text/javascript';curr_script.removeAttribute("script[data-service]");var src=curr_script.getAttribute('data-src');src&&curr_script.removeAttribute('data-src');var fresh_script=_createNode('script');fresh_script.textContent=curr_script.innerHTML;(function(destination,source){var attributes=source.attributes;var len=attributes.length;for(var i=0;i<len;i++){var attr_name=attributes[i].nodeName;destination.setAttribute(attr_name,source[attr_name]||source.getAttribute(attr_name))}})(fresh_script,curr_script);src?(fresh_script.src=src):(src=curr_script.src);if(src){if(fresh_script.readyState){fresh_script.onreadystatechange=function(){if(fresh_script.readyState==="loaded"||fresh_script.readyState==="complete"){fresh_script.onreadystatechange=null;_loadScripts(scripts,++index)}}}else{fresh_script.onload=function(){fresh_script.onload=null;_loadScripts(scripts,++index)}}} 18curr_script.parentNode.replaceChild(fresh_script,curr_script);if(src)return} 19if(index<scripts.length){_loadScripts(scripts,++index)}} 20_loadScripts(scripts,0);if(typeof embedUrl==="function"){embedUrl(video._id,function(src){})}else if(typeof embedUrl==='string'){var src=embedUrl.replace('{data-id}',video._id);video._title&&(video._iframe.title=video._title);if(src==='undefined'){return!1}
21if(iframeParams){if(iframeParams.substring(0,3)==='ap:'){src+=iframeParams.substring(3)}else{src+='?'+iframeParams}} 22var iframeProps=service.iframe;video._iframe.onload=function(){video._div.classList.add('c-h-b');video._iframe.onload=undefined;iframeProps&&typeof iframeProps.onload==='function'&&iframeProps.onload(video._id,video._iframe)};for(var key in iframeProps){setAttribute(video._iframe,key,iframeProps[key])} 23for(var attr in video._iframeAttributes){setAttribute(video._iframe,attr,video._iframeAttributes[attr])} 24video._iframe.src=src;appendChild(video._div,video._iframe)}};function setAttribute(el,attrKey,attrValue){if(!disallowedProps.includes(attrKey)) 25el.setAttribute(attrKey,attrValue);} 26var removeIframe=function(video){if(video._div.innerHTML.length>=1){if(video._div.id!==""){var divs=video._div.querySelectorAll("#"+video._div.id+" > div");for(let i=0;i<divs.length;i++){if(divs[i].classList.contains("c-nt")===!0||divs[i].classList.contains("c-bg")||divs[i].classList.contains("c-ld")){divs[i].parentNode.classList=[];continue} 27divs[i].style.display="none"}}} 28var selection=video._iframe.parentNode.querySelector("iframe")!==null;if(selection){video._iframe.parentNode.querySelector("iframe").remove()} 29video._hasIframe=!1};function hideNotice(video){video._div.classList.add('c-h-n');video._showNotice=!1};var showNotice=function(video){video._div.classList.remove('c-h-n','c-h-b');video._showNotice=!0};var getCookie=function(a){return(a=doc.cookie.match("(^|;)\\s*"+a+"\\s*=\\s*([^;]+)"))?a.pop():''};var eraseCookie=function(cookie){var path=cookie.path||'/';var domain=cookie.domain||location.hostname;var expires='Expires=Thu, 01 Jan 1970 00:00:01 GMT;';doc.cookie=cookie.name+'=; Path='+path+'; Domain='+domain+'; '+expires};var getKeys=function(obj){return Object.keys(obj)};var preconnect=function(_url){var url=_url.split('://');var protocol=url[0];if(protocol==='http'||protocol==='https'){var domain=(url[1]&&url[1].split('/')[0])||!1;if(domain&&domain!==location.hostname){if(preconnects.indexOf(domain)===-1){var l=createNode('link');l.rel='preconnect';l.href=protocol+'://'+domain;appendChild(doc.head,l);preconnects.push(domain)}}}};function preloadThumbnail(url){if(url&&preloads.indexOf(url)===-1){var l=createNode('link');l.rel='preload';l.as='image';l.href=url;appendChild(doc.head,l);preloads.push(url)}} 30function createNode(type){return doc.createElement(type)} 31function setClassName(el,className){el.className=className} 32function appendChild(parent,child){parent.appendChild(child)} 33var createAllNotices=function(serviceName,service,hidden){var _iframes=iframeDivs[serviceName];var nIframes=_iframes.length;var languages=service.languages;for(var i=0;i<nIframes;i++){(function(i){var video=_iframes[i];if(!video._hasNotice){var loadBtnText=languages[currLang].loadBtn;var noticeText=languages[currLang].notice;var loadAllBtnText=languages[currLang].loadAllBtn;var fragment=doc.createDocumentFragment();var notice=createNode('div');var span=createNode('span');var innerDiv=createNode('p');var load_button=createNode('button');var load_all_button=createNode('button');var notice_text=createNode('span');var ytVideoBackground=createNode('div');var loaderBg=createNode('div');var ytVideoBackgroundInner=createNode('div');var notice_text_container=createNode('div');var buttons=createNode('div');load_button.type=load_all_button.type='button';setClassName(notice_text,'cc-text');setClassName(ytVideoBackgroundInner,'c-bg-i');video._backgroundDiv=ytVideoBackgroundInner;setClassName(loaderBg,'c-ld');if(typeof video._thumbnail!=='string'||video._thumbnail!==''){setClassName(ytVideoBackground,'c-bg')} 34var iframeTitle=video._title;var fragment_2=doc.createDocumentFragment();if(iframeTitle){var title_span=createNode('span');setClassName(title_span,'c-tl');title_span.insertAdjacentHTML('beforeend',iframeTitle);appendChild(fragment_2,title_span)} 35load_button.textContent=loadBtnText;load_all_button.textContent=loadAllBtnText;appendChild(notice_text,fragment_2);notice&¬ice_text.insertAdjacentHTML('beforeend',noticeText||"");appendChild(span,notice_text);setClassName(notice_text_container,'c-t-cn');setClassName(span,'c-n-t');setClassName(innerDiv,'c-n-c');setClassName(notice,'c-nt');setClassName(buttons,'c-n-a');setClassName(load_button,'c-l-b');setClassName(load_all_button,'c-la-b');if(loadBtnText.length>=1){appendChild(buttons,load_button)} 36if(loadAllBtnText.length>=1){appendChild(buttons,load_all_button)} 37appendChild(notice_text_container,span);appendChild(notice_text_container,buttons);appendChild(innerDiv,notice_text_container);appendChild(notice,innerDiv);function showVideo(){hideNotice(video);createIframe(video,service)} 38load_button.addEventListener('click',function(){showVideo()});load_all_button.addEventListener('click',function(){showVideo();api.acceptService(serviceName)});
38appendChild(ytVideoBackground,ytVideoBackgroundInner);appendChild(fragment,notice);(service.thumbnailUrl||video._thumbnail)&&appendChild(fragment,ytVideoBackground);appendChild(fragment,loaderBg);hidden&&video._div.classList.add('c-h-n');appendChild(video._div,fragment);video._hasNotice=!0}})(i)}};var hideAllNotices=function(serviceName,service){var videos=iframeDivs[serviceName];if('IntersectionObserver' in window){var observer=new IntersectionObserver(function(entries){if(stopObserver){observer.disconnect();return} 39for(var i=0;i<entries.length;++i){if(entries[i].isIntersecting){(function(_index){setTimeout(function(){var index=entries[_index].target.dataset.index;createIframe(videos[index],service);hideNotice(videos[index])},_index*50);observer.unobserve(entries[_index].target)})(i)}}});videos.forEach(function(video){if(!video._hasIframe) 40observer.observe(video._div);})}else{for(var i=0;i<videos.length;i++){(function(index){createIframe(videos[i],service);hideNotice(videos[index])})(i)}}};var showAllNotices=function(serviceName,service){var videos=iframeDivs[serviceName];var nDivs=videos.length;for(var i=0;i<nDivs;i++){(function(index){if(videos[i]._hasIframe){if(typeof service.onReject==='function'){service.onReject(videos[i]._iframe);videos[i]._hasIframe=!1}else{removeIframe(videos[i])}} 41showNotice(videos[index])})(i)}};var getValidatedLanguage=function(lang,allLanguages){if(allLanguages.hasOwnProperty(lang)){return lang}else if(getKeys(allLanguages).length>0){if(allLanguages.hasOwnProperty(currLang)){return currLang}else{return getKeys(allLanguages)[0]}}};var getBrowserLang=function(){return navigator.language.slice(0,2).toLowerCase()};var api={acceptService:function(serviceName){stopObserver=!1;if(serviceName==='all'){var length=serviceNames.length;for(var i=0;i<length;i++){var serviceName=serviceNames[i];acceptHelper(serviceName,services[serviceName])}}else if(serviceNames.indexOf(serviceName)>-1){acceptHelper(serviceName,services[serviceName])} 42function acceptHelper(serviceName,service){hideAllNotices(serviceName,service)}},rejectService:function(serviceName){if(serviceName==='all'){stopObserver=!0;var length=serviceNames.length;for(var i=0;i<length;i++){var serviceName=serviceNames[i];rejectHelper(serviceName,services[serviceName])}}else{if(serviceNames.indexOf(serviceName)>-1){rejectHelper(serviceName,services[serviceName])}} 43function rejectHelper(serviceName,service){if(getCookie("cf_cookie").length>1){var obj=JSON.parse(getCookie("cf_cookie"));if(obj.categories.indexOf((service.cookie.name)!=-1)){eraseCookie(service.cookie)}} 44showAllNotices(serviceName,service)}},observe:function(target,callback){var observer=new MutationObserver(function(mutations){mutations.forEach(function(mutation){if(mutation.type==='childList'){setTimeout(function(){callback(target.querySelector('iframe'))},300);observer.disconnect();return}})});if(target.querySelector('iframe')){setTimeout(function(){callback(target.querySelector('iframe'))},300)}else{observer.observe(target,{attributes:!1,childList:!0,subtree:!1})}},run:function(_config){services=_config.services;serviceNames=getKeys(services);var nServices=serviceNames.length;if(nServices===0){return} 45currLang=_config.currLang;var languages=services[serviceNames[0]].languages;if(_config.autoLang===!0){currLang=getValidatedLanguage(getBrowserLang(),languages)}else{if(typeof _config.currLang==='string'){currLang=getValidatedLanguage(_config.currLang,languages)}} 46for(var i=0;i<nServices;i++){var serviceName=serviceNames[i];iframeDivs[serviceName]=[];var foundDivs=doc.querySelectorAll('div[data-service="'+serviceName+'"]');var nDivs=foundDivs.length;if(nDivs===0){continue} 47for(var j=0;j<nDivs;j++){foundDivs[j].dataset.index=j;iframeDivs[serviceName].push(getVideoProp(foundDivs[j]))} 48var currService=services[serviceName];var cookie_name=currService.cookie.name;if(getCookie("cf_cookie").length<=0){createAllNotices(serviceName,currService,!1)}else{var obj=JSON.parse(getCookie("cf_cookie"));if(obj.categories.indexOf(cookie_name)!=-1){createAllNotices(serviceName,currService,!0);hideAllNotices(serviceName,currService)}else{createAllNotices(serviceName,currService,!1)}} 49lazyLoadThumnails(serviceName,currService.thumbnailUrl)}}};var fn_name='iframemanager';
49window[fn_name]=function(){window[fn_name]=undefined;return api}})()
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.