var d21_ibe_api_host = 'https://ibe-api-v4-default.dirs21.de'; (function(){ // var isValidLanguage = function(lang){ var validLanguages = ['de','en','fr', 'es','it','ru','zh','nl']; lang = lang != null ? lang.toLowerCase() : lang; var result = false; if(lang == null) return result; for(var i = 0; i < validLanguages.length; i++){ if(lang.indexOf(validLanguages[i]) >= 0 && lang.length <= 5){ result = true; } } return result; }; window.d21LogTime = function (key) { if (window.d21_time) { console.log(key, new Date() - window.d21_time); } } window.d21_widgetStart = function(){ if (window.d21_sdk_init) return; window.d21_sdk_init = true; // Add basket if (window.d21 === undefined || (window.d21 !== undefined && window.d21 != null && window.d21['Version'] != undefined)) { var basketJS = document.createElement("script"); basketJS.src = "https://cdnjs.cloudflare.com/ajax/libs/basket.js/0.5.2/basket.full.min.js"; document.body.appendChild(basketJS); } // detect language // 1. by html-tag var htmlTagLang = document.getElementsByTagName("Html")[0].getAttribute("lang"); var browserLang = htmlTagLang && htmlTagLang.length >= 2 ? htmlTagLang.substring(0,2).toLowerCase() : undefined; // 2. by meta-tag if(browserLang == undefined) { var metas = Array.prototype.slice.call(document.getElementsByTagName('meta')); metas.forEach(function(m,index){ if(browserLang == undefined) browserLang = isValidLanguage(m.getAttribute('content')) ? m.getAttribute('content').substring(0,2).toLowerCase() : undefined; }); } // 3. default value de-DE if(browserLang != undefined) { browserLang = browserLang + '-' + browserLang.toUpperCase(); } else { browserLang = "de-DE"; } // Write main script with detected language var hasRequireJs = window.d21 !== undefined && window.d21 !== null && window.d21['version'] !== undefined; var d21SdkJS = document.createElement("script"); d21SdkJS.src = "https://js-sdk.dirs21.de" + "/widgets/b2bf9729-ef0e-48af-935c-efbd90f2d719/" + browserLang + '/False' + (hasRequireJs ? '?v=1.1&b=4.1' : '?b=4.1'); d21SdkJS.async = true; d21SdkJS.type= "text/javascript"; document.body.appendChild(d21SdkJS); window.d21LogTime("d21_widgets_start"); } window.addEventListener("DOMContentLoaded", function d21StartSDK(){ window.removeEventListener("DOMContentLoaded", d21StartSDK, false); d21_widgetStart(); }); window.addEventListener("load", function d21StartSDK(){ window.removeEventListener("load", d21StartSDK, false); d21_widgetStart(); }); })();