(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.d21_widgetStart = function(){ // Add basket if (window.d21 === undefined || (window.d21 !== undefined && window.d21 != null && window.d21['Version'] != undefined)) { var basketJS = document.createElement("script"); basketJS.src = "//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/2fb06488-5978-4935-b66d-ea122248b7d9/" + browserLang + '/False' + (hasRequireJs ? '?v=1.1&b=4.1' : '?b=4.1'); d21SdkJS.async = true; d21SdkJS.type= "text/javascript"; document.body.appendChild(d21SdkJS); } window.addEventListener("load", function(){ d21_widgetStart(); }); })();