$(document).ready(function () { try { initDebugURLs(); addMpBuffer(); if($.cookie('lazy_load_utils')){ // either the DOM is already fully loaded, or we will add an event listener if (document.readyState === 'complete') { executeScripts(); } else { window.addEventListener('load', executeScripts); } } else{ executeScripts(); } } catch (e) { console.log(e) } }); function executeScripts(){ loadOptimizer(); init_pipa_paywall_utils_js(); // init_smartocto(); -- moved to PIPA handleEpochTVVideos(); addTrackingToLinks(); addTrackingToElements(); addUserDebugPopup(); } function initDebugURLs() { // load dev env if (window.location.href.indexOf('debugPipa=1') > -1) { $.cookie('pipa_debug', 1, {domain: "epochtimes.de", path: '/', expires: 1}); alert('PIPA Test Plan ON'); window.location.href = window.location.href.replace("debugPipa=1", ''); } if (window.location.href.indexOf('debugPipa=0') > -1) { $.removeCookie('pipa_debug', {domain: "epochtimes.de", path: '/'}); alert('PIPA Test Plan OFF'); window.location.href = window.location.href.replace("debugPipa=0", ''); } if (window.location.href.indexOf('agent-portal=open') > -1) { setTimeout(function(){ window.epSubs.showTemplate('agent-portal', 'popup'); }, 3000); } if (window.location.href.indexOf('lazy_load_gtm') > -1) { $.cookie('lazy_load_gtm', 1, {domain: "epochtimes.de", path: '/', expires: 1}); alert('lazy_load_gtm ON'); window.location.href = window.location.href.replace("lazy_load_gtm", ''); } if (window.location.href.indexOf('lazy_load_utils') > -1) { $.cookie('lazy_load_utils', 1, {domain: "epochtimes.de", path: '/', expires: 1}); alert('lazy_load_utils ON'); window.location.href = window.location.href.replace("lazy_load_utils", ''); } } function addMpBuffer(){ /****** mp event buffer *******/ window.mp = { track: function (a) { this.buffer.push(["track", arguments]) }, buffer: [], messageBuffer: [] } window.addEventListener("message", mpMessageBuffer) function mpMessageBuffer(e) { if(window.mp.messageBuffer && e.data.event_id && e.data.event_id.startsWith("mixpanel.")) window.mp.messageBuffer.push(e) else if (!window.mp.messageBuffer) window.removeEventListener("message",mpMessageBuffer) } /******************************/ } function init_pipa_paywall_utils_js() { if ($(window).width() < 768 && window.deET_is_article_website) { $("#logo-header > div.m-only.w-25.pl-3.mr-3.d-flex.justify-content-start").removeClass("w-25 pl-3 mr-3"); $("#logo-header > div.m-only.d-flex.justify-content-start").addClass("eet_mobile_menu pl-1"); $("#logo-header > div.m-only.w-25.ml-3.pr-3.d-flex.justify-content-end").removeClass("w-25 ml-3 pr-3") $("
").insertBefore("#logo-header a#etdAbo"); $("#logo-header a#etdAbo").remove(); } else if($(window).width() < 768 && window.deET_is_epochtv) { $("#top-right").html(""); $("#top-right").append(``); } else if($(window).width() >= 768 && window.deET_is_article_website){ $("#top-right").html(""); $("#top-right").append(` Shop `); $("").insertBefore("#top-right #etdAbo"); $("#top-right #etdAbo").remove(); } $("body").append(` `) window.ep = window.ep || []; // ===== Start configure PIPA parameters ===== let newspaper_prod_plan_id = "59766d56-bdf5-40ba-bb2b-c8b2a7a1a097"; let newspaper_test_plan_id = "71d494b5-d7c0-4890-a592-6e8e629a73fc"; let epochTV_prod_plan_id = "c96924f5-4546-4813-bc94-52e68a9f1c77"; let epochTV_test_plan_id = "9dbac38b-33a1-4cea-b07d-d45a32cd7a60"; let active_plan_id = ""; if($.cookie('pipa_debug')){ active_plan_id = window.deET_is_epochtv ? epochTV_test_plan_id : newspaper_test_plan_id; } else{ active_plan_id = window.deET_is_epochtv ? epochTV_prod_plan_id : newspaper_prod_plan_id; } et_write_log("PIPA planId - ", active_plan_id); window.ep.push( ["config", "epochtimes.de"], // set site_id ["config", "planid", active_plan_id], // set plan_id ["config", "dataDestination", "web_event_data_www_epochtimes_de"], ["url", [window.location.href]], // set the url parameter in 'Pages' of PIPA experiance plan ["tag", window.deET_categories], ["init", function () { // this is the pipa init callback function // set the container and display mode of login bar if($(window).width() < 768 && window.deET_is_article_website){ window.ep.pipaId.show({ displayMode: 'popup', containerSelector: '#logo-header .login_placeholder', // the container for showing the login bar or user info bar }); window.ep.push( ["config", "signin_bar", { template_id: "signin", mode: "inline", selector: "#logo-header .login_placeholder", width: "300", height: "55", url_params: { // data will be set into as the url parameters in template iconcolor: "white", } }], ); } else{ window.ep.pipaId.show({ displayMode: 'popup', containerSelector: '#top-right .login_placeholder', // the container for showing the login bar or user info bar }); window.ep.push( // customize signin_bar template ["config", "signin_bar", { template_id: "signin", mode: "inline", selector: "#top-right .login_placeholder", width: "300", height: "55", url_params: { // data will be set into as the url parameters in template iconcolor: "white", } }], ); } window.epSubs.executePaywallRules(); loadMixPanel(); hidePlusSymbol(); }]); // don't do tracking if user does not want cookies try { if((Cookiebot && Cookiebot.hasOwnProperty("consent") && Cookiebot.consent && Cookiebot.consent.hasOwnProperty("marketing") && Cookiebot.consent.marketing === false) || !$.cookie('epoch_token') || (window.location.href.indexOf('?est=') === -1 && window.location.href.indexOf('&est=') === -1)){ window.ep.push(["config", "noCookie", true]); et_write_log("noCookie NO"); } else{ et_write_log("noCookie YES"); } }catch (e) { et_write_log("noCookie YES"); } // load sdk of PIPA const apiHost = "https://subs.epochbase.eu/lib/api.bundle.js?track=false&useSameDomain=true&execute=false&v=20230824"; $.ajax({ 'url': apiHost, 'dataType': 'script', 'cache': true, 'timeout': 5000 }) .done( function() { $("head").append(``); et_write_log("[LOADING PIPA SUCCESS] hostUrl=", apiHost); }) .fail( function() { et_write_log("[LOADING PIPA ERROR] hostUrl=", apiHost); }); } function loadOptimizer(){ // new code !function(){try{var t,e,r=t=>{try{postMessage(t,window)}catch(e){return e&&25===e.code}return!1},i=[],n=new Proxy({},{get:function(t,e){return function(){if(r(window.optimizerUI)){i.push({method:e,args:arguments});return}return t[e].apply(t,arguments)}}});window.optimizerUI=n,t=function(){window.optimizerUI=optimizerUI,i.forEach(function(t){window.optimizerUI[t.method].apply(window.optimizerUI,t.args)}),i.length=0},(e=document.createElement("script")).src="/load/view.php?a=aHR0cHM6Ly9zZXJ2aWNlcy5lcG9jaC5jbG91ZC9wdWJsaWMtbGFicy9vcHRpbWl6ZXIubWluLmpz",e.onload=t,document.head.appendChild(e)}catch(o){et_write_log(o)}}(); //old code // const apiHost = "https://services.epoch.cloud/public-labs/optimizer.js?v=" + new Date().toISOString().slice(0, 13); // $.ajax({ // 'url': apiHost, // 'dataType': 'script', // 'cache': true, // 'timeout': 5000 // }) // .done( function() { // et_write_log("[LOADING OPTIMIZER SUCCESS] hostUrl=", apiHost); // // }) // .fail( function() { // et_write_log("[LOADING OPTIMIZER ERROR] hostUrl=", apiHost); // }); } function loadMixPanel(){ try { const allUrlParams = window.si.parseURLParams(); const initParams = { SITE_ID: "www.epochtimes.de", MIXPANEL_PROJ: "DE_ET_SANDBOX", } var propsList = { site_id: initParams.SITE_ID, environment: initParams.MIXPANEL_PROJ, region_id: initParams.SITE_ID, clean_url: location.pathname, device_category: window.si.isMobileDevice() ? "mobile" : "desktop", } propsList.publish_date = deET.UTILS.convertStringDateToISO8601(window.eet_publish_date.toString()) || null; // et_write_log("propsList",propsList); let disable_mixpanel_ip = true; if (typeof Cookiebot !== 'undefined' && Cookiebot && Cookiebot.hasOwnProperty("consent") && Cookiebot.consent && Cookiebot.consent.hasOwnProperty("statistics") && Cookiebot.consent.statistics){ disable_mixpanel_ip = false; } const params = { MIXPANEL_PROJ_TOKEN: "c2c42197f93724b0d8084d6e8abd3680", MIXPANEL_PROJ: initParams.MIXPANEL_PROJ, SITE_ID: initParams.SITE_ID, props: propsList, DISABLE_IP: disable_mixpanel_ip, MIXPANEL_API_HOST: "https://mixproxy.epochtimes.de/mp", MIXPANEL_CUSTOM_LIB_URL: 'https://mixproxy.epochtimes.de/mp/lib.min.js', overrideScrollEvents: true, ignore_dnt: true, debug: window.location.search.substring().indexOf('debug') > 0 } window.debugEvent = "mixpanel pre-load"; loadMixpanel(params); window.debugEvent = "mixpanel post-load"; if(window.mixpanel && window.mp){ et_write_log("[LOADING MIXPANEL SUCCESS]"); scrollEventsDE(); } else{ et_write_log("[LOADING MIXPANEL ERROR]"); } }catch (e) { et_write_log("[LOADING MIXPANEL ERROR]", e); } } function convertStringDateToISO8601(dateString){ //stringDate is supposed to have the format 20230420 const year = dateString.slice(0, 4); const month = dateString.slice(4, 6); const day = dateString.slice(6, 8); // Create a new Date object using the extracted parts const date = new Date(year, month - 1, day); // Convert the Date object to an ISO 8601 formatted string return date.toISOString(); } function scrollEventsDE() { window.readScroll = 0 window.addEventListener("scroll", scrollHandler) var pageHeight = getPageHeightDE(); var articleRead = false function scrollHandler(e) { if(window.readScroll < window.scrollY/pageHeight) window.readScroll = window.scrollY/pageHeight if(window.eet_page_type === 'post') { if(!articleRead && window.scrollY > document.querySelector("#etd21-news-content").getBoundingClientRect().top) { if (document.querySelector(".modal.show")) return; if (document.querySelector(".arcanum-widget.widget-overlay")) return; articleRead = true; window.postMessage({event_id: "article.read"}, "*"); } } } function getPageHeightDE() { // et_write_log("getPageHeightFR") if(window.eet_page_type === 'post') { let mainContent = document.querySelector("#etd21-news-content") var height = mainContent.offsetHeight + mainContent.getBoundingClientRect().top } else { var height = document.body.offsetHeight } return height } } window.si = { parseURLParams: function (e) { var i = e ? e.split("?")[1] : window.location.search.slice(1), s = {}; if (i) for (var a = (i = i.split("#")[0]).split("&"), r = 0; r < a.length; r++) { var t = a[r].split("="), l = t[0], p = void 0 === t[1] || t[1]; if (l.match(/\[(\d+)?\]$/)) { var c = l.replace(/\[(\d+)?\]/, ""); if (s[c] || (s[c] = []), l.match(/\[\d+\]$/)) { var n = /\[(\d+)\]/.exec(l)[1]; s[c][n] = p } else s[c].push(p) } else s[l] ? s[l] && "string" == typeof s[l] ? (s[l] = [s[l]], s[l].push(p)) : s[l].push(p) : s[l] = p } for (let elem in s) { s[elem] = decodeURIComponent(s[elem]); } return s }, isMobileDevice: function () { let isMobile = false; if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0, 4))) { isMobile = true; } return isMobile; }, } window.deET = { API: { switchFromOneEurToAnnualPlanConductor: async function(sub_id) { return $.ajax({ type: "POST", url: `https://mkt.epochbase.eu/epochsubs/v2/upgrade_plan`, data: { "siteId": "epochtimes.de", "subscriptionId": sub_id, "planId": "digital_year_exclusive", "couponId": "v1xtcdnq_1" }, success: function (res) { // et_write_log("registerUserto30DayPlan success: ",res); }, error: function (xhr, textStatus, thrownError) { // et_write_log("xhr - ",xhr.status); // et_write_log("textStatus - ",textStatus); // et_write_log("thrownError - ", thrownError); throw new Error(textStatus); } }); }, submitSurveyAnswer: function (data) { let destination = "survey_answers_de"; $.ajax({ method: "POST", type: "POST", url: "https://t1.epochtimes.de/db/si", contentType : "application/json", async: true, timeout: 5000, dataType: "json", data: JSON.stringify({ "destination": destination, "fields": data, }) }); }, validateEmailET: async function(user_email) { return $.ajax({ type: "GET", url: "https://t1.epochtimes.de/fwd/validate/v1?email="+encodeURIComponent(user_email), dataType: "json", contentType: "application/json", success: function(res) { // et_write_log("validateEmailET", res); }, error: function (xhr, textStatus, thrownError) { // et_write_log("xhr - ",xhr.status); // et_write_log("textStatus - ",textStatus); // et_write_log("thrownError - ", thrownError); throw new Error(textStatus); } }) }, validateEmailETLessRestrictions: async function(user_email) { return $.ajax({ type: "GET", url: "https://t1.epochtimes.de/fwd/mail/v1/verify?purpose=bulk&email="+encodeURIComponent(user_email), dataType: "json", contentType: "application/json", success: function(res) { // et_write_log("validateEmailETLessRestrictions", res); }, error: function (xhr, textStatus, thrownError) { // et_write_log("xhr - ",xhr.status); // et_write_log("textStatus - ",textStatus); // et_write_log("thrownError - ", thrownError); throw new Error(textStatus); } }) }, sendWelcomeEmail: async function(user_email) { return $.ajax({ type: "POST", url: `https://subsapi.epoch.cloud/email/send_email_with_channel?channel=express_prod_et_de`, dataType: "json", contentType: "application/json", Accept: "application/json", data: JSON.stringify({ "from": { "fromEmail": "abo@epochtimes.de", "fromName": "The Epoch Times DE" }, "personalizations": [ { "recipient": user_email, "attributes": {} } ], "subject": "Willkommen bei Epoch Times Plus - Lesen Sie den Unterschied!", "templateId": 14, "settings": { "xx": 3, "foo": "bar" } }), success: function (res) { // et_write_log("registerUser success: ",res); }, error: function (xhr, textStatus, thrownError) { // et_write_log("xhr - ",xhr.status); // et_write_log("textStatus - ",textStatus); // et_write_log("thrownError - ", thrownError); throw new Error(textStatus); } }); } }, UTILS: { validateEmailFormat: function(inputText){ var mailformat = /^\w+([\+\.-]*?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/; if(inputText.match(mailformat)) { // et_write_log("Valid email address!"); return true; } return false; }, guid: function(){ let s4 = () => { return Math.floor((1 + Math.random()) * 0x10000) .toString(16) .substring(1); } //return id of format 'aaaaaaaa'-'aaaa'-'aaaa'-'aaaa'-'aaaaaaaaaaaa' return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); }, padTo2Digits: function(num) { return num.toString().padStart(2, '0'); }, getGMTTime: function (date = new Date()) { return [ this.padTo2Digits(date.getUTCHours()), this.padTo2Digits(date.getUTCMinutes()), this.padTo2Digits(date.getUTCSeconds()), ].join(':'); }, convertStringDateToISO8601: function (dateString){ //stringDate is supposed to have the format 20230420 const year = dateString.slice(0, 4); const month = dateString.slice(4, 6); const day = dateString.slice(6, 8); // Create a new Date object using the extracted parts const date = new Date(year, month - 1, day); // Convert the Date object to an ISO 8601 formatted string return date.toISOString(); } } } function hidePlusSymbol() { let userInfo = window.epSubs.getUserInfo(); let user_has_no_access = (window.epSubs.getUserSubStatus().subscriptionType !== "access" && window.epSubs.getUserSubStatus().subscriptionType !== "conductor"); //if user is not logged in or does not have any access if(userInfo.id.length === 0 || user_has_no_access){ $('head').prepend(``) } } function checkIfPipaOrOptimizerHardwallIsOpen(){ let hardwallOpen = 0; let pipaModalOpen = $('.micromodal-slide.is-open'); if (pipaModalOpen.length === 1 && pipaModalOpen.find('.modal__close:visible').length === 0) { hardwallOpen = 1; et_write_log("pipa hardwall open"); } let optimizerModalOpen = $('.arcanum-widget.widget-popup'); if (optimizerModalOpen.length === 1 && optimizerModalOpen.find('.modal-close:visible').length === 0) { hardwallOpen = 1; et_write_log("optimizer hardwall open"); } return hardwallOpen; } function waitForElems (classname, callback){ let checking = setInterval(function(){ if(document.getElementsByClassName(classname)){ clearInterval(checking); callback(); } }, 500); } function handleEpochTVVideos() { try { if (window.eet_page_type === 'post-EpochTV' && window.deET_customer_website){ waitForElems("vjs-tech", function() { var etd_video_player = document.getElementsByClassName("vjs-tech")[0]; var etd_sm_initiated_video = false; etd_video_player.addEventListener("timeupdate", function () { if(this.currentTime >= 5 && this.currentTime < 6) { if (!etd_sm_initiated_video){ etd_sm_initiated_video = true; let video_title = $('#video-content .title.heading').text(); window.tentacles.onVideoPlay( { brandId: '', videoId: window.eet_post_id, title: video_title, pubDate: window.deET_publishDate_ISO ? window.deET_publishDate_ISO : "", uri: 'https://www.epochtimes.de?p=' + window.eet_post_id, channel: 'web' } ); et_write_log("Smartocto Video Request"); window.test_sm_video = { brandId: '', videoId: window.eet_post_id, title: video_title, pubDate: window.deET_publishDate_ISO ? window.deET_publishDate_ISO : "", uri: 'https://www.epochtimes.de?p=' + window.eet_post_id, channel: 'web' }; et_write_log(window.test_sm_video); } } }); }); } } catch (e) { et_write_log(e) } } // This function copies the current URL to the clipboard so that the customer can share the article function copyRefShareUrl() { var shareUrl = window.location.href.split('?')[0] + '?utm_source=ref_share&utm_medium=link_copy'; if (navigator.clipboard) { // modern browsers can use this (it is a Promise Event) return navigator.clipboard.writeText(shareUrl).then(function() { et_write_log("URL has been copied to the clipboard: " + shareUrl); window.postMessage({event_id: "mixpanel.track", event_data: { name: 'Social Share', props: {platform: 'email', widgets: 'copyButton'} } }, "*"); return true; }).catch(function(e) { et_write_log(e); window.postMessage({event_id: "mixpanel.track", event_data: { name: 'Error Log', props: { error_source: 'copy_article_url_for_share', error_name: 'Navigator could not copy', error_message: convertToStrictlyText(e) } } }, "*"); return false; }); }else{ // old browsers need to use this deprecated function try { var shareTextArea = document.createElement("textarea"); shareTextArea.id = "clipboardText"; shareTextArea.style.position = 'absolute'; shareTextArea.style.left = '-9999px'; shareTextArea.value = shareUrl; document.body.appendChild(shareTextArea); shareTextArea.select(); let success_copy = document.execCommand('copy'); document.body.removeChild(shareTextArea); if (success_copy){ window.postMessage({event_id: "mixpanel.track", event_data: { name: 'Social Share', props: {platform: 'email', widgets: 'copyButton'} } }, "*"); return true; }else{ window.postMessage({event_id: "mixpanel.track", event_data: { name: 'Error Log', props: { error_source: 'copy_article_url_for_share', error_name: 'execCommand could not copy', error_message: convertToStrictlyText(e) } } }, "*"); return false; } } catch (e) { et_write_log(e); window.postMessage({event_id: "mixpanel.track", event_data: { name: 'Error Log', props: { error_source: 'copy_article_url_for_share', error_name: 'execCommand could not copy 2', error_message: convertToStrictlyText(e) } } }, "*"); return false; } } } // the function is called like this: // handleCopyRefShareUrl().then(function (result) { // if (result === true) { // et_write_log("Copy worked"); // } else { // et_write_log("Copy failed"); // } // }); async function handleCopyRefShareUrl() { const copyResult = await copyRefShareUrl(); if (copyResult === true) { // Clipboard operation was successful return true; } else { // Clipboard operation failed return false; } } function convertToStrictlyText(param) { const str = "" + param; let result = ''; for (let i = 0; i < str.length; i++) { if (['>', '<', '{', '}', '"', '\\', '\n'].includes(str[i])) { result += '-'; } else { result += str[i]; } } result = result.split('---').join(' - '); return `len(${result.length}): ${result.slice(0, 206)}` + (result.length > 206 ? '...' : ''); } function addTrackingToLinks () { try { //Adds tracking to all anchors within a selected element excluding anchors within other elements (rejects) function addElementAnchorsTracking(selected, trackingCode, rejects, pageType) { let previousValue = ""; let duplicates = 0; //Select elements, find all descendant anchors, exclude anchors within rejects, append tracking code $(selected).find('a').not($(rejects).find('a')).attr('href', function(index, currentValue) { if(typeof currentValue == "string" && currentValue.startsWith('http')) { if (currentValue == previousValue) { ++duplicates; } previousValue = currentValue; let newValue = currentValue + '?ea_src=' + pageType + '&ea_pos=' + trackingCode + (index + 1 - duplicates); return newValue; } }); } //Adds the different tracking codes to all anchors by category function addTrackingByCategory (categoryTrackingPairs, pageType) { categoryTrackingPairs.map(value => { addElementAnchorsTracking(value[0], value[1], value[2], pageType); }); } if (window.eet_page_type === 'home') { let categoriesAndTrackingCodes = [ ['#schlagzeilen-container-desktop', 'col-left&ea_elmt=latest-news&ea_cnt=' , ''], ['#schlagzeilen-container-mobile', 'col-left&ea_elmt=latest-news-mobile&ea_cnt=', ''], ['#tradition-side', 'col-left&ea_elmt=live-tradition&ea_cnt=' , ''], ['#top10', 'col-left&ea_elmt=most-read&ea_cnt=' , ''], ['#gedichtdestages-side', 'col-left&ea_elmt=poems&ea_cnt=' , ''], ['#klassikdestages-side', 'col-left&ea_elmt=classic&ea_cnt=' , ''], ['#etd-hb-1', 'col-middle&ea_elmt=top-article&ea_cnt=' , ''], ['#top-news', 'col-middle&ea_elmt=promote-topic&ea_cnt=' , ''], ['.top-aktuell', 'col-middle&ea_elmt=main-articles&ea_cnt=' , '#epochtv-banner-mobile, #schlagzeilen-container-mobile'], ['#redaktionsempfehlung', 'col-right&ea_elmt=editors-pick&ea_cnt=' , ''], ['#shenyun-side', 'col-right&ea_elmt=shen-yun&ea_cnt=' , ''], ['#term-wrapper-deutschland', 'bottom-categories&ea_elmt=term-deutschland&ea_cnt=' , ''], ['#term-wrapper-ausland', 'bottom-categories&ea_elmt=term-ausland&ea_cnt=' , ''], ['#term-wrapper-meinung', 'bottom-categories&ea_elmt=term-meinung&ea_cnt=' , ''], ['#term-wrapper-wirtschaft', 'bottom-categories&ea_elmt=term-wirtschaft&ea_cnt=' , ''], ['#term-wrapper-gesellschaft', 'bottom-categories&ea_elmt=term-gesellschaft&ea_cnt=' , ''], ['#term-wrapper-china', 'bottom-categories&ea_elmt=term-china&ea_cnt=' , ''], ['#term-wrapper-feuilleton', 'bottom-categories&ea_elmt=term-feuilleton&ea_cnt=' , ''], ['#term-wrapper-gesundheit', 'bottom-categories&ea_elmt=term-gesundheit&ea_cnt=' , ''], ['#term-wrapper-wissen', 'bottom-categories&ea_elmt=term-wissen&ea_cnt=' , ''], ]; addTrackingByCategory(categoriesAndTrackingCodes, 'frontpage'); } if (window.eet_page_type === 'post') { let categoriesAndTrackingCodes = [ ['#top10', 'col-right&ea_elmt=most-read&ea_cnt=' , ''], ['#redaktionsempfehlung', 'col-right&ea_elmt=editors-pick&ea_cnt=' , ''], ['#etd21-news-content .related-articles', 'col-middle&ea_elmt=related-articles&ea_cnt=', ''], ['#epochtv_under_article', 'col-middle&ea_elmt=epochtv&ea_cnt=' , ''], ['#health_under_article', 'col-middle&ea_elmt=epochtv&ea_cnt=' , ''], ]; addTrackingByCategory(categoriesAndTrackingCodes, 'article'); } }catch (e) { et_write_log(e); } } function addTrackingToElements(){ try { $('a[data-elements_detail]').click(function(event) { try { let data_elements = $(this).attr("data-elements"); let data_elements_detail = $(this).attr("data-elements_detail"); window.mp.track('Element Link Clicked', { elements: data_elements, elements_category: "ArticlePage", elements_type: "link-sharing", elements_detail: data_elements_detail }); }catch (e) { et_write_log(e); } }); }catch (e) { et_write_log(e); } } async function addUserDebugPopup () { try { if (window.location.href.indexOf('debug_customer') !== -1) { await new Promise((resolve) => { setTimeout(() => { function detectUserBrowser () { //https://stackoverflow.com/questions/5916900/how-can-you-detect-the-version-of-a-browser class Browser { constructor() { this.spec_string = navigator.userAgent; this.name = this.get_name(); this.version = this.get_version(); } get_name() { var spec_string = this.spec_string; var matches = spec_string.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || []; // Work with the matches. matches = matches[2] ? [matches[1], matches[2]] : [navigator.appName, navigator.appVersion, '-?']; // Trident. if (/trident/i.test(matches[1])) { var temp = /\brv[ :]+(\d+)/g.exec(spec_string) || []; return 'IE'; } // Chrome. if (matches[1] === 'Chrome') { var temp = spec_string.match(/\bOPR|Edge\/(\d+)/); if (temp != null) { return 'Opera'; } } if ((temp = spec_string.match(/version\/(\d+)/i)) != null) { matches.splice(1, 1, temp[1]); } var name = matches[0]; return name; } get_version=function(){ var spec_string=this.spec_string; var matches=spec_string.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || []; // Work with the matches. matches=matches[2]? [matches[1], matches[2]]: [navigator.appName, navigator.appVersion, '-?']; // Trident. if(/trident/i.test(matches[1])){ var temp=/\brv[ :]+(\d+)/g.exec(spec_string) || []; var version=(temp[1]||''); return version; } // Chrome. if(matches[1]==='Chrome'){ var temp=spec_string.match(/\bOPR|Edge\/(\d+)/) var version=temp[1]; if(temp!=null) {return version;} } if((temp=spec_string.match(/version\/(\d+)/i))!=null){ matches.splice(1,1,temp[1]); } var version=matches[1]; return version; }; }; var browser=new Browser(); return browser.name + ' ' + browser.version; } function detectUserOS () { //https://stackoverflow.com/questions/9514179/how-to-find-the-operating-system-details-using-javascript //OS version detection can be found in the link as well - it is complicated though let userAgent = window.navigator.userAgent, platform = window.navigator.platform, macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'], windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'], iosPlatforms = ['iPhone', 'iPad', 'iPod'], os = null; if (macosPlatforms.indexOf(platform) !== -1) { os = 'Mac OS'; } else if (iosPlatforms.indexOf(platform) !== -1) { os = 'iOS'; } else if (windowsPlatforms.indexOf(platform) !== -1) { os = 'Windows'; } else if (/Android/.test(userAgent)) { os = 'Android'; } else if (!os && /Linux/.test(platform)) { os = 'Linux'; } return os; } function getDebugData () { const fullURL = 'URL: ' + window.location.href + '