var spendinoJquery; var thisPageUsingOtherJSLibrary = false; if (typeof jQuery == 'undefined') { if (typeof $ == 'function') { thisPageUsingOtherJSLibrary = true; } function getScript(url, success) { var script = document.createElement('script'); script.src = url; var head = document.getElementsByTagName('head')[0], done = false; script.onload = script.onreadystatechange = function() { if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) { done = true; success(); script.onload = script.onreadystatechange = null; head.removeChild(script); }; }; head.appendChild(script); }; getScript('https://api.spendino.de/admanager/js/jquery.min.js', function() { if (typeof jQuery=='undefined') { // Uups } else { if (thisPageUsingOtherJSLibrary) { spendinoJquery = jQuery.noConflict(false); } else { spendinoJquery = jQuery.noConflict(true); } } }); } else { // jQuery was already loaded spendinoJquery = jQuery; }; document.write(''); var urlParam = function(name){ var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(location.search); if (results == null){ return null; } else { return decodeURI(results[1]) || 0; } }; var hash = window.location.hash; if( hash ) { //todo: hash bei - splitten und wert als named. wert muss key:value sein $namedParams =hash.substring(1).replace('-','/'); var iframe = window.document.getElementsByName('spendinoWidget'); if( typeof iframe != 'undefined' ) { if (iframe[0].src.indexOf('?') > -1) { var lTmp = iframe[0].src; iframe[0].src = lTmp.split('?')[0] + '/' + $namedParams+'?' + lTmp.split('?')[1]; } else { iframe[0].src = iframe[0].src + '/' + $namedParams; } } } if (location.search !== '') { // var spendinoParentUrlParams = new URLSearchParams(location.search); // var spendinoParentUrlParams = {}; var spendinoQueryParams = ''; if(null != urlParam('xcustomcode')) { if(spendinoQueryParams != '') { spendinoQueryParams = spendinoQueryParams+'&'; } spendinoQueryParams = spendinoQueryParams + 'xcustomcode=' +urlParam('xcustomcode'); } else if(null != urlParam('xwerbecode') || null != urlParam('werbecode')) { if(spendinoQueryParams != '') { spendinoQueryParams = spendinoQueryParams+'&'; } var werbecode = null != urlParam('werbecode') ? urlParam('werbecode') : urlParam('xwerbecode'); spendinoQueryParams = spendinoQueryParams + 'xcustomcode=' + werbecode; } if(null != urlParam('xcustomtitle') || null != urlParam('customtitle') || null != urlParam('projektname')|| null != urlParam('xwerbecodetitel')|| null != urlParam('werbecodetitel')) { if(spendinoQueryParams != '') { spendinoQueryParams = spendinoQueryParams+'&'; } var customtitle = null != urlParam('projektname') ? urlParam('projektname') : ''; customtitle = null != urlParam('werbecodetitel') ? urlParam('werbecodetitel') : customtitle; customtitle = null != urlParam('werbecodetitle') ? urlParam('werbecodetitle') : customtitle; customtitle = null != urlParam('xwerbecodetitle') ? urlParam('xwerbecodetitle') : customtitle; customtitle = null != urlParam('xwerbecodetitel') ? urlParam('xwerbecodetitel') : customtitle; customtitle = null != urlParam('customtitle') ? urlParam('customtitle') : customtitle; customtitle = null != urlParam('xcustomtitle') ? urlParam('xcustomtitle') : customtitle; spendinoQueryParams = spendinoQueryParams + 'xcustomtitle=' + customtitle; } if(spendinoQueryParams != '') { var siframe = window.document.getElementsByName('spendinoWidget'); if( typeof siframe != 'undefined' ) { if (siframe[0].src.indexOf('?') > -1) { siframe[0].src = siframe[0].src + '&' + spendinoQueryParams; } else { siframe[0].src = siframe[0].src + '?' + spendinoQueryParams; } } } } function setSpendinoParam(param, value) { var mFrame = window.document.getElementsByName('spendinoWidget')[0]; mFrame.contentWindow.postMessage(JSON.stringify(["setParam",param,value,"*"]), '*'); } function getSpendinoParam(param, callback) { var mFrame = window.document.getElementsByName('spendinoWidget')[0]; mFrame.contentWindow.postMessage(JSON.stringify(["getParam",param,callback,"*"]), '*'); } var spendinoIframeId = "spendinoForm1801"; var spendinoEventListeners = spendinoEventListeners || false; if( spendinoEventListeners === false ) { window.addEventListener("resize", resizeSpendino ); // window.addEventListener("scrollTop", scrollTopSpendino ); spendinoEventListeners = true; } //var sFrame; var neededHeight; var sWidth = ''; function scrollTopSpendino() { spendinoJquery('html, body').animate({ scrollTop:spendinoJquery('#'+spendinoIframeId).offset().top },'slow'); } function resizeSpendino() { var iframe = document.getElementById( spendinoIframeId ); if( iframe === null || typeof iframe === 'undefined' ) { return; } iframe.width = "100%"; var iframeParent = iframe.parentNode; var iframeWidth = iframeParent.offsetWidth+''; if (sWidth != iframeWidth) { sWidth = iframeWidth; if (iframeWidth.indexOf('px') !== -1) { iframeWidth = parseInt(iframeWidth); } var iframeHeight = 580; var ratio = 1; if (typeof window.devicePixelRatio !== 'undefined') { ratio = window.devicePixelRatio; } if (iframeWidth.indexOf('%') !== -1 || iframeWidth > parseInt('532')) { iframeWidth = '532'; } else if (iframeWidth < 401) { iframeHeight = 1900; } iframe.width = (iframeWidth) + "px"; iframe.height = (iframeHeight) + "px"; iframe.setAttribute('style', 'height:' + iframe.height + ' !important;width:' + iframe.width + ' !important'); } } function scrollToSpendino(element, to, duration) { var top = spendinoJquery(window).scrollTop(); if (duration <= 0) return; var difference = to - top; var perTick = difference / duration * 10; setTimeout(function() { spendinoJquery(window).scrollTop(top+perTick); if (spendinoJquery(window).scrollTop() === to) return; scrollToSpendino(element, to, duration - 10); }, 10); } function getPositionSpendino( el ) { var xPosition = 0; var yPosition = 0; while(el) { xPosition += el.offsetLeft; yPosition += el.offsetTop; el = el.offsetParent; } return { x: xPosition, y: yPosition }; } function openCCPopUp(url){ WPP.embeddedPayUrl(url); } window.addEventListener('message', function(e) { var eventName = e.data[0]; var data = e.data[1]; var iframeId = e.data[2]; if( iframeId !== 'spendinoForm1801' ) { return; } var iframe = document.getElementById( iframeId ); if( iframe === null || typeof iframe === 'undefined' ) { return; } switch (eventName) { case 'setHeight': // iframe.style.height = data + 'px'; // iframe.width = (iframeWidth) + "px"; iframe.height = data + "px"; iframe.setAttribute( 'style', 'height:' + data + 'px !important;width:' + iframe.width + ' !important' ); break; case 'scrollTo': var pos = getPositionSpendino(iframe); if (pos.x < 10) { pos.x = 10; } scrollToSpendino(document.getElementsByTagName('body'), pos.y - 100 + data, 100); // scrollToSpendino(document.getElementsByTagName('body'), pos.y - 100 + data, 100); // scrollToSpendino(document.documentElement.scrollTop, pos.y - 100 + data, 100); break; case 'location': iframe.contentWindow.postMessage(JSON.stringify(['location', document.location]), '*'); break; case 'scrollTop': scrollTopSpendino(); break; case 'loadComplete': if (typeof(spendinoOnLoad) == 'function') { spendinoOnLoad(); } spendinoLoadingAnimation('stop'); // $('#spendinoIframeLoader').addClass('hide'); break; case 'getParam' : var callback = e.data[1]['callback']; window[callback](e.data[1]['param'],e.data[1]['value']); break; case 'setCCPaymentUrl': spendinoJquery.getScript('https://wpp.wirecard.com/loader/paymentPage.js', function () { openCCPopUp(data); setTimeout(function(){ spendinoJquery('#wirecard-hpp-container').css('z-index','110050'); },500); }); break; case 'startLoadingAnimation': spendinoLoadingAnimation('start'); break; case 'stopLoadingAnimation': spendinoLoadingAnimation('stop'); break; } }, false); function spendinoLoadingAnimation( action = '') { var spendinoIframeLoader = document.getElementById( 'spendinoIframeLoader' ); if( spendinoIframeLoader !== null && typeof spendinoIframeLoader !== 'undefined' ) { switch (action) { case 'start': spendinoIframeLoader.classList.remove('hide'); spendinoIframeLoader.classList.remove('spinnerhide'); break; case 'stop': spendinoIframeLoader.classList.add('hide'); spendinoIframeLoader.classList.add('spinnerhide'); break; } } }