1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288 |
- /*jslint browser: true, evil: true */
- // define correct path for files inclusion
- var scripts = document.getElementsByTagName('script'),
- path = scripts[scripts.length - 1].src.split('?')[0],
- cdn = path.split('/').slice(0, -1).join('/') + '/',
- alreadyLaunch = (alreadyLaunch === undefined) ? 0 : alreadyLaunch,
- tarteaucitronForceLanguage = (tarteaucitronForceLanguage === undefined) ? '' : tarteaucitronForceLanguage,
- tarteaucitronProLoadServices,
- tarteaucitronNoAdBlocker = false;
- var tarteaucitron = {
- "version": 323,
- "cdn": cdn,
- "user": {},
- "lang": {},
- "services": {},
- "added": [],
- "idprocessed": [],
- "state": [],
- "launch": [],
- "parameters": {},
- "isAjax": false,
- "reloadThePage": false,
- "init": function (params) {
- "use strict";
- var origOpen;
- tarteaucitron.parameters = params;
- if (alreadyLaunch === 0) {
- alreadyLaunch = 1;
- if (window.addEventListener) {
- window.addEventListener("load", function () {
- tarteaucitron.load();
- tarteaucitron.fallback(['tarteaucitronOpenPanel'], function (elem) {
- elem.addEventListener("click", function () {
- tarteaucitron.userInterface.openPanel();
- }, false);
- }, true);
- }, false);
- /*
- window.addEventListener("scroll", function () {
- return false;
- var scrollPos = window.pageYOffset || document.documentElement.scrollTop,
- heightPosition;
- if (document.getElementById('tarteaucitronAlertBig') !== null && !tarteaucitron.highPrivacy) {
- if (document.getElementById('tarteaucitronAlertBig').style.display === 'block') {
- heightPosition = document.getElementById('tarteaucitronAlertBig').offsetHeight + 'px';
- if (scrollPos > (screen.height * 2)) {
- // tarteaucitron.userInterface.respondAll(true);
- tarteaucitron.userInterface.respondAll(false);
- } else if (scrollPos > (screen.height / 2)) {
- document.getElementById('tarteaucitronDisclaimerAlert').innerHTML = '<b>' + tarteaucitron.lang.alertBigScroll + '</b> ' + tarteaucitron.lang.alertBig;
- }
- if (tarteaucitron.orientation === 'top') {
- document.getElementById('tarteaucitronPercentage').style.top = heightPosition;
- } else {
- document.getElementById('tarteaucitronPercentage').style.bottom = heightPosition;
- }
- document.getElementById('tarteaucitronPercentage').style.width = ((100 / (screen.height * 2)) * scrollPos) + '%';
- }
- }
- }, false);
- */
- window.addEventListener("keydown", function (evt) {
- if (evt.keyCode === 27) {
- tarteaucitron.userInterface.closePanel();
- }
- }, false);
- window.addEventListener("hashchange", function () {
- if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
- tarteaucitron.userInterface.openPanel();
- }
- }, false);
- window.addEventListener("resize", function () {
- if (document.getElementById('tarteaucitron') !== null) {
- if (document.getElementById('tarteaucitron').style.display === 'block') {
- tarteaucitron.userInterface.jsSizing('main');
- }
- }
- if (document.getElementById('tarteaucitronCookiesListContainer') !== null) {
- if (document.getElementById('tarteaucitronCookiesListContainer').style.display === 'block') {
- tarteaucitron.userInterface.jsSizing('cookie');
- }
- }
- }, false);
- } else {
- window.attachEvent("onload", function () {
- tarteaucitron.load();
- tarteaucitron.fallback(['tarteaucitronOpenPanel'], function (elem) {
- elem.attachEvent("onclick", function () {
- tarteaucitron.userInterface.openPanel();
- });
- }, true);
- });
- window.attachEvent("onscroll", function () {
- return false;
- var scrollPos = window.pageYOffset || document.documentElement.scrollTop,
- heightPosition;
- if (document.getElementById('tarteaucitronAlertBig') !== null && !tarteaucitron.highPrivacy) {
- if (document.getElementById('tarteaucitronAlertBig').style.display === 'block') {
- heightPosition = document.getElementById('tarteaucitronAlertBig').offsetHeight + 'px';
- if (scrollPos > (screen.height * 2)) {
- // tarteaucitron.userInterface.respondAll(true);
- tarteaucitron.userInterface.respondAll(false);//non
- } else if (scrollPos > (screen.height / 2)) {
- document.getElementById('tarteaucitronDisclaimerAlert').innerHTML = '<b>' + tarteaucitron.lang.alertBigScroll + '</b> ' + tarteaucitron.lang.alertBig;
- }
- if (tarteaucitron.orientation === 'top') {
- document.getElementById('tarteaucitronPercentage').style.top = heightPosition;
- } else {
- document.getElementById('tarteaucitronPercentage').style.bottom = heightPosition;
- }
- document.getElementById('tarteaucitronPercentage').style.width = ((100 / (screen.height * 2)) * scrollPos) + '%';
- }
- }
- });
- window.attachEvent("onkeydown", function (evt) {
- if (evt.keyCode === 27) {
- tarteaucitron.userInterface.closePanel();
- }
- });
- window.attachEvent("onhashchange", function () {
- if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
- tarteaucitron.userInterface.openPanel();
- }
- });
- window.attachEvent("onresize", function () {
- if (document.getElementById('tarteaucitron') !== null) {
- if (document.getElementById('tarteaucitron').style.display === 'block') {
- tarteaucitron.userInterface.jsSizing('main');
- }
- }
- if (document.getElementById('tarteaucitronCookiesListContainer') !== null) {
- if (document.getElementById('tarteaucitronCookiesListContainer').style.display === 'block') {
- tarteaucitron.userInterface.jsSizing('cookie');
- }
- }
- });
- }
- if (typeof XMLHttpRequest !== 'undefined') {
- origOpen = XMLHttpRequest.prototype.open;
- XMLHttpRequest.prototype.open = function () {
- if (window.addEventListener) {
- this.addEventListener("load", function () {
- if (typeof tarteaucitronProLoadServices === 'function') {
- tarteaucitronProLoadServices();
- }
- }, false);
- } else if (typeof this.attachEvent !== 'undefined') {
- this.attachEvent("onload", function () {
- if (typeof tarteaucitronProLoadServices === 'function') {
- tarteaucitronProLoadServices();
- }
- });
- } else {
- if (typeof tarteaucitronProLoadServices === 'function') {
- setTimeout(tarteaucitronProLoadServices, 1000);
- }
- }
- try {
- origOpen.apply(this, arguments);
- } catch (err) {}
- };
- }
- }
- },
- "load": function () {
- "use strict";
- var cdn = tarteaucitron.cdn,
- language = tarteaucitron.getLanguage(),
- pathToLang = cdn + 'lang/tarteaucitron.' + language + '.js?v=' + tarteaucitron.version,
- pathToServices = cdn + 'tarteaucitron.services.js?v=' + tarteaucitron.version,
- linkElement = document.createElement('link'),
- defaults = {
- "adblocker": false,
- "hashtag": '#tarteaucitron',
- "highPrivacy": false,
- "orientation": "top",
- "removeCredit": false,
- "showAlertSmall": true,
- "cookieslist": true
- },
- params = tarteaucitron.parameters;
- // Step 0: get params
- if (params !== undefined) {
- tarteaucitron.extend(defaults, params);
- }
- // global
- tarteaucitron.orientation = defaults.orientation;
- tarteaucitron.hashtag = defaults.hashtag;
- tarteaucitron.highPrivacy = defaults.highPrivacy;
- // Step 1: load css
- linkElement.rel = 'stylesheet';
- linkElement.type = 'text/css';
- var turl = document.domain;
- // linkElement.href = cdn + 'css/tarteaucitron.css?v=' + tarteaucitron.version;
- linkElement.href = '/html/xxx/tarteaucitron/css/tarteaucitron.css?v=' + tarteaucitron.version;
- document.getElementsByTagName('head')[0].appendChild(linkElement);
- // Step 2: load language and services
- tarteaucitron.addScript(pathToLang, '', function () {
- tarteaucitron.addScript(pathToServices, '', function () {
- var body = document.body,
- div = document.createElement('div'),
- html = '',
- index,
- orientation = 'Top',
- cat = ['ads', 'analytic', 'api', 'comment', 'social', 'support', 'video'],
- i;
- cat = cat.sort(function (a, b) {
- if (tarteaucitron.lang[a].title > tarteaucitron.lang[b].title) { return 1; }
- if (tarteaucitron.lang[a].title < tarteaucitron.lang[b].title) { return -1; }
- return 0;
- });
- // Step 3: prepare the html
- html += '<div id="tarteaucitronPremium"></div>';
- html += '<div id="tarteaucitronBack" onclick="tarteaucitron.userInterface.closePanel();"></div>';
- html += '<div id="tarteaucitron">';
- html += ' <div id="tarteaucitronClosePanel" onclick="tarteaucitron.userInterface.closePanel();">';
- html += ' ' + tarteaucitron.lang.close;
- html += ' </div>';
- html += ' <div id="tarteaucitronServices">';
- html += ' <div class="tarteaucitronLine tarteaucitronMainLine" id="tarteaucitronMainLineOffset">';
- html += ' <div class="tarteaucitronName">';
- html += ' <b><a href="#" onclick="tarteaucitron.userInterface.toggle(\'tarteaucitronInfo\', \'tarteaucitronInfoBox\');return false">✛</a> ' + tarteaucitron.lang.all + '</b>';
- html += ' </div>';
- html += ' <div class="tarteaucitronAsk" id="tarteaucitronScrollbarAdjust">';
- html += ' <div id="tarteaucitronAllAllowed" class="tarteaucitronAllow" onclick="tarteaucitron.userInterface.respondAll(true);">';
- html += ' ✓ ' + tarteaucitron.lang.allow;
- html += ' </div> ';
- html += ' <div id="tarteaucitronAllDenied" class="tarteaucitronDeny" onclick="tarteaucitron.userInterface.respondAll(false);">';
- html += ' ✗ ' + tarteaucitron.lang.deny;
- html += ' </div>';
- html += ' </div>';
- html += ' </div>';
- html += ' <div id="tarteaucitronInfo" class="tarteaucitronInfoBox">';
- html += ' ' + tarteaucitron.lang.disclaimer;
- if (defaults.removeCredit === false) {
- html += ' <br/><br/>';
- html += ' <a href="https://opt-out.ferank.eu/" rel="nofollow" target="_blank">' + tarteaucitron.lang.credit + '</a>';
- }
- html += ' </div>';
- html += ' <div class="tarteaucitronBorder" id="tarteaucitronScrollbarParent">';
- html += ' <div class="clear"></div>';
- for (i = 0; i < cat.length; i += 1) {
- html += ' <div id="tarteaucitronServicesTitle_' + cat[i] + '" class="tarteaucitronHidden">';
- html += ' <div class="tarteaucitronTitle">';
- html += ' <a href="#" onclick="tarteaucitron.userInterface.toggle(\'tarteaucitronDetails' + cat[i] + '\', \'tarteaucitronInfoBox\');return false">✛</a> ' + tarteaucitron.lang[cat[i]].title;
- html += ' </div>';
- html += ' <div id="tarteaucitronDetails' + cat[i] + '" class="tarteaucitronDetails tarteaucitronInfoBox">';
- html += ' ' + tarteaucitron.lang[cat[i]].details;
- html += ' </div>';
- html += ' </div>';
- html += ' <div id="tarteaucitronServices_' + cat[i] + '"></div>';
- }
- html += ' <div class="tarteaucitronHidden" id="tarteaucitronScrollbarChild" style="height:20px;display:block"></div>';
- html += ' </div>';
- html += ' </div>';
- html += '</div>';
- if (defaults.orientation === 'bottom') {
- orientation = 'Bottom';
- }
- if (defaults.highPrivacy) {
- html += '<div id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + '">';
- html += ' <span id="tarteaucitronDisclaimerAlert">';
- html += ' ' + tarteaucitron.lang.alertBigPrivacy;
- html += ' </span>';
- html += ' <span id="tarteaucitronPersonalize" onclick="tarteaucitron.userInterface.openPanel();">';
- html += ' ' + tarteaucitron.lang.personalize;
- html += ' </span>';
- html += '</div>';
- } else {
- html += '<div style="background:white;text-align:left" id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + '"><div class="wrap">';
- html += ' <span id="tarteaucitronDisclaimerAlert">';
- var gdprshow = document.getElementById("gdprshow") == null ? '<p class="title"><strong>Cookies:</strong></p><p>本網站使用瀏覽器紀錄 (Cookies)來提供您最好的使用體驗,我們使用的 Cookies 也包括了第三方 Cookies。相關資訊請瀏覽我們的隱私權與 Cookies 政策。<br>如果您選擇繼續瀏覽或關閉這個提示,便表示您已接受我們的網站使用條款。</p>' : document.getElementById("gdprshow").innerHTML;
- html += ' ' + gdprshow ; //desc content
- html += ' </span>';
- html += ' <span id="tarteaucitronPersonalize" class="btn btn-primary" onclick="tarteaucitron.userInterface.respondAll(true);">';
- var gdprshowbtn = document.getElementById("gdprshowbtn") == null ? '我同意' : document.getElementById("gdprshowbtn").innerHTML;
- html += ' ' + gdprshowbtn ; //button
- html += ' </span>';
- //html += ' <span id="tarteaucitronCloseAlert" onclick="tarteaucitron.userInterface.openPanel();">';
- //html += ' ' + tarteaucitron.lang.personalize;
- //html += ' </span>';
- html += '</div>';
- html += '</div><div id="tarteaucitronPercentage"></div>';
- }
- tarteaucitron.addScript(tarteaucitron.cdn + 'advertising.js?v=' + tarteaucitron.version, '', function () {
- if (tarteaucitronNoAdBlocker === true || defaults.adblocker === false) {
- div.id = 'tarteaucitronRoot';
- body.appendChild(div, body);
- div.innerHTML = html;
- if (tarteaucitron.job !== undefined) {
- tarteaucitron.job = tarteaucitron.cleanArray(tarteaucitron.job);
- for (index = 0; index < tarteaucitron.job.length; index += 1) {
- //console.log('## addService : ' + tarteaucitron.job[index]);
- tarteaucitron.addService(tarteaucitron.job[index]);
- }
- }
- tarteaucitron.isAjax = true;
- tarteaucitron.job.push = function (id) {
- // ie <9 hack
- if (typeof tarteaucitron.job.indexOf === 'undefined') {
- tarteaucitron.job.indexOf = function (obj, start) {
- var i,
- j = this.length;
- for (i = (start || 0); i < j; i += 1) {
- if (this[i] === obj) { return i; }
- }
- return -1;
- };
- }
- if (tarteaucitron.job.indexOf(id) === -1) {
- Array.prototype.push.call(this, id);
- }
- tarteaucitron.launch[id] = false;
- tarteaucitron.addService(id);
- };
- if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
- tarteaucitron.userInterface.openPanel();
- }
- tarteaucitron.cookie.number();
- setInterval(tarteaucitron.cookie.number, 60000);
- }
- }, defaults.adblocker);
- if (defaults.adblocker === true) {
- setTimeout(function () {
- if (tarteaucitronNoAdBlocker === false) {
- html = '<div id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + '" style="display:block">';
- html += ' <span id="tarteaucitronDisclaimerAlert">';
- html += ' ' + tarteaucitron.lang.adblock + '<br/>';
- html += ' <b>' + tarteaucitron.lang.adblock_call + '</b>';
- html += ' </span>';
- html += ' <span id="tarteaucitronPersonalize" onclick="location.reload();">';
- html += ' ' + tarteaucitron.lang.reload;
- html += ' </span>';
- html += '</div>';
- html += '<div id="tarteaucitronPremium"></div>';
- div.id = 'tarteaucitronRoot';
- body.appendChild(div, body);
- div.innerHTML = html;
- tarteaucitron.pro('!adblocker=true');
- } else {
- tarteaucitron.pro('!adblocker=false');
- }
- }, 1500);
- }
- if(document.cookie.indexOf('!gdpr_respond=true') === -1){
- document.getElementById("tarteaucitronAlertBig").style.display='block';
- }
- });
- });
- },
- "addService": function (serviceId) {
- "use strict";
- var html = '',
- s = tarteaucitron.services,
- service = s[serviceId],
- cookie = tarteaucitron.cookie.read(),
- hostname = document.location.hostname,
- hostRef = document.referrer.split('/')[2],
- isNavigating = (hostRef === hostname) ? true : false,
- isAutostart = (!service.needConsent) ? true : false,
- isWaiting = (cookie.indexOf(service.key + '=wait') >= 0) ? true : false,
- isDenied = (cookie.indexOf(service.key + '=false') >= 0) ? true : false,
- isAllowed = (cookie.indexOf(service.key + '=true') >= 0) ? true : false;
- var isResponded = false;
- //isResponded = (cookie.indexOf(service.key + '=false') >= 0 || cookie.indexOf(service.key + '=true') >= 0) ? true : false;
- // isResponded = (cookie.indexOf('gdpr_respond=false') >= 0 || cookie.indexOf('gdpr_respond=true') >= 0) ? true : false;
- if (cookie.indexOf('gdpr_respond=false') >= 0 || cookie.indexOf('gdpr_respond=true') >= 0) {
- var isResponded = (cookie.indexOf(service.key + '=false') >= 0 || cookie.indexOf(service.key + '=true') >= 0) ? true : false;
- }
- if (tarteaucitron.added[service.key] !== true) {
- tarteaucitron.added[service.key] = true;
- html += '<div id="' + service.key + 'Line" class="tarteaucitronLine">';
- html += ' <div class="tarteaucitronName">';
- html += ' <b>' + service.name + '</b><br/>';
- html += ' <span id="tacCL' + service.key + '" class="tarteaucitronListCookies"></span><br/>';
- html += ' <a href="https://opt-out.ferank.eu/service/' + service.key + '/" target="_blank">';
- html += ' ' + tarteaucitron.lang.more;
- html += ' </a>';
- html += ' - ';
- html += ' <a href="' + service.uri + '" target="_blank">';
- html += ' ' + tarteaucitron.lang.source;
- html += ' </a>';
- html += ' </div>';
- html += ' <div class="tarteaucitronAsk">';
- html += ' <div id="' + service.key + 'Allowed" class="tarteaucitronAllow" onclick="tarteaucitron.userInterface.respond(this, true);">';
- html += ' ✓ ' + tarteaucitron.lang.allow;
- html += ' </div> ';
- html += ' <div id="' + service.key + 'Denied" class="tarteaucitronDeny" onclick="tarteaucitron.userInterface.respond(this, false);">';
- html += ' ✗ ' + tarteaucitron.lang.deny;
- html += ' </div>';
- html += ' </div>';
- html += '</div>';
- tarteaucitron.userInterface.css('tarteaucitronServicesTitle_' + service.type, 'display', 'block');
- if (document.getElementById('tarteaucitronServices_' + service.type) !== null) {
- document.getElementById('tarteaucitronServices_' + service.type).innerHTML += html;
- }
- tarteaucitron.userInterface.order(service.type);
- }
- // allow by default for non EU
- if (isResponded === false && tarteaucitron.user.bypass === true) {
- isAllowed = true;
- tarteaucitron.cookie.create(service.key, true);
- }
- if ((!isResponded && (isAutostart || (isNavigating && isWaiting)) && !tarteaucitron.highPrivacy) || isAllowed) {
- if (!isAllowed) {
- tarteaucitron.cookie.create(service.key, true);
- }
- if (tarteaucitron.launch[service.key] !== true) {
- tarteaucitron.launch[service.key] = true;
- service.js();
- }
- tarteaucitron.state[service.key] = true;
- tarteaucitron.userInterface.color(service.key, true);
- tarteaucitron.cookie.create(service.key, true);
- //tarteaucitron.cookie.create('gdpr_respond', true);
- //tarteaucitron.state['gdpr_respond'] = true;
- if (!isResponded) {
- tarteaucitron.userInterface.openAlert();
- }
- } else if (isDenied) {
- if (typeof service.fallback === 'function') {
- service.fallback();
- }
- tarteaucitron.state[service.key] = false;
- tarteaucitron.userInterface.color(service.key, false);
- } else if (!isResponded) {
- tarteaucitron.cookie.create(service.key, 'wait');
- if (typeof service.fallback === 'function') {
- service.fallback();
- }
- tarteaucitron.userInterface.color(service.key, 'wait');
- tarteaucitron.userInterface.openAlert();
- }
- tarteaucitron.cookie.checkCount(service.key);
- },
- "cleanArray": function cleanArray(arr) {
- "use strict";
- var i,
- len = arr.length,
- out = [],
- obj = {},
- s = tarteaucitron.services;
- for (i = 0; i < len; i += 1) {
- if (!obj[arr[i]]) {
- obj[arr[i]] = {};
- if (tarteaucitron.services[arr[i]] !== undefined) {
- out.push(arr[i]);
- }
- }
- }
- out = out.sort(function (a, b) {
- if (s[a].type + s[a].key > s[b].type + s[b].key) { return 1; }
- if (s[a].type + s[a].key < s[b].type + s[b].key) { return -1; }
- return 0;
- });
- return out;
- },
- "userInterface": {
- "css": function (id, property, value) {
- "use strict";
- if (document.getElementById(id) !== null) {
- document.getElementById(id).style[property] = value;
- }
- },
- "respondAll": function (status) {
- "use strict";
- var s = tarteaucitron.services,
- service,
- key,
- index = 0;
- for (index = 0; index < tarteaucitron.job.length; index += 1) {
- service = s[tarteaucitron.job[index]];
- key = service.key;
- if (tarteaucitron.state[key] !== status) {
- if (status === false && tarteaucitron.launch[key] === true) {
- tarteaucitron.reloadThePage = true;
- }
- if (tarteaucitron.launch[key] !== true && status === true) {
- tarteaucitron.launch[key] = true;
- tarteaucitron.services[key].js();
- }
- tarteaucitron.state[key] = status;
- tarteaucitron.cookie.create(key, status);
- tarteaucitron.userInterface.color(key, status);
- }
- }
- tarteaucitron.cookie.create('gdpr_respond', 'true');
- tarteaucitron.userInterface.closeAlert();
- //tarteaucitron.userInterface.css('tarteaucitronAlertBig', 'display', 'none');
- // tarteaucitron.userInterface.css('tarteaucitronAlertSmall', 'display', 'block');
- },
- "respond": function (el, status) {
- "use strict";
- var key = el.id.replace(new RegExp("(Eng[0-9]+|Allow|Deni)ed", "g"), '');
- // return if same state
- if (tarteaucitron.state[key] === status) {
- return;
- }
- if (status === false && tarteaucitron.launch[key] === true) {
- tarteaucitron.reloadThePage = true;
- }
- // if not already launched... launch the service
- if (status === true) {
- if (tarteaucitron.launch[key] !== true) {
- tarteaucitron.launch[key] = true;
- tarteaucitron.services[key].js();
- }
- }
- tarteaucitron.state[key] = status;
- tarteaucitron.cookie.create(key, status);
- tarteaucitron.userInterface.color(key, status);
- },
- "color": function (key, status) {
- "use strict";
- var gray = '#808080',
- greenDark = '#1B870B',
- greenLight = '#E6FFE2',
- redDark = '#9C1A1A',
- redLight = '#FFE2E2',
- yellowDark = '#FBDA26',
- c = 'tarteaucitron',
- nbDenied = 0,
- nbPending = 0,
- nbAllowed = 0,
- sum = tarteaucitron.job.length,
- index;
- if (status === true) {
- tarteaucitron.userInterface.css(key + 'Line', 'borderLeft', '5px solid ' + greenDark);
- tarteaucitron.userInterface.css(key + 'Allowed', 'backgroundColor', greenDark);
- tarteaucitron.userInterface.css(key + 'Denied', 'backgroundColor', gray);
- } else if (status === false) {
- tarteaucitron.userInterface.css(key + 'Line', 'borderLeft', '5px solid ' + redDark);
- tarteaucitron.userInterface.css(key + 'Allowed', 'backgroundColor', gray);
- tarteaucitron.userInterface.css(key + 'Denied', 'backgroundColor', redDark);
- }
- // check if all services are allowed
- for (index = 0; index < sum; index += 1) {
- if (tarteaucitron.state[tarteaucitron.job[index]] === false) {
- nbDenied += 1;
- } else if (tarteaucitron.state[tarteaucitron.job[index]] === undefined) {
- nbPending += 1;
- } else if (tarteaucitron.state[tarteaucitron.job[index]] === true) {
- nbAllowed += 1;
- }
- }
- tarteaucitron.userInterface.css(c + 'DotGreen', 'width', ((100 / sum) * nbAllowed) + '%');
- tarteaucitron.userInterface.css(c + 'DotYellow', 'width', ((100 / sum) * nbPending) + '%');
- tarteaucitron.userInterface.css(c + 'DotRed', 'width', ((100 / sum) * nbDenied) + '%');
- if (nbDenied === 0 && nbPending === 0) {
- tarteaucitron.userInterface.css(c + 'AllAllowed', 'backgroundColor', greenDark);
- tarteaucitron.userInterface.css(c + 'AllDenied', 'backgroundColor', gray);
- } else if (nbAllowed === 0 && nbPending === 0) {
- tarteaucitron.userInterface.css(c + 'AllAllowed', 'backgroundColor', gray);
- tarteaucitron.userInterface.css(c + 'AllDenied', 'backgroundColor', redDark);
- } else {
- tarteaucitron.userInterface.css(c + 'AllAllowed', 'backgroundColor', gray);
- tarteaucitron.userInterface.css(c + 'AllDenied', 'backgroundColor', gray);
- }
- // close the alert if all service have been reviewed
- if (nbPending === 0) {
- tarteaucitron.userInterface.closeAlert();
- }
- if (tarteaucitron.services[key].cookies.length > 0 && status === false) {
- tarteaucitron.cookie.purge(tarteaucitron.services[key].cookies);
- }
- if (status === true) {
- if (document.getElementById('tacCL' + key) !== null) {
- document.getElementById('tacCL' + key).innerHTML = '...';
- }
- setTimeout(function () {
- tarteaucitron.cookie.checkCount(key);
- }, 2500);
- } else {
- tarteaucitron.cookie.checkCount(key);
- }
- },
- "openPanel": function () {
- "use strict";
- tarteaucitron.userInterface.css('tarteaucitron', 'display', 'block');
- tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
- tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
- tarteaucitron.userInterface.jsSizing('main');
- },
- "closePanel": function () {
- "use strict";
- if (document.location.hash === tarteaucitron.hashtag) {
- document.location.hash = '';
- }
- tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
- tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
- tarteaucitron.fallback(['tarteaucitronInfoBox'], function (elem) {
- elem.style.display = 'none';
- }, true);
- if (tarteaucitron.reloadThePage === true) {
- window.location.reload();
- } else {
- tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
- }
- },
- "openAlert": function () {
- "use strict";
- var c = 'tarteaucitron';
- tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'block');
- tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'none');
- tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'block');
- },
- "closeAlert": function () {
- "use strict";
- var c = 'tarteaucitron';
- tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'none');
- tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'block');
- tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'none');
- tarteaucitron.userInterface.jsSizing('box');
- },
- "toggleCookiesList": function () {
- "use strict";
- var div = document.getElementById('tarteaucitronCookiesListContainer');
- if (div === null) {
- return;
- }
- if (div.style.display !== 'block') {
- tarteaucitron.cookie.number();
- div.style.display = 'block';
- tarteaucitron.userInterface.jsSizing('cookie');
- tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
- tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
- tarteaucitron.fallback(['tarteaucitronInfoBox'], function (elem) {
- elem.style.display = 'none';
- }, true);
- } else {
- div.style.display = 'none';
- tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
- tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
- }
- },
- "toggle": function (id, closeClass) {
- "use strict";
- var div = document.getElementById(id);
- if (div === null) {
- return;
- }
- if (closeClass !== undefined) {
- tarteaucitron.fallback([closeClass], function (elem) {
- if (elem.id !== id) {
- elem.style.display = 'none';
- }
- }, true);
- }
- if (div.style.display !== 'block') {
- div.style.display = 'block';
- } else {
- div.style.display = 'none';
- }
- },
- "order": function (id) {
- "use strict";
- var main = document.getElementById('tarteaucitronServices_' + id),
- allDivs,
- store = [],
- i;
- if (main === null) {
- return;
- }
- allDivs = main.childNodes;
- if (typeof Array.prototype.map === 'function') {
- Array.prototype.map.call(main.children, Object).sort(function (a, b) {
- if (tarteaucitron.services[a.id.replace(/Line/g, '')].name > tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return 1; }
- if (tarteaucitron.services[a.id.replace(/Line/g, '')].name < tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return -1; }
- return 0;
- }).forEach(function (element) {
- main.appendChild(element);
- });
- }
- },
- "jsSizing": function (type) {
- "use strict";
- var scrollbarMarginRight = 10,
- scrollbarWidthParent,
- scrollbarWidthChild,
- servicesHeight,
- e = window,
- a = 'inner',
- windowInnerHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
- mainTop,
- mainHeight,
- closeButtonHeight,
- headerHeight,
- cookiesListHeight,
- cookiesCloseHeight,
- cookiesTitleHeight,
- paddingBox,
- alertSmallHeight,
- cookiesNumberHeight;
- if (type === 'box') {
- if (document.getElementById('tarteaucitronAlertSmall') !== null && document.getElementById('tarteaucitronCookiesNumber') !== null) {
- // reset
- tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', '0px 10px');
- // calculate
- alertSmallHeight = document.getElementById('tarteaucitronAlertSmall').offsetHeight;
- cookiesNumberHeight = document.getElementById('tarteaucitronCookiesNumber').offsetHeight;
- paddingBox = (alertSmallHeight - cookiesNumberHeight) / 2;
- // apply
- tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', paddingBox + 'px 10px');
- }
- } else if (type === 'main') {
- // get the real window width for media query
- if (window.innerWidth === undefined) {
- a = 'client';
- e = document.documentElement || document.body;
- }
- // height of the services list container
- if (document.getElementById('tarteaucitron') !== null && document.getElementById('tarteaucitronClosePanel') !== null && document.getElementById('tarteaucitronMainLineOffset') !== null) {
- // reset
- tarteaucitron.userInterface.css('tarteaucitronScrollbarParent', 'height', 'auto');
- // calculate
- mainHeight = document.getElementById('tarteaucitron').offsetHeight;
- closeButtonHeight = document.getElementById('tarteaucitronClosePanel').offsetHeight;
- headerHeight = document.getElementById('tarteaucitronMainLineOffset').offsetHeight;
- // apply
- servicesHeight = (mainHeight - closeButtonHeight - headerHeight + 1);
- tarteaucitron.userInterface.css('tarteaucitronScrollbarParent', 'height', servicesHeight + 'px');
- }
- // align the main allow/deny button depending on scrollbar width
- if (document.getElementById('tarteaucitronScrollbarParent') !== null && document.getElementById('tarteaucitronScrollbarChild') !== null) {
- // media query
- if (e[a + 'Width'] <= 479) {
- tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginLeft', '11px');
- } else if (e[a + 'Width'] <= 767) {
- scrollbarMarginRight = 12;
- }
- scrollbarWidthParent = document.getElementById('tarteaucitronScrollbarParent').offsetWidth;
- scrollbarWidthChild = document.getElementById('tarteaucitronScrollbarChild').offsetWidth;
- tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginRight', ((scrollbarWidthParent - scrollbarWidthChild) + scrollbarMarginRight) + 'px');
- }
- // center the main panel
- if (document.getElementById('tarteaucitron') !== null) {
- // media query
- if (e[a + 'Width'] <= 767) {
- mainTop = 0;
- } else {
- mainTop = ((windowInnerHeight - document.getElementById('tarteaucitron').offsetHeight) / 2) - 21;
- }
- // correct
- if (mainTop < 0) {
- mainTop = 0;
- }
- if (document.getElementById('tarteaucitronMainLineOffset') !== null) {
- if (document.getElementById('tarteaucitron').offsetHeight < (windowInnerHeight / 2)) {
- mainTop -= document.getElementById('tarteaucitronMainLineOffset').offsetHeight;
- }
- }
- // apply
- tarteaucitron.userInterface.css('tarteaucitron', 'top', mainTop + 'px');
- }
- } else if (type === 'cookie') {
- // put cookies list at bottom
- if (document.getElementById('tarteaucitronAlertSmall') !== null) {
- tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'bottom', (document.getElementById('tarteaucitronAlertSmall').offsetHeight) + 'px');
- }
- // height of cookies list
- if (document.getElementById('tarteaucitronCookiesListContainer') !== null) {
- // reset
- tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', 'auto');
- // calculate
- cookiesListHeight = document.getElementById('tarteaucitronCookiesListContainer').offsetHeight;
- cookiesCloseHeight = document.getElementById('tarteaucitronClosePanelCookie').offsetHeight;
- cookiesTitleHeight = document.getElementById('tarteaucitronCookiesTitle').offsetHeight;
- // apply
- tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', (cookiesListHeight - cookiesCloseHeight - cookiesTitleHeight - 2) + 'px');
- }
- }
- }
- },
- "cookie": {
- "owner": {},
- "create": function (key, status) {
- "use strict";
- var d = new Date(),
- time = d.getTime(),
- expireTime = time + 31536000000, // 365 days
- regex = new RegExp("!" + key + "=(wait|true|false)", "g"),
- cookie = tarteaucitron.cookie.read().replace(regex, ""),
- value = 'tarteaucitron=' + cookie + '!' + key + '=' + status;
- if (tarteaucitron.cookie.read().indexOf(key + '=' + status) === -1) {
- tarteaucitron.pro('!' + key + '=' + status);
- }
- d.setTime(expireTime);
- document.cookie = value + '; expires=' + d.toGMTString() + '; path=/;';
- },
- "read": function () {
- "use strict";
- var nameEQ = "tarteaucitron=",
- ca = document.cookie.split(';'),
- i,
- c;
- for (i = 0; i < ca.length; i += 1) {
- c = ca[i];
- while (c.charAt(0) === ' ') {
- c = c.substring(1, c.length);
- }
- if (c.indexOf(nameEQ) === 0) {
- return c.substring(nameEQ.length, c.length);
- }
- }
- return '';
- },
- "purge": function (arr) {
- "use strict";
- var i;
- for (i = 0; i < arr.length; i += 1) {
- document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/;';
- document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname + ';';
- document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname.split('.').slice(-2).join('.') + ';';
- }
- },
- "checkCount": function (key) {
- "use strict";
- var arr = tarteaucitron.services[key].cookies,
- nb = arr.length,
- nbCurrent = 0,
- html = '',
- i,
- status = document.cookie.indexOf(key + '=true');
- if (status >= 0 && nb === 0) {
- html += tarteaucitron.lang.useNoCookie;
- } else if (status >= 0) {
- for (i = 0; i < nb; i += 1) {
- if (document.cookie.indexOf(arr[i] + '=') !== -1) {
- nbCurrent += 1;
- if (tarteaucitron.cookie.owner[arr[i]] === undefined) {
- tarteaucitron.cookie.owner[arr[i]] = [];
- }
- if (tarteaucitron.cookie.crossIndexOf(tarteaucitron.cookie.owner[arr[i]], tarteaucitron.services[key].name) === false) {
- tarteaucitron.cookie.owner[arr[i]].push(tarteaucitron.services[key].name);
- }
- }
- }
- if (nbCurrent > 0) {
- html += tarteaucitron.lang.useCookieCurrent + ' ' + nbCurrent + ' cookie';
- if (nbCurrent > 1) {
- html += 's';
- }
- html += '.';
- } else {
- html += tarteaucitron.lang.useNoCookie;
- }
- } else if (nb === 0) {
- html = tarteaucitron.lang.noCookie;
- } else {
- html += tarteaucitron.lang.useCookie + ' ' + nb + ' cookie';
- if (nb > 1) {
- html += 's';
- }
- html += '.';
- }
- if (document.getElementById('tacCL' + key) !== null) {
- document.getElementById('tacCL' + key).innerHTML = html;
- }
- },
- "crossIndexOf": function (arr, match) {
- "use strict";
- var i;
- for (i = 0; i < arr.length; i += 1) {
- if (arr[i] === match) {
- return true;
- }
- }
- return false;
- },
- "number": function () {
- "use strict";
- var cookies = document.cookie.split(';'),
- nb = (document.cookie !== '') ? cookies.length : 0,
- html = '',
- i,
- name,
- namea,
- nameb,
- c,
- d,
- s = (nb > 1) ? 's' : '',
- savedname,
- regex = /^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i,
- regexedDomain = (tarteaucitron.cdn.match(regex) !== null) ? tarteaucitron.cdn.match(regex)[1] : tarteaucitron.cdn,
- host = (tarteaucitron.domain !== undefined) ? tarteaucitron.domain : regexedDomain;
- cookies = cookies.sort(function (a, b) {
- namea = a.split('=', 1).toString().replace(/ /g, '');
- nameb = b.split('=', 1).toString().replace(/ /g, '');
- c = (tarteaucitron.cookie.owner[namea] !== undefined) ? tarteaucitron.cookie.owner[namea] : '0';
- d = (tarteaucitron.cookie.owner[nameb] !== undefined) ? tarteaucitron.cookie.owner[nameb] : '0';
- if (c + a > d + b) { return 1; }
- if (c + a < d + b) { return -1; }
- return 0;
- });
- if (document.cookie !== '') {
- for (i = 0; i < nb; i += 1) {
- name = cookies[i].split('=', 1).toString().replace(/ /g, '');
- if (tarteaucitron.cookie.owner[name] !== undefined && tarteaucitron.cookie.owner[name].join(' // ') !== savedname) {
- savedname = tarteaucitron.cookie.owner[name].join(' // ');
- html += '<div class="tarteaucitronHidden">';
- html += ' <div class="tarteaucitronTitle">';
- html += ' ' + tarteaucitron.cookie.owner[name].join(' // ');
- html += ' </div>';
- html += '</div>';
- } else if (tarteaucitron.cookie.owner[name] === undefined && host !== savedname) {
- savedname = host;
- html += '<div class="tarteaucitronHidden">';
- html += ' <div class="tarteaucitronTitle">';
- html += ' ' + host;
- html += ' </div>';
- html += '</div>';
- }
- html += '<div class="tarteaucitronCookiesListMain">';
- html += ' <div class="tarteaucitronCookiesListLeft"><a href="#" onclick="tarteaucitron.cookie.purge([\'' + cookies[i].split('=', 1) + '\']);tarteaucitron.cookie.number();tarteaucitron.userInterface.jsSizing(\'cookie\');return false"><b>×</b></a> <b>' + name + '</b>';
- html += ' </div>';
- html += ' <div class="tarteaucitronCookiesListRight">' + cookies[i].split('=').slice(1).join('=') + '</div>';
- html += '</div>';
- }
- } else {
- html += '<div class="tarteaucitronCookiesListMain">';
- html += ' <div class="tarteaucitronCookiesListLeft"><b>-</b></div>';
- html += ' <div class="tarteaucitronCookiesListRight"></div>';
- html += '</div>';
- }
- html += '<div class="tarteaucitronHidden" style="height:20px;display:block"></div>';
- if (document.getElementById('tarteaucitronCookiesList') !== null) {
- document.getElementById('tarteaucitronCookiesList').innerHTML = html;
- }
- if (document.getElementById('tarteaucitronCookiesNumber') !== null) {
- document.getElementById('tarteaucitronCookiesNumber').innerHTML = nb;
- }
- if (document.getElementById('tarteaucitronCookiesNumberBis') !== null) {
- document.getElementById('tarteaucitronCookiesNumberBis').innerHTML = nb + ' cookie' + s;
- }
- for (i = 0; i < tarteaucitron.job.length; i += 1) {
- tarteaucitron.cookie.checkCount(tarteaucitron.job[i]);
- }
- }
- },
- "getLanguage": function () {
- "use strict";
- if (!navigator) { return 'en'; }
- var twChk = "";
- var availableLanguages = 'en,fr,es,it,de,pt,pl,ru,zh,cn',
- defaultLanguage = 'en',
- lang = navigator.language || navigator.browserLanguage ||
- navigator.systemLanguage || navigator.userLang || null,
- userLanguage = lang.substr(0, 2);
- twChk = lang.indexOf('-TW') > -1 ? "zh" : twChk;
- twChk = lang.indexOf('-CN') > -1 ? "cn" : twChk;
- userLanguage = twChk != '' ? twChk : userLanguage;
- var htmlCharset = document.charset.indexOf('UTF-');
- if (twChk != "" && (document.documentElement.lang == 'en' || htmlCharset < 0 )) userLanguage = 'en';
- if (tarteaucitronForceLanguage !== '') {
- if (availableLanguages.indexOf(tarteaucitronForceLanguage) !== -1) {
- return tarteaucitronForceLanguage;
- }
- }
- if (availableLanguages.indexOf(userLanguage) === -1) {
- return defaultLanguage;
- }
- return userLanguage;
- },
- "getLocale": function () {
- "use strict";
- if (!navigator) { return 'en_US'; }
- var lang = navigator.language || navigator.browserLanguage ||
- navigator.systemLanguage || navigator.userLang || null,
- userLanguage = lang.substr(0, 2);
- if (userLanguage === 'fr') {
- return 'fr_FR';
- } else if (userLanguage === 'en') {
- return 'en_US';
- } else if (userLanguage === 'de') {
- return 'de_DE';
- } else if (userLanguage === 'es') {
- return 'es_ES';
- } else if (userLanguage === 'it') {
- return 'it_IT';
- } else if (userLanguage === 'pt') {
- return 'pt_PT';
- } else {
- return 'en_US';
- }
- },
- "addScript": function (url, id, callback, execute, attrName, attrVal) {
- "use strict";
- var script,
- done = false;
- if (execute === false) {
- if (typeof callback === 'function') {
- callback();
- }
- } else {
- script = document.createElement('script');
- script.type = 'text/javascript';
- script.id = (id !== undefined) ? id : '';
- script.async = true;
- script.src = url;
- if (attrName !== undefined && attrVal !== undefined) {
- script.setAttribute(attrName, attrVal);
- }
- if (typeof callback === 'function') {
- script.onreadystatechange = script.onload = function () {
- var state = script.readyState;
- if (!done && (!state || /loaded|complete/.test(state))) {
- done = true;
- callback();
- }
- };
- }
- document.getElementsByTagName('head')[0].appendChild(script);
- }
- },
- "makeAsync": {
- "antiGhost": 0,
- "buffer": '',
- "init": function (url, id) {
- "use strict";
- var savedWrite = document.write,
- savedWriteln = document.writeln;
- document.write = function (content) {
- tarteaucitron.makeAsync.buffer += content;
- };
- document.writeln = function (content) {
- tarteaucitron.makeAsync.buffer += content.concat("\n");
- };
- setTimeout(function () {
- document.write = savedWrite;
- document.writeln = savedWriteln;
- }, 20000);
- tarteaucitron.makeAsync.getAndParse(url, id);
- },
- "getAndParse": function (url, id) {
- "use strict";
- if (tarteaucitron.makeAsync.antiGhost > 9) {
- tarteaucitron.makeAsync.antiGhost = 0;
- return;
- }
- tarteaucitron.makeAsync.antiGhost += 1;
- tarteaucitron.addScript(url, '', function () {
- if (document.getElementById(id) !== null) {
- document.getElementById(id).innerHTML += "<span style='display:none'> </span>" + tarteaucitron.makeAsync.buffer;
- tarteaucitron.makeAsync.buffer = '';
- tarteaucitron.makeAsync.execJS(id);
- }
- });
- },
- "execJS": function (id) {
- /* not strict because third party scripts may have errors */
- var i,
- scripts,
- childId,
- type;
- if (document.getElementById(id) === null) {
- return;
- }
- scripts = document.getElementById(id).getElementsByTagName('script');
- for (i = 0; i < scripts.length; i += 1) {
- type = (scripts[i].getAttribute('type') !== null) ? scripts[i].getAttribute('type') : '';
- if (type === '') {
- type = (scripts[i].getAttribute('language') !== null) ? scripts[i].getAttribute('language') : '';
- }
- if (scripts[i].getAttribute('src') !== null && scripts[i].getAttribute('src') !== '') {
- childId = id + Math.floor(Math.random() * 99999999999);
- document.getElementById(id).innerHTML += '<div id="' + childId + '"></div>';
- tarteaucitron.makeAsync.getAndParse(scripts[i].getAttribute('src'), childId);
- } else if (type.indexOf('javascript') !== -1 || type === '') {
- eval(scripts[i].innerHTML);
- }
- }
- }
- },
- "fallback": function (matchClass, content, noInner) {
- "use strict";
- var elems = document.getElementsByTagName('*'),
- i,
- index = 0;
- for (i in elems) {
- if (elems[i] !== undefined) {
- for (index = 0; index < matchClass.length; index += 1) {
- if ((' ' + elems[i].className + ' ')
- .indexOf(' ' + matchClass[index] + ' ') > -1) {
- if (typeof content === 'function') {
- if (noInner === true) {
- content(elems[i]);
- } else {
- elems[i].innerHTML = content(elems[i]);
- }
- } else {
- elems[i].innerHTML = content;
- }
- }
- }
- }
- }
- },
- "engage": function (id) {
- "use strict";
- var html = '',
- r = Math.floor(Math.random() * 100000);
- html += '<div class="tac_activate">';
- html += ' <div class="tac_float">';
- html += ' <b>' + tarteaucitron.services[id].name + '</b> ' + tarteaucitron.lang.fallback;
- html += ' <div class="tarteaucitronAllow" id="Eng' + r + 'ed' + id + '" onclick="tarteaucitron.userInterface.respond(this, true);">';
- html += ' ✓ ' + tarteaucitron.lang.allow;
- html += ' </div>';
- html += ' </div>';
- html += '</div>';
- return html;
- },
- "extend": function (a, b) {
- "use strict";
- var prop;
- for (prop in b) {
- if (b.hasOwnProperty(prop)) {
- a[prop] = b[prop];
- }
- }
- },
- "proTemp": '',
- "proTimer": function () {
- "use strict";
- setTimeout(tarteaucitron.proPing, 1000);
- },
- "pro": function (list) {
- "use strict";
- tarteaucitron.proTemp += list;
- clearTimeout(tarteaucitron.proTimer);
- tarteaucitron.proTimer = setTimeout(tarteaucitron.proPing, 2500);
- },
- "proPing": function () {
- "use strict";
- if (tarteaucitron.uuid !== '' && tarteaucitron.uuid !== undefined && tarteaucitron.proTemp !== '') {
- var div = document.getElementById('tarteaucitronPremium'),
- timestamp = new Date().getTime(),
- url = '//opt-out.ferank.eu/premium.php?';
- if (div === null) {
- return;
- }
- url += 'domain=' + tarteaucitron.domain + '&';
- url += 'uuid=' + tarteaucitron.uuid + '&';
- url += 'c=' + encodeURIComponent(tarteaucitron.proTemp) + '&';
- url += '_' + timestamp;
- div.innerHTML = '<img src="' + url + '" style="display:none" />';
- tarteaucitron.proTemp = '';
- }
- tarteaucitron.cookie.number();
- }
- };
|