1/** 2 * This script renders the necessary Chartbeat script, that we in the exo-frontend are referencing in the CMP. 3 * 4 * Please note: For this to work in EXO, you need to build the entire EscenicJava project and deploy it. 5 * This means that the '-Dskip.frontend=true' flag should not be part of the escenic deployment terminal command. 6 */ 7let chartbeatCurrentSection = location.pathname.length === 1 ? 'Forsiden' : location.pathname.split('/')[1]; 8let useChartBeat = true; 9 10// This should always be politiken.dk - but if we need to test Charbeat on a dev-server, we need hardcode it to f.eks "dev107.politiken.dk" for us to be able to test 11let chartbeatDomain = 'politiken.dk'; 12 13const polContext = window.polContext__ 14if (polContext && polContext.page && polContext.page.sectionHierarchy !== 'undefined') { // on frontpage, this is an empty string (falsy), so we would never reach the switch. This fixes that. 15 chartbeatCurrentSection = window.polContext__.page.sectionHierarchy.split('|').join(','); 16 17 switch (polContext.page.subbrand) { 18 case 'skolemonitor': 19 chartbeatDomain = 'skolemonitor.dk'; 20 break; 21 case 'borneavisen': 22 chartbeatDomain = 'borneavisen.dk'; 23 useChartBeat = false; 24 break; 25 case 'byrummonitor': 26 chartbeatDomain = 'byrummonitor.dk'; 27 break; 28 case 'politikenhistorie': 29 chartbeatDomain = 'politikenhistorie.dk'; 30 break; 31 case 'advertorial': 32 chartbeatDomain = 'politikenadvertorial.dk'; 33 break; 34 case 'politikenmad': 35 chartbeatDomain = 'politikenmad.dk'; 36 break; 37 case 'sundhedsmonitor': 38 chartbeatDomain = 'sundhedsmonitor.dk'; 39 break; 40 case 'klimamonitor': 41 chartbeatDomain = 'klimamonitor.dk'; 42 break; 43 case 'idraetsmonitor': 44 chartbeatDomain = 'idraetsmonitor.dk'; 45 break; 46 case 'kulturmonitor': 47 chartbeatDomain = 'kulturmonitor.dk'; 48 break; 49 case 'turistmonitor': 50 chartbeatDomain = 'turistmonitor.dk'; 51 break; 52 case 'seniormonitor': 53 chartbeatDomain = 'seniormonitor.dk'; 54 break; 55 case 'socialmonitor': 56 chartbeatDomain = 'socialmonitor.dk'; 57 break; 58 } 59} 60 61if (useChartBeat) { 62 var _sf_async_config = _sf_async_config || { // need to be 'var' due to scoping, which isn't working with 'let' or 'const' 63 uid: 38516, 64 domain: chartbeatDomain, 65 sections: chartbeatCurrentSection, 66 flickerControl: false, 67 }; 68 69 const userTypes = { 70 'subscriber': 'paid', 71 'registered': 'lgdin', 72 'anonymous': 'anon' 73 }; 74 75 _cbq = window._cbq = (window._cbq || []); 76 if (polContext && polContext.user && polContext.user.type) { 77 _cbq.push(['_acct', userTypes[polContext__.user.type]]); 78 } 79 80 81 (function () { 82 window._sf_endpt = (new Date()).getTime(); 83 const chartbeatScript = document.createElement('script'); 84 chartbeatScript.setAttribute('language', 'javascript'); 85 chartbeatScript.setAttribute('type', 'text/javascript'); 86 chartbeatScript.setAttribute('src', '//static.chartbeat.com/js/chartbeat.js'); 87 document.body.appendChild(chartbeatScript); 88 })(); 89 90 (function () { 91 const charbeatMabScript = document.createElement('script'); 92 charbeatMabScript.type = 'text/javascript'; 93 charbeatMabScript.async = true; 94 charbeatMabScript.src = '//static.chartbeat.com/js/chartbeat_mab.js'; 95 const s = document.getElementsByTagName('script')[0]; 96 s.parentNode.insertBefore(charbeatMabScript, s); 97 })(); 98}
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.