tarteaucitron.js 95 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933
  1. /*jslint browser: true, evil: true */
  2. var scripts = document.getElementsByTagName('script'),
  3. path = scripts[scripts.length - 1].src.split('?')[0],
  4. tarteaucitronForceCDN = (tarteaucitronForceCDN === undefined) ? '' : tarteaucitronForceCDN,
  5. cdn = (tarteaucitronForceCDN === '') ? path.split('/').slice(0, -1).join('/') + '/' : tarteaucitronForceCDN,
  6. alreadyLaunch = (alreadyLaunch === undefined) ? 0 : alreadyLaunch,
  7. tarteaucitronForceLanguage = (tarteaucitronForceLanguage === undefined) ? '' : tarteaucitronForceLanguage,
  8. tarteaucitronForceExpire = (tarteaucitronForceExpire === undefined) ? '' : tarteaucitronForceExpire,
  9. tarteaucitronCustomText = (tarteaucitronCustomText === undefined) ? '' : tarteaucitronCustomText,
  10. // tarteaucitronExpireInDay: true for day(s) value - false for hour(s) value
  11. tarteaucitronExpireInDay = (tarteaucitronExpireInDay === undefined || typeof tarteaucitronExpireInDay !== "boolean") ? true : tarteaucitronExpireInDay,
  12. timeExpire = 31536000000,
  13. tarteaucitronProLoadServices,
  14. tarteaucitronNoAdBlocker = false;
  15. var tarteaucitron = {
  16. "version": 20210310,
  17. "cdn": cdn,
  18. "user": {},
  19. "lang": {},
  20. "services": {},
  21. "added": [],
  22. "idprocessed": [],
  23. "state": [],
  24. "launch": [],
  25. "parameters": {},
  26. "isAjax": false,
  27. "reloadThePage": false,
  28. "events": {
  29. "init": function () {},
  30. "load": function () {},
  31. },
  32. "init": function (params) {
  33. "use strict";
  34. var origOpen;
  35. tarteaucitron.parameters = params;
  36. if (alreadyLaunch === 0) {
  37. alreadyLaunch = 1;
  38. if (window.addEventListener) {
  39. window.addEventListener("load", function () {
  40. tarteaucitron.initEvents.loadEvent(false);
  41. }, false);
  42. window.addEventListener("scroll", function () {
  43. tarteaucitron.initEvents.scrollEvent();
  44. }, false);
  45. window.addEventListener("keydown", function (evt) {
  46. tarteaucitron.initEvents.keydownEvent(false, evt);
  47. }, false);
  48. window.addEventListener("hashchange", function () {
  49. tarteaucitron.initEvents.hashchangeEvent();
  50. }, false);
  51. window.addEventListener("resize", function () {
  52. tarteaucitron.initEvents.resizeEvent();
  53. }, false);
  54. } else {
  55. window.attachEvent("onload", function () {
  56. tarteaucitron.initEvents.loadEvent(true);
  57. });
  58. window.attachEvent("onscroll", function () {
  59. tarteaucitron.initEvents.scrollEvent();
  60. });
  61. window.attachEvent("onkeydown", function (evt) {
  62. tarteaucitron.initEvents.keydownEvent(true, evt);
  63. });
  64. window.attachEvent("onhashchange", function () {
  65. tarteaucitron.initEvents.hashchangeEvent();
  66. });
  67. window.attachEvent("onresize", function () {
  68. tarteaucitron.initEvents.resizeEvent();
  69. });
  70. }
  71. if (typeof XMLHttpRequest !== 'undefined') {
  72. origOpen = XMLHttpRequest.prototype.open;
  73. XMLHttpRequest.prototype.open = function () {
  74. if (window.addEventListener) {
  75. this.addEventListener("load", function () {
  76. if (typeof tarteaucitronProLoadServices === 'function') {
  77. tarteaucitronProLoadServices();
  78. }
  79. }, false);
  80. } else if (typeof this.attachEvent !== 'undefined') {
  81. this.attachEvent("onload", function () {
  82. if (typeof tarteaucitronProLoadServices === 'function') {
  83. tarteaucitronProLoadServices();
  84. }
  85. });
  86. } else {
  87. if (typeof tarteaucitronProLoadServices === 'function') {
  88. setTimeout(tarteaucitronProLoadServices, 1000);
  89. }
  90. }
  91. try {
  92. origOpen.apply(this, arguments);
  93. } catch (err) {}
  94. };
  95. }
  96. }
  97. if(tarteaucitron.events.init) {
  98. tarteaucitron.events.init();
  99. }
  100. },
  101. "initEvents": {
  102. "loadEvent": function (isOldBrowser) {
  103. tarteaucitron.load();
  104. tarteaucitron.fallback(['tarteaucitronOpenPanel'], function (elem) {
  105. if (isOldBrowser) {
  106. elem.attachEvent("onclick", function (event) {
  107. tarteaucitron.userInterface.openPanel();
  108. event.preventDefault();
  109. });
  110. } else {
  111. elem.addEventListener("click", function (event) {
  112. tarteaucitron.userInterface.openPanel();
  113. event.preventDefault();
  114. }, false);
  115. }
  116. }, true);
  117. },
  118. "keydownEvent": function (isOldBrowser, evt) {
  119. if (evt.keyCode === 27) {
  120. tarteaucitron.userInterface.closePanel();
  121. }
  122. if (isOldBrowser) {
  123. if ( evt.keyCode === 9 && focusableEls.indexOf(evt.target) >= 0) {
  124. if ( evt.shiftKey ) /* shift + tab */ {
  125. if (document.activeElement === firstFocusableEl) {
  126. lastFocusableEl.focus();
  127. evt.preventDefault();
  128. }
  129. } else /* tab */ {
  130. if (document.activeElement === lastFocusableEl) {
  131. firstFocusableEl.focus();
  132. evt.preventDefault();
  133. }
  134. }
  135. }
  136. }
  137. },
  138. "hashchangeEvent": function () {
  139. if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
  140. tarteaucitron.userInterface.openPanel();
  141. }
  142. },
  143. "resizeEvent": function () {
  144. var tacElem = document.getElementById('tarteaucitron');
  145. var tacCookieContainer = document.getElementById('tarteaucitronCookiesListContainer');
  146. if (tacElem && tacElem.style.display === 'block') {
  147. tarteaucitron.userInterface.jsSizing('main');
  148. }
  149. if (tacCookieContainer && tacCookieContainer.style.display === 'block') {
  150. tarteaucitron.userInterface.jsSizing('cookie');
  151. }
  152. },
  153. "scrollEvent": function () {
  154. var scrollPos = window.pageYOffset || document.documentElement.scrollTop;
  155. var heightPosition;
  156. var tacPercentage = document.getElementById('tarteaucitronPercentage');
  157. var tacAlertBig = document.getElementById('tarteaucitronAlertBig');
  158. if (tacAlertBig && !tarteaucitron.highPrivacy) {
  159. if (tacAlertBig.style.display === 'block') {
  160. heightPosition = tacAlertBig.offsetHeight + 'px';
  161. if (scrollPos > (screen.height * 2)) {
  162. tarteaucitron.userInterface.respondAll(true);
  163. } else if (scrollPos > (screen.height / 2)) {
  164. document.getElementById('tarteaucitronDisclaimerAlert').innerHTML = '<strong>' + tarteaucitron.lang.alertBigScroll + '</strong> ' + tarteaucitron.lang.alertBig;
  165. }
  166. if (tacPercentage) {
  167. if (tarteaucitron.orientation === 'top') {
  168. tacPercentage.style.top = heightPosition;
  169. } else {
  170. tacPercentage.style.bottom = heightPosition;
  171. }
  172. tacPercentage.style.width = ((100 / (screen.height * 2)) * scrollPos) + '%';
  173. }
  174. }
  175. }
  176. },
  177. },
  178. "load": function () {
  179. "use strict";
  180. var cdn = tarteaucitron.cdn,
  181. language = tarteaucitron.getLanguage(),
  182. useJSDelivrMinifiedJS = (cdn.indexOf('cdn.jsdelivr.net') >= 0),
  183. pathToLang = cdn + 'lang/tarteaucitron.' + language + (useJSDelivrMinifiedJS ? '.min' : '') + '.js?v=' + tarteaucitron.version,
  184. pathToServices = cdn + 'tarteaucitron.services' + (useJSDelivrMinifiedJS ? '.min' : '') + '.js?v=' + tarteaucitron.version,
  185. linkElement = document.createElement('link'),
  186. defaults = {
  187. "adblocker": false,
  188. "hashtag": '#tarteaucitron',
  189. "cookieName": 'tarteaucitron',
  190. "highPrivacy": true,
  191. "orientation": "middle",
  192. "bodyPosition": "bottom",
  193. "removeCredit": false,
  194. "showAlertSmall": false,
  195. "showIcon": true,
  196. "iconPosition": "BottomRight",
  197. "cookieslist": false,
  198. "handleBrowserDNTRequest": false,
  199. "DenyAllCta": true,
  200. "AcceptAllCta" : true,
  201. "moreInfoLink": true,
  202. "privacyUrl": "",
  203. "useExternalCss": false,
  204. "useExternalJs": false,
  205. "mandatory": true,
  206. "closePopup": false,
  207. "groupServices": true
  208. },
  209. params = tarteaucitron.parameters;
  210. // Don't show the middle bar if we are on the privacy policy or more page
  211. if (((tarteaucitron.parameters.readmoreLink !== undefined && window.location.href == tarteaucitron.parameters.readmoreLink) || window.location.href == tarteaucitron.parameters.privacyUrl) && tarteaucitron.parameters.orientation == "middle") {
  212. tarteaucitron.parameters.orientation = "bottom";
  213. }
  214. // Step -1
  215. if (typeof tarteaucitronCustomPremium !== 'undefined') {
  216. tarteaucitronCustomPremium();
  217. }
  218. // Step 0: get params
  219. if (params !== undefined) {
  220. for (var k in defaults) {
  221. if(!tarteaucitron.parameters.hasOwnProperty(k)) {
  222. tarteaucitron.parameters[k] = defaults[k];
  223. }
  224. }
  225. }
  226. // global
  227. tarteaucitron.orientation = tarteaucitron.parameters.orientation;
  228. tarteaucitron.hashtag = tarteaucitron.parameters.hashtag;
  229. tarteaucitron.highPrivacy = tarteaucitron.parameters.highPrivacy;
  230. tarteaucitron.handleBrowserDNTRequest = tarteaucitron.parameters.handleBrowserDNTRequest;
  231. // Step 1: load css
  232. if ( !tarteaucitron.parameters.useExternalCss ) {
  233. linkElement.rel = 'stylesheet';
  234. linkElement.type = 'text/css';
  235. linkElement.href = cdn + 'css/tarteaucitron' + (useJSDelivrMinifiedJS ? '.min' : '') + '.css?v=' + tarteaucitron.version;
  236. document.getElementsByTagName('head')[0].appendChild(linkElement);
  237. }
  238. // Step 2: load language and services
  239. tarteaucitron.addInternalScript(pathToLang, '', function () {
  240. if(tarteaucitronCustomText !== ''){
  241. tarteaucitron.lang = tarteaucitron.AddOrUpdate(tarteaucitron.lang, tarteaucitronCustomText);
  242. }
  243. tarteaucitron.addInternalScript(pathToServices, '', function () {
  244. // css for new middle bar
  245. if (tarteaucitron.orientation === 'middle') {
  246. var customThemeMiddle = document.createElement('style'),
  247. cssRuleMiddle = 'div#tarteaucitronRoot.tarteaucitronBeforeVisible:before {content: \'\';position: fixed;width: 100%;height: 100%;background: white;top: 0;left: 0;z-index: 999;opacity: 0.5;}div#tarteaucitronAlertBig:before {content: \'' + tarteaucitron.lang.middleBarHead + '\';font-size: 35px;}body #tarteaucitronRoot div#tarteaucitronAlertBig {width: 60%;min-width: 285px;height: auto;margin: auto;left: 50%;top: 50%;transform: translate(-50%, -50%);box-shadow: 0 0 9000px #000;border-radius: 20px;padding: 35px 25px;}span#tarteaucitronDisclaimerAlert {padding: 0 30px;}#tarteaucitronRoot span#tarteaucitronDisclaimerAlert {margin: 10px 0 30px;display: block;text-align: center;font-size: 21px;}@media screen and (max-width: 900px) {div#tarteaucitronAlertBig button {margin: 0 auto 10px!important;display: block!important;}}';
  248. customThemeMiddle.type = 'text/css';
  249. if (customThemeMiddle.styleSheet) {
  250. customThemeMiddle.styleSheet.cssText = cssRuleMiddle;
  251. } else {
  252. customThemeMiddle.appendChild(document.createTextNode(cssRuleMiddle));
  253. }
  254. document.getElementsByTagName('head')[0].appendChild(customThemeMiddle);
  255. }
  256. var body = document.body,
  257. div = document.createElement('div'),
  258. html = '',
  259. index,
  260. orientation = 'Top',
  261. cat = ['ads', 'analytic', 'api', 'comment', 'social', 'support', 'video', 'other'],
  262. i;
  263. cat = cat.sort(function (a, b) {
  264. if (tarteaucitron.lang[a].title > tarteaucitron.lang[b].title) { return 1; }
  265. if (tarteaucitron.lang[a].title < tarteaucitron.lang[b].title) { return -1; }
  266. return 0;
  267. });
  268. // Step 3: prepare the html
  269. html += '<div id="tarteaucitronPremium"></div>';
  270. html += '<button type="button" id="tarteaucitronBack" aria-label="' + tarteaucitron.lang.close + '"></button>';
  271. html += '<div id="tarteaucitron" role="dialog" aria-labelledby="dialogTitle">';
  272. html += ' <button type="button" id="tarteaucitronClosePanel">';
  273. html += ' ' + tarteaucitron.lang.close;
  274. html += ' </button>';
  275. html += ' <div id="tarteaucitronServices">';
  276. html += ' <div class="tarteaucitronLine tarteaucitronMainLine" id="tarteaucitronMainLineOffset">';
  277. html += ' <span class="tarteaucitronH1" role="heading" aria-level="1" id="dialogTitle">'+ tarteaucitron.lang.title + '</span>';
  278. html += ' <div id="tarteaucitronInfo">';
  279. html += ' ' + tarteaucitron.lang.disclaimer;
  280. if (tarteaucitron.parameters.privacyUrl !== "") {
  281. html += ' <br/><br/>';
  282. html += ' <button type="button" id="tarteaucitronPrivacyUrlDialog">';
  283. html += ' ' + tarteaucitron.lang.privacyUrl;
  284. html += ' </button>';
  285. }
  286. html += ' </div>';
  287. html += ' <div class="tarteaucitronName">';
  288. html += ' <span class="tarteaucitronH2" role="heading" aria-level="2">' + tarteaucitron.lang.all + '</span>';
  289. html += ' </div>';
  290. html += ' <div class="tarteaucitronAsk" id="tarteaucitronScrollbarAdjust">';
  291. html += ' <button type="button" id="tarteaucitronAllAllowed" class="tarteaucitronAllow">';
  292. html += ' <span class="tarteaucitronCheck"></span> ' + tarteaucitron.lang.allowAll;
  293. html += ' </button> ';
  294. html += ' <button type="button" id="tarteaucitronAllDenied" class="tarteaucitronDeny">';
  295. html += ' <span class="tarteaucitronCross"></span> ' + tarteaucitron.lang.denyAll;
  296. html += ' </button>';
  297. html += ' </div>';
  298. html += ' </div>';
  299. html += ' <div class="tarteaucitronBorder">';
  300. html += ' <div class="clear"></div><ul>';
  301. if (tarteaucitron.parameters.mandatory == true) {
  302. html += '<li id="tarteaucitronServicesTitle_mandatory">';
  303. html += '<div class="tarteaucitronTitle">';
  304. html += ' <button type="button" tabindex="-1">&nbsp; ' + tarteaucitron.lang.mandatoryTitle + '</button>';
  305. html += '</div>';
  306. html += '<ul id="tarteaucitronServices_mandatory">';
  307. html += '<li class="tarteaucitronLine">';
  308. html += ' <div class="tarteaucitronName">';
  309. html += ' <span class="tarteaucitronH3" role="heading" aria-level="3">' + tarteaucitron.lang.mandatoryText + '</span>';
  310. html += ' <span class="tarteaucitronListCookies"></span><br/>';
  311. html += ' </div>';
  312. html += ' <div class="tarteaucitronAsk">';
  313. html += ' <button type="button" class="tarteaucitronAllow" tabindex="-1" disabled>';
  314. html += ' <span class="tarteaucitronCheck"></span> ' + tarteaucitron.lang.allow;
  315. html += ' </button> ';
  316. html += ' <button type="button" class="tarteaucitronDeny" style="visibility:hidden" tabindex="-1">';
  317. html += ' <span class="tarteaucitronCross"></span> ' + tarteaucitron.lang.deny;
  318. html += ' </button> ';
  319. html += ' </div>';
  320. html += '</li>';
  321. html += '</ul></li>';
  322. }
  323. for (i = 0; i < cat.length; i += 1) {
  324. html += ' <li id="tarteaucitronServicesTitle_' + cat[i] + '" class="tarteaucitronHidden">';
  325. html += ' <div class="tarteaucitronTitle">';
  326. html += ' <button type="button" class="catToggleBtn" data-cat="tarteaucitronDetails' + cat[i] + '"><span class="tarteaucitronPlus"></span> ' + tarteaucitron.lang[cat[i]].title + '</button>';
  327. html += ' </div>';
  328. html += ' <div id="tarteaucitronDetails' + cat[i] + '" class="tarteaucitronDetails tarteaucitronInfoBox">';
  329. html += ' ' + tarteaucitron.lang[cat[i]].details;
  330. html += ' </div>';
  331. html += ' <ul id="tarteaucitronServices_' + cat[i] + '"></ul></li>';
  332. }
  333. html += ' <li id="tarteaucitronNoServicesTitle" class="tarteaucitronLine">' + tarteaucitron.lang.noServices + '</li>';
  334. html += ' </ul>';
  335. html += ' <div class="tarteaucitronHidden tarteaucitron-spacer-20" id="tarteaucitronScrollbarChild"></div>';
  336. if (tarteaucitron.parameters.removeCredit === false) {
  337. html += ' <a class="tarteaucitronSelfLink" href="https://tarteaucitron.io/" rel="nofollow noreferrer noopener" target="_blank" title="tarteaucitron ' + tarteaucitron.lang.newWindow + '"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHcAAAAeCAYAAAAWwoEYAAADl0lEQVRoge1Y0W3bQAx9CjKARlC+9GVUmqDJBHEmiDyB6wkcTxBngtgTxJ0gzgQW4C/9aYOmE6g4lTQo+k6y3Rb94QOERNQd+cjj8XiGwWAwGAwGg8FgMBgMBoPB8F8RNRXe+whEKe7c36ZCAeCRxC9Rig2PUd8kPgAsoxSfQ3YAzAA8D/HwYYCb05kBKKO0teFkmbC1jlKsAnq/Abjn+QBqAIsoRS30ttwG/HNz1wH/XIxWTicLdvtW7xTAGEAMtP685CNsBTe2d/BLydfXAG57SEnMAST0zgYZSUCPk02bCvkJduIzuJzDLfPolbY+tLKmar+/8+IRePy4qdpE03qHuH8fipFb4N2+XdA3AJ/0vaQxt7s9FvkIS2XvtqnwM0rxpOQfbnE5G2LhTCmUO2fHIngOmcv+KG3HafDchB6ntwjYqenR2PqC7sOZ3E7FXHB0vqxoFyUyLh7OEH7LOGouvhhN3eIBeKXv0n5MsufdHqXcwYR5U2EbpV35lSspVPJmQj4TcgRK7jTg5IzmPUhhwM5a2WHUFCx+NgiDucmgh7idikLovHFlL0pxQ9xzX+IIP9Y6FrJsqhjlQpZRAkFVDCjZfcCHt6bqJDmuh5ylCWx0RVnk3oumaknqTH5sqrY0fBWyULaHUIgAgxb46MxV3DbieAhxOxUxjSuljig9lMQ/Bcfoi9BTEv9aLORSndVxYOH525sUDC6u2gWxcNzBNRxPanyh3ktKinOgy3WoxPbtUM0t6RkbQnzBnFPgi9GCOEubY9UffIryz9iKRe8s/FUfEWosJJGxagp85bpUO3VywQ46lOtAWfNxKwa4JXQ+628+bpxYGXXMzp5rXH401VEyXwIdowXFaKWSMFHvMTVmGnc+P3oXV2QOiBCfgex8QtcQCbcQE/H+eoHzrkFo1KM7zVO4jVVj5s6lRiWF7zyXyfRMc97J3tzj87mYqZ7E2YjzUct9GUi4tjHLR8dVkBLjQcuHFleWvQfRNEhFR7uX7pkctOwvZXsft7sAtyldEUIN2UTeLxnEfxKYswzdi88BdbZ8hifUoSMftQvP+muRwN6+Q3DeqqRExP9QmTtcheiHh0Ot1x2i2km1bP9pbufw5zZdyWsOrh7vQae5OZWbsMv30pi7cd/CKj3coPEVaCP4Zhx4eQWhOZ1Y9MTXGyP8/iGjEyfa1T4fO/4Lea9vBoPBYDAYDAaDwWAwGAwGwz8GgF8siXCCbrSRhgAAAABJRU5ErkJggg==" alt="tarteaucitron.io" /></a>';
  338. }
  339. html += ' </div>';
  340. html += ' </div>';
  341. html += '</div>';
  342. if (tarteaucitron.parameters.orientation === 'bottom') {
  343. orientation = 'Bottom';
  344. }
  345. if (tarteaucitron.parameters.highPrivacy && !tarteaucitron.parameters.AcceptAllCta) {
  346. html += '<div id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + '">';
  347. //html += '<div class="tarteaucitronAlertBigWrapper">';
  348. html += ' <span id="tarteaucitronDisclaimerAlert">';
  349. html += ' ' + tarteaucitron.lang.alertBigPrivacy;
  350. html += ' </span>';
  351. //html += ' <span class="tarteaucitronAlertBigBtnWrapper">';
  352. html += ' <button type="button" id="tarteaucitronPersonalize">';
  353. html += ' ' + tarteaucitron.lang.personalize;
  354. html += ' </button>';
  355. if (tarteaucitron.parameters.privacyUrl !== "") {
  356. html += ' <button type="button" id="tarteaucitronPrivacyUrl">';
  357. html += ' ' + tarteaucitron.lang.privacyUrl;
  358. html += ' </button>';
  359. }
  360. //html += ' </span>';
  361. //html += '</div>';
  362. html += '</div>';
  363. } else {
  364. html += '<div id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + '">';
  365. //html += '<div class="tarteaucitronAlertBigWrapper">';
  366. html += ' <span id="tarteaucitronDisclaimerAlert">';
  367. if (tarteaucitron.parameters.highPrivacy) {
  368. html += ' ' + tarteaucitron.lang.alertBigPrivacy;
  369. } else {
  370. html += ' ' + tarteaucitron.lang.alertBigClick + ' ' + tarteaucitron.lang.alertBig;
  371. }
  372. html += ' </span>';
  373. //html += ' <span class="tarteaucitronAlertBigBtnWrapper">';
  374. html += ' <button type="button" class="tarteaucitronCTAButton tarteaucitronAllow" id="tarteaucitronPersonalize2">';
  375. html += ' <span class="tarteaucitronCheck"></span> ' + tarteaucitron.lang.acceptAll;
  376. html += ' </button>';
  377. if (tarteaucitron.parameters.DenyAllCta) {
  378. html += ' <button type="button" class="tarteaucitronCTAButton tarteaucitronDeny" id="tarteaucitronAllDenied2">';
  379. html += ' <span class="tarteaucitronCross"></span> ' + tarteaucitron.lang.denyAll;
  380. html += ' </button>';
  381. //html += ' <br/><br/>';
  382. }
  383. html += ' <button type="button" id="tarteaucitronCloseAlert">';
  384. html += ' ' + tarteaucitron.lang.personalize;
  385. html += ' </button>';
  386. if (tarteaucitron.parameters.privacyUrl !== "") {
  387. html += ' <button type="button" id="tarteaucitronPrivacyUrl">';
  388. html += ' ' + tarteaucitron.lang.privacyUrl;
  389. html += ' </button>';
  390. }
  391. //html += ' </span>';
  392. //html += '</div>';
  393. html += '</div>';
  394. html += '<div id="tarteaucitronPercentage"></div>';
  395. }
  396. if (tarteaucitron.parameters.showIcon === true) {
  397. html += '<div id="tarteaucitronIcon" class="tarteaucitronIcon' + tarteaucitron.parameters.iconPosition + '">';
  398. html += ' <button type="button" id="tarteaucitronManager">';
  399. html += ' <img src="' + (tarteaucitron.parameters.iconSrc ? tarteaucitron.parameters.iconSrc : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAGA0lEQVRoge1a207bWBRdBtJwLYZhKDMVmlSK1LxNkPo+ZH6g8B6p5AuALwC+APoFoVLeoT8whPeRSt+CZKmZVu3AiIsRlEtCktGyjy8xzuXYhvahS0JJHJ/4rLP3XnuffcAPfGdQ7mM6jRLSAF4BxqsbewB2lRS2o35mpEQaJcwCyANIdLi1DGBNSWEzqmdHRqRRwjqAJclhtExOSUEP+/xIiDRKhhUWfL7ShTtBuJnqcw+/z4Ql0xNmMEwSSz4kuNIzSgpjSsqYJP/GeE185wYJroedRyiLNEpGLLzzrHSuk+83SgbxvOcyyRaDziWsRVZkSRDinpzPbwVGWIucuohsKynMS47fAQyls/BMSRmKJo3AFhG5wm2N1wF+Zs3zebbFfR0RxrXcJHQlgH+LMW616pR/WiIMEXfW3mtzXyeEGWsjKot8c4TOI98L+iKaR5PS6IUk88RLAO9F8UjrbYoYMOosNavpfmODIiwRXRR/G3ohaWVo1RU/c30jV8ab2mV8qVGzHWBOLyTLZiWs5Rolg/C3ySOi0tXP/k4aEwOwSBKPJs7Rp16ABJTe+p1xVX0It/owqqdDEMRoqd3RFxqDPh20Ig6VEPVC0i5RSCD+6wl6HlW7GksSlUMV11/GrUs5NasFLusDE9ELSVphXemtJwaT/8JyIRvxNNCfBmIiNdR04LII3DSrbe0yjqvyJF/ppptqVlt+MCLCEh/oOkPPP6N38Mb5cnQBGFsEqmXg5j3QMwoMzwGnr4HYbybBq13gZAOom/FO63zdf2qQArCsZrUN2TlJy69eSDKYV+6Q4MpP75ivHzPA53ngaBW4eGuSOt0A/lsGPmXMz0+3TFJcTfFbPfFbfnwlhON+iQhlWmA82CQ4ocQ7c6KcfL3DHuls0yT6Sx4YnLXJDCQOIRRv5yGIJBgP8Sdisj2qubpc5UGJmo+W49ifVmzL8HcpGhQPvZCUKiCliIhEN0tr2OCqHuSA8gwQ/92MkU7gxEmeVqGrTTgpxPXbUrtGWYus0I9thRIraagRQUIDf7Qn4yZhKRiFQIyhfMfUr3yblokVWSJ6k8xSnc7eNN/RjowfCYiFoDUFer1S3gW6JiJ8Nt30EMbEhU+vzSIztuRYjRLsR8IHLjlf7HZ+MrWWEXxNmbvapt4jGSqZRYSkGUetSNTPzHsui5YMQ2ajJUNks6mw4wT54Ok2ShnzzIPCUGshzawCRKy5FqvrTZe0RWzQGvw79m67XZjKmxJrLsICjtZa55gxXy+6F4sYsEtxTqhXdRTLC8ulSDaWoCLsolfN+8YUhOsJV709H7Cudr0LlVEtzqBcN+shEyThdR941OnAbF8pirKJqXyupTRTtQSReiVmXW1j7oBErB0d9xM2WEd5J9ZKYtuR4WKwwBSoORbpGrJ5ZI9lt71irJmGX1px0JYE26uNErawr2zfIcP4OHEKXm66PA3wjpCNEfpJunI4muifPjKvsFCkGjExTq63yxMJsZNMYF/J4HmDC5A3Yq36jy0ClePHVhwuu/b1HSFlEfHD5ZtD1bEK44Qu1mWys6tbWmZyPWckzlPTGiRw/XHCuk+q4Rek+mVrVL/UppwrdDEGNV2kpyuhccgc5Oxm9vWnn+19vJrVpLor0kTUrGacMplb1CfOFyTD4o9uNrHqr2Z+ZMSp1c2XcVSORnh9Q81q3k599ETgkNnjg0nGzi10K7rX+bZpHbrblPcY5A4Zxk2xcjzCvTpd9027Aa0QtouyyrKFRR6D/04DwkFGvHPXM3Qda/Jb4nPgI7hQLVM1q5HIBt2MzQNa57Z1DiiLAGa5Mi+O4Sz3Mpp6laPHO6InII3ITnX1QtI+EOX+m9ZxleOZ/j9PiuKoLi3aqXPuEoSye/Vhkm+LalbLtHhMS0R6zu7aZ3vP2jOjL7QVv4McxhcDnZIelAQibGIbULOapf3PuE1Vs9qeaOTdkVKr00gCQiw4NlBzDvf1Lxx+uP5r3Dgv5KQZRzWn+GRwz8jmDS8itUg7iB6vLuJCF5Uty4A9mVKkFR6MiJDachST/oHvHgD+B4SoUIitpF05AAAAAElFTkSuQmCC') + '" alt="' + tarteaucitron.lang.icon + '" title="' + tarteaucitron.lang.icon + '">';
  400. html += ' </button>';
  401. html += '</div>';
  402. }
  403. if (tarteaucitron.parameters.showAlertSmall === true) {
  404. html += '<div id="tarteaucitronAlertSmall" class="tarteaucitronAlertSmall' + orientation + '">';
  405. html += ' <button type="button" id="tarteaucitronManager">';
  406. html += ' ' + tarteaucitron.lang.alertSmall;
  407. html += ' <span id="tarteaucitronDot">';
  408. html += ' <span id="tarteaucitronDotGreen"></span>';
  409. html += ' <span id="tarteaucitronDotYellow"></span>';
  410. html += ' <span id="tarteaucitronDotRed"></span>';
  411. html += ' </span>';
  412. if (tarteaucitron.parameters.cookieslist === true) {
  413. html += ' </button><!-- @whitespace';
  414. html += ' --><button type="button" id="tarteaucitronCookiesNumber">0</button>';
  415. html += ' <div id="tarteaucitronCookiesListContainer">';
  416. html += ' <button type="button" id="tarteaucitronClosePanelCookie">';
  417. html += ' ' + tarteaucitron.lang.close;
  418. html += ' </button>';
  419. html += ' <div class="tarteaucitronCookiesListMain" id="tarteaucitronCookiesTitle">';
  420. html += ' <span class="tarteaucitronH2" role="heading" aria-level="2" id="tarteaucitronCookiesNumberBis">0 cookie</span>';
  421. html += ' </div>';
  422. html += ' <div id="tarteaucitronCookiesList"></div>';
  423. html += ' </div>';
  424. } else {
  425. html += ' </div>';
  426. }
  427. html += '</div>';
  428. }
  429. tarteaucitron.addInternalScript(tarteaucitron.cdn + 'advertising' + (useJSDelivrMinifiedJS ? '.min' : '') + '.js?v=' + tarteaucitron.version, '', function () {
  430. if (tarteaucitronNoAdBlocker === true || tarteaucitron.parameters.adblocker === false) {
  431. // create a wrapper container at the same level than tarteaucitron so we can add an aria-hidden when tarteaucitron is opened
  432. /*var wrapper = document.createElement('div');
  433. wrapper.id = "tarteaucitronContentWrapper";
  434. while (document.body.firstChild)
  435. {
  436. wrapper.appendChild(document.body.firstChild);
  437. }
  438. // Append the wrapper to the body
  439. document.body.appendChild(wrapper);*/
  440. div.id = 'tarteaucitronRoot';
  441. if (tarteaucitron.parameters.bodyPosition === 'top') {
  442. // Prepend tarteaucitron: #tarteaucitronRoot first-child of the body for better accessibility
  443. var bodyFirstChild = body.firstChild;
  444. body.insertBefore(div, bodyFirstChild);
  445. }
  446. else {
  447. // Append tarteaucitron: #tarteaucitronRoot last-child of the body
  448. body.appendChild(div, body);
  449. }
  450. div.innerHTML = html;
  451. //ie compatibility
  452. var tacRootAvailableEvent;
  453. if(typeof(Event) === 'function') {
  454. tacRootAvailableEvent = new Event("tac.root_available");
  455. }else{
  456. tacRootAvailableEvent = document.createEvent('Event');
  457. tacRootAvailableEvent.initEvent("tac.root_available", true, true);
  458. }
  459. //end ie compatibility
  460. window.dispatchEvent(tacRootAvailableEvent);
  461. if (tarteaucitron.job !== undefined) {
  462. tarteaucitron.job = tarteaucitron.cleanArray(tarteaucitron.job);
  463. for (index = 0; index < tarteaucitron.job.length; index += 1) {
  464. tarteaucitron.addService(tarteaucitron.job[index]);
  465. }
  466. } else {
  467. tarteaucitron.job = []
  468. }
  469. tarteaucitron.isAjax = true;
  470. tarteaucitron.job.push = function (id) {
  471. // ie <9 hack
  472. if (typeof tarteaucitron.job.indexOf === 'undefined') {
  473. tarteaucitron.job.indexOf = function (obj, start) {
  474. var i,
  475. j = this.length;
  476. for (i = (start || 0); i < j; i += 1) {
  477. if (this[i] === obj) { return i; }
  478. }
  479. return -1;
  480. };
  481. }
  482. if (tarteaucitron.job.indexOf(id) === -1) {
  483. Array.prototype.push.call(this, id);
  484. }
  485. tarteaucitron.launch[id] = false;
  486. tarteaucitron.addService(id);
  487. };
  488. if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
  489. tarteaucitron.userInterface.openPanel();
  490. }
  491. tarteaucitron.cookie.number();
  492. setInterval(tarteaucitron.cookie.number, 60000);
  493. }
  494. }, tarteaucitron.parameters.adblocker);
  495. if (tarteaucitron.parameters.adblocker === true) {
  496. setTimeout(function () {
  497. if (tarteaucitronNoAdBlocker === false) {
  498. html = '<div id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + ' tarteaucitron-display-block" role="alert" aria-live="polite">';
  499. html += ' <p id="tarteaucitronDisclaimerAlert">';
  500. html += ' ' + tarteaucitron.lang.adblock + '<br/>';
  501. html += ' <strong>' + tarteaucitron.lang.adblock_call + '</strong>';
  502. html += ' </p>';
  503. html += ' <button type="button" class="tarteaucitronCTAButton" id="tarteaucitronCTAButton">';
  504. html += ' ' + tarteaucitron.lang.reload;
  505. html += ' </button>';
  506. html += '</div>';
  507. html += '<div id="tarteaucitronPremium"></div>';
  508. div.id = 'tarteaucitronRoot';
  509. if (tarteaucitron.parameters.bodyPosition === 'top') {
  510. // Prepend tarteaucitron: #tarteaucitronRoot first-child of the body for better accessibility
  511. var bodyFirstChild = body.firstChild;
  512. body.insertBefore(div, bodyFirstChild);
  513. }
  514. else {
  515. // Append tarteaucitron: #tarteaucitronRoot last-child of the body
  516. body.appendChild(div, body);
  517. }
  518. div.innerHTML = html;
  519. }
  520. }, 1500);
  521. }
  522. if(tarteaucitron.parameters.closePopup === true){
  523. let element = document.getElementById('tarteaucitronAlertBig');
  524. let span = document.createElement('span')
  525. span.textContent = 'X';
  526. span.setAttribute('id', "tarteaucitronCloseCross")
  527. element.insertBefore(span, element.firstElementChild)
  528. }
  529. if(tarteaucitron.parameters.groupServices === true) {
  530. var tac_group_style = document.createElement('style');
  531. tac_group_style.innerHTML = '.tarteaucitronTitle{display:none}';
  532. document.head.appendChild(tac_group_style);
  533. var cats = document.querySelectorAll('[id^="tarteaucitronServicesTitle_"]')
  534. cats.forEach(function(item) {
  535. var cat = item.getAttribute('id').replace(/^(tarteaucitronServicesTitle_)/, "");
  536. if (cat !== "mandatory") {
  537. var html = '';
  538. html += '<li class="tarteaucitronLine">';
  539. html += ' <div class="tarteaucitronName">';
  540. html += ' <span class="tarteaucitronH3" role="heading" aria-level="3">'+tarteaucitron.lang[cat].title+'</span>';
  541. html += ' <span>'+tarteaucitron.lang[cat].details+'</span>';
  542. html += ' <button type="button" class="tarteaucitron-toggle-group" id="tarteaucitron-toggle-group-'+cat+'">'+tarteaucitron.lang.alertSmall+' ('+document.getElementById("tarteaucitronServices_"+cat).childElementCount+')</button>';
  543. html += ' </div>';
  544. html += ' <div class="tarteaucitronAsk" id="tarteaucitron-group-'+cat+'">';
  545. html += ' <button type="button" class="tarteaucitronAllow" id="tarteaucitron-accept-group-'+cat+'">';
  546. html += ' &#10003; ' + tarteaucitron.lang.allow;
  547. html += ' </button> ';
  548. html += ' <button type="button" class="tarteaucitronDeny" id="tarteaucitron-reject-group-'+cat+'">';
  549. html += ' &#10007; ' + tarteaucitron.lang.deny;
  550. html += ' </button>';
  551. html += ' </div>';
  552. html += '</li>';
  553. var ul = document.createElement('ul');
  554. ul.innerHTML = html;
  555. item.insertBefore(ul, item.querySelector('#tarteaucitronServices_'+cat+''));
  556. document.querySelector('#tarteaucitronServices_' + cat).style.display = 'none';
  557. tarteaucitron.addClickEventToId("tarteaucitron-toggle-group-" + cat, function () {
  558. tarteaucitron.userInterface.toggle('tarteaucitronServices_' + cat);
  559. });
  560. tarteaucitron.addClickEventToId("tarteaucitron-accept-group-" + cat, function () {
  561. tarteaucitron.userInterface.respondAll(true, cat);
  562. });
  563. tarteaucitron.addClickEventToId("tarteaucitron-reject-group-" + cat, function () {
  564. tarteaucitron.userInterface.respondAll(false, cat);
  565. });
  566. }
  567. });
  568. }
  569. tarteaucitron.userInterface.color("", true);
  570. // add a little timeout to be sure everything is accessible
  571. setTimeout(function () {
  572. // Setup events
  573. tarteaucitron.addClickEventToId("tarteaucitronCloseCross", function () {
  574. tarteaucitron.userInterface.closeAlert();
  575. });
  576. tarteaucitron.addClickEventToId("tarteaucitronPersonalize", function () {
  577. tarteaucitron.userInterface.openPanel();
  578. });
  579. tarteaucitron.addClickEventToId("tarteaucitronPersonalize2", function () {
  580. tarteaucitron.userInterface.respondAll(true);
  581. });
  582. tarteaucitron.addClickEventToId("tarteaucitronManager", function () {
  583. tarteaucitron.userInterface.openPanel();
  584. });
  585. tarteaucitron.addClickEventToId("tarteaucitronBack", function () {
  586. tarteaucitron.userInterface.closePanel();
  587. });
  588. tarteaucitron.addClickEventToId("tarteaucitronClosePanel", function () {
  589. tarteaucitron.userInterface.closePanel();
  590. });
  591. tarteaucitron.addClickEventToId("tarteaucitronClosePanelCookie", function () {
  592. tarteaucitron.userInterface.closePanel();
  593. });
  594. tarteaucitron.addClickEventToId("tarteaucitronPrivacyUrl", function () {
  595. document.location = tarteaucitron.parameters.privacyUrl;
  596. });
  597. tarteaucitron.addClickEventToId("tarteaucitronPrivacyUrlDialog", function () {
  598. document.location = tarteaucitron.parameters.privacyUrl;
  599. });
  600. tarteaucitron.addClickEventToId("tarteaucitronCookiesNumber", function () {
  601. tarteaucitron.userInterface.toggleCookiesList();
  602. });
  603. tarteaucitron.addClickEventToId("tarteaucitronAllAllowed", function () {
  604. tarteaucitron.userInterface.respondAll(true);
  605. });
  606. tarteaucitron.addClickEventToId("tarteaucitronAllDenied", function () {
  607. tarteaucitron.userInterface.respondAll(false);
  608. });
  609. tarteaucitron.addClickEventToId("tarteaucitronAllDenied2", function () {
  610. tarteaucitron.userInterface.respondAll(false, '', true);
  611. if (tarteaucitron.reloadThePage === true) {
  612. window.location.reload();
  613. }
  614. });
  615. tarteaucitron.addClickEventToId("tarteaucitronCloseAlert", function () {
  616. tarteaucitron.userInterface.openPanel();
  617. });
  618. tarteaucitron.addClickEventToId("tarteaucitronCTAButton", function () {
  619. location.reload();
  620. });
  621. var toggleBtns = document.getElementsByClassName("catToggleBtn"), i;
  622. for (i = 0; i < toggleBtns.length; i++) {
  623. toggleBtns[i].dataset.index = i;
  624. tarteaucitron.addClickEventToElement(toggleBtns[i], function () {
  625. tarteaucitron.userInterface.toggle('tarteaucitronDetails' + cat[this.dataset.index], 'tarteaucitronInfoBox');
  626. return false;
  627. });
  628. }
  629. var allowBtns = document.getElementsByClassName("tarteaucitronAllow");
  630. for (i = 0; i < allowBtns.length; i++) {
  631. tarteaucitron.addClickEventToElement(allowBtns[i], function () {
  632. tarteaucitron.userInterface.respond(this, true);
  633. });
  634. }
  635. var denyBtns = document.getElementsByClassName("tarteaucitronDeny");
  636. for (i = 0; i < denyBtns.length; i++) {
  637. tarteaucitron.addClickEventToElement(denyBtns[i], function () {
  638. tarteaucitron.userInterface.respond(this, false);
  639. });
  640. }
  641. if(tarteaucitron.events.load) {
  642. tarteaucitron.events.load();
  643. }
  644. }, 500);
  645. });
  646. });
  647. },
  648. "addService": function (serviceId) {
  649. "use strict";
  650. var html = '',
  651. s = tarteaucitron.services,
  652. service = s[serviceId],
  653. cookie = tarteaucitron.cookie.read(),
  654. hostname = document.location.hostname,
  655. hostRef = document.referrer.split('/')[2],
  656. isNavigating = (hostRef === hostname && window.location.href !== tarteaucitron.parameters.privacyUrl),
  657. isAutostart = (!service.needConsent),
  658. isWaiting = (cookie.indexOf(service.key + '=wait') >= 0),
  659. isDenied = (cookie.indexOf(service.key + '=false') >= 0),
  660. isAllowed = ((cookie.indexOf(service.key + '=true') >= 0) || (!service.needConsent && cookie.indexOf(service.key + '=false') < 0)),
  661. isResponded = (cookie.indexOf(service.key + '=false') >= 0 || cookie.indexOf(service.key + '=true') >= 0),
  662. isDNTRequested = (navigator.doNotTrack === "1" || navigator.doNotTrack === "yes" || navigator.msDoNotTrack === "1" || window.doNotTrack === "1");
  663. if (tarteaucitron.added[service.key] !== true) {
  664. tarteaucitron.added[service.key] = true;
  665. html += '<li id="' + service.key + 'Line" class="tarteaucitronLine">';
  666. html += ' <div class="tarteaucitronName">';
  667. html += ' <span class="tarteaucitronH3" role="heading" aria-level="3">' + service.name + '</span>';
  668. html += ' <span id="tacCL' + service.key + '" class="tarteaucitronListCookies"></span><br/>';
  669. if (tarteaucitron.parameters.moreInfoLink == true) {
  670. var link = 'https://tarteaucitron.io/service/' + service.key + '/';
  671. if (service.readmoreLink !== undefined && service.readmoreLink !== '') {
  672. link = service.readmoreLink;
  673. }
  674. if (tarteaucitron.parameters.readmoreLink !== undefined && tarteaucitron.parameters.readmoreLink !== '') {
  675. link = tarteaucitron.parameters.readmoreLink;
  676. }
  677. html += ' <a href="' + link + '" target="_blank" rel="noreferrer noopener nofollow" title="'+ tarteaucitron.lang.cookieDetail + ' ' + service.name + ' ' + tarteaucitron.lang.ourSite + ' ' + tarteaucitron.lang.newWindow +'">';
  678. html += ' ' + tarteaucitron.lang.more;
  679. html += ' </a>';
  680. html += ' - ';
  681. html += ' <a href="' + service.uri + '" target="_blank" rel="noreferrer noopener" title="' + service.name + ' ' + tarteaucitron.lang.newWindow + '">';
  682. html += ' ' + tarteaucitron.lang.source;
  683. html += ' </a>';
  684. }
  685. html += ' </div>';
  686. html += ' <div class="tarteaucitronAsk">';
  687. html += ' <button type="button" id="' + service.key + 'Allowed" class="tarteaucitronAllow">';
  688. html += ' <span class="tarteaucitronCheck"></span> ' + tarteaucitron.lang.allow;
  689. html += ' </button> ';
  690. html += ' <button type="button" id="' + service.key + 'Denied" class="tarteaucitronDeny">';
  691. html += ' <span class="tarteaucitronCross"></span> ' + tarteaucitron.lang.deny;
  692. html += ' </button>';
  693. html += ' </div>';
  694. html += '</li>';
  695. tarteaucitron.userInterface.css('tarteaucitronServicesTitle_' + service.type, 'display', 'block');
  696. if (document.getElementById('tarteaucitronServices_' + service.type) !== null) {
  697. document.getElementById('tarteaucitronServices_' + service.type).innerHTML += html;
  698. }
  699. tarteaucitron.userInterface.css('tarteaucitronNoServicesTitle', 'display', 'none');
  700. tarteaucitron.userInterface.order(service.type);
  701. tarteaucitron.addClickEventToId(service.key + 'Allowed', function () {
  702. tarteaucitron.userInterface.respond(this, true);
  703. });
  704. tarteaucitron.addClickEventToId(service.key + 'Denied', function () {
  705. tarteaucitron.userInterface.respond(this, false);
  706. });
  707. }
  708. tarteaucitron.pro('!' + service.key + '=' + isAllowed);
  709. // allow by default for non EU
  710. if (isResponded === false && tarteaucitron.user.bypass === true) {
  711. isAllowed = true;
  712. tarteaucitron.cookie.create(service.key, true);
  713. }
  714. if ((!isResponded && (isAutostart || (isNavigating && isWaiting)) && !tarteaucitron.highPrivacy) || isAllowed) {
  715. if (!isAllowed || (!service.needConsent && cookie.indexOf(service.key + '=false') < 0)) {
  716. tarteaucitron.cookie.create(service.key, true);
  717. }
  718. if (tarteaucitron.launch[service.key] !== true) {
  719. tarteaucitron.launch[service.key] = true;
  720. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + service.key + "_") < 0) { service.js(); }
  721. tarteaucitron.sendEvent(service.key + '_loaded');
  722. }
  723. tarteaucitron.state[service.key] = true;
  724. tarteaucitron.userInterface.color(service.key, true);
  725. } else if (isDenied) {
  726. if (typeof service.fallback === 'function') {
  727. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + service.key + "_") < 0) { service.fallback(); }
  728. }
  729. tarteaucitron.state[service.key] = false;
  730. tarteaucitron.userInterface.color(service.key, false);
  731. } else if (!isResponded && isDNTRequested && tarteaucitron.handleBrowserDNTRequest) {
  732. tarteaucitron.cookie.create(service.key, 'false');
  733. if (typeof service.fallback === 'function') {
  734. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + service.key + "_") < 0) { service.fallback(); }
  735. }
  736. tarteaucitron.state[service.key] = false;
  737. tarteaucitron.userInterface.color(service.key, false);
  738. } else if (!isResponded) {
  739. tarteaucitron.cookie.create(service.key, 'wait');
  740. if (typeof service.fallback === 'function') {
  741. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + service.key + "_") < 0) { service.fallback(); }
  742. }
  743. tarteaucitron.userInterface.color(service.key, 'wait');
  744. tarteaucitron.userInterface.openAlert();
  745. }
  746. tarteaucitron.cookie.checkCount(service.key);
  747. tarteaucitron.sendEvent(service.key + '_added')
  748. },
  749. "sendEvent" : function(event_key) {
  750. if(event_key !== undefined) {
  751. //ie compatibility
  752. var send_event_item;
  753. if(typeof(Event) === 'function') {
  754. send_event_item = new Event(event_key);
  755. }else{
  756. send_event_item = document.createEvent('Event');
  757. send_event_item.initEvent(event_key, true, true);
  758. }
  759. //end ie compatibility
  760. document.dispatchEvent(send_event_item);
  761. }
  762. },
  763. "cleanArray": function cleanArray(arr) {
  764. "use strict";
  765. var i,
  766. len = arr.length,
  767. out = [],
  768. obj = {},
  769. s = tarteaucitron.services;
  770. for (i = 0; i < len; i += 1) {
  771. if (!obj[arr[i]]) {
  772. obj[arr[i]] = {};
  773. if (tarteaucitron.services[arr[i]] !== undefined) {
  774. out.push(arr[i]);
  775. }
  776. }
  777. }
  778. out = out.sort(function (a, b) {
  779. if (s[a].type + s[a].key > s[b].type + s[b].key) { return 1; }
  780. if (s[a].type + s[a].key < s[b].type + s[b].key) { return -1; }
  781. return 0;
  782. });
  783. return out;
  784. },
  785. "userInterface": {
  786. "css": function (id, property, value) {
  787. "use strict";
  788. if (document.getElementById(id) !== null) {
  789. if (property == "display" && value == "none" && (id == "tarteaucitron" || id == "tarteaucitronBack" || id == "tarteaucitronAlertBig")) {
  790. document.getElementById(id).style["opacity"] = "0";
  791. setTimeout(function() {document.getElementById(id).style[property] = value;}, 200);
  792. } else {
  793. document.getElementById(id).style[property] = value;
  794. if (property == "display" && value == "block" && (id == "tarteaucitron" || id == "tarteaucitronAlertBig")) {
  795. document.getElementById(id).style["opacity"] = "0";
  796. setTimeout(function() {document.getElementById(id).style["opacity"] = "1";}, 1);
  797. }
  798. if (property == "display" && value == "block" && id == "tarteaucitronBack") {
  799. document.getElementById(id).style["opacity"] = "0";
  800. setTimeout(function() {document.getElementById(id).style["opacity"] = "0.7";}, 1);
  801. }
  802. }
  803. }
  804. },
  805. "addClass": function (id, className) {
  806. "use strict";
  807. if (document.getElementById(id) !== null) {
  808. document.getElementById(id).classList.add(className);
  809. }
  810. },
  811. "removeClass": function (id, className) {
  812. "use strict";
  813. if (document.getElementById(id) !== null) {
  814. document.getElementById(id).classList.remove(className);
  815. }
  816. },
  817. "respondAll": function (status, type, allowSafeAnalytics) {
  818. "use strict";
  819. var s = tarteaucitron.services,
  820. service,
  821. key,
  822. index = 0;
  823. for (index = 0; index < tarteaucitron.job.length; index += 1) {
  824. if (typeof type !== 'undefined' && type !== '' && s[tarteaucitron.job[index]].type !== type) {
  825. continue;
  826. }
  827. if (allowSafeAnalytics && typeof s[tarteaucitron.job[index]].safeanalytic !== "undefined" && s[tarteaucitron.job[index]].safeanalytic === true) {
  828. continue;
  829. }
  830. service = s[tarteaucitron.job[index]];
  831. key = service.key;
  832. if (tarteaucitron.state[key] !== status) {
  833. if (status === false && tarteaucitron.launch[key] === true) {
  834. tarteaucitron.reloadThePage = true;
  835. }
  836. if (tarteaucitron.launch[key] !== true && status === true) {
  837. tarteaucitron.pro('!' + key + '=engage');
  838. tarteaucitron.launch[key] = true;
  839. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + key + "_") < 0) { tarteaucitron.services[key].js(); }
  840. tarteaucitron.sendEvent(key + '_loaded');
  841. }
  842. tarteaucitron.state[key] = status;
  843. tarteaucitron.cookie.create(key, status);
  844. tarteaucitron.userInterface.color(key, status);
  845. }
  846. }
  847. },
  848. "respond": function (el, status) {
  849. "use strict";
  850. if (el.id === '') {
  851. return;
  852. }
  853. var key = el.id.replace(new RegExp("(Eng[0-9]+|Allow|Deni)ed", "g"), '');
  854. if (key.substring(0, 13) === 'tarteaucitron' || key === '') {return;}
  855. // return if same state
  856. if (tarteaucitron.state[key] === status) {
  857. return;
  858. }
  859. if (status === false && tarteaucitron.launch[key] === true) {
  860. tarteaucitron.reloadThePage = true;
  861. }
  862. // if not already launched... launch the service
  863. if (status === true) {
  864. if (tarteaucitron.launch[key] !== true) {
  865. tarteaucitron.pro('!' + key + '=engage');
  866. tarteaucitron.launch[key] = true;
  867. tarteaucitron.sendEvent(key + '_loaded');
  868. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + key + "_") < 0) { tarteaucitron.services[key].js(); }
  869. }
  870. }
  871. tarteaucitron.state[key] = status;
  872. tarteaucitron.cookie.create(key, status);
  873. tarteaucitron.userInterface.color(key, status);
  874. },
  875. "color": function (key, status) {
  876. "use strict";
  877. var c = 'tarteaucitron',
  878. nbDenied = 0,
  879. nbPending = 0,
  880. nbAllowed = 0,
  881. sum = tarteaucitron.job.length,
  882. index,
  883. s = tarteaucitron.services;
  884. if (key !== "") {
  885. if (status === true) {
  886. document.getElementById(key + 'Line').classList.add('tarteaucitronIsAllowed');
  887. document.getElementById(key + 'Line').classList.remove('tarteaucitronIsDenied');
  888. } else if (status === false) {
  889. document.getElementById(key + 'Line').classList.remove('tarteaucitronIsAllowed');
  890. document.getElementById(key + 'Line').classList.add('tarteaucitronIsDenied');
  891. }
  892. // check if all services are allowed
  893. var sumToRemove = 0;
  894. for (index = 0; index < sum; index += 1) {
  895. if (typeof s[tarteaucitron.job[index]].safeanalytic !== "undefined" && s[tarteaucitron.job[index]].safeanalytic === true) {
  896. sumToRemove += 1;
  897. continue;
  898. }
  899. if (tarteaucitron.state[tarteaucitron.job[index]] === false) {
  900. nbDenied += 1;
  901. } else if (tarteaucitron.state[tarteaucitron.job[index]] === undefined) {
  902. nbPending += 1;
  903. } else if (tarteaucitron.state[tarteaucitron.job[index]] === true) {
  904. nbAllowed += 1;
  905. }
  906. }
  907. sum -= sumToRemove;
  908. tarteaucitron.userInterface.css(c + 'DotGreen', 'width', ((100 / sum) * nbAllowed) + '%');
  909. tarteaucitron.userInterface.css(c + 'DotYellow', 'width', ((100 / sum) * nbPending) + '%');
  910. tarteaucitron.userInterface.css(c + 'DotRed', 'width', ((100 / sum) * nbDenied) + '%');
  911. if (nbDenied === 0 && nbPending === 0) {
  912. tarteaucitron.userInterface.removeClass(c + 'AllDenied', c + 'IsSelected');
  913. tarteaucitron.userInterface.addClass(c + 'AllAllowed', c + 'IsSelected');
  914. tarteaucitron.userInterface.addClass(c + 'MainLineOffset', c + 'IsAllowed');
  915. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsDenied');
  916. } else if (nbAllowed === 0 && nbPending === 0) {
  917. tarteaucitron.userInterface.removeClass(c + 'AllAllowed', c + 'IsSelected');
  918. tarteaucitron.userInterface.addClass(c + 'AllDenied', c + 'IsSelected');
  919. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsAllowed');
  920. tarteaucitron.userInterface.addClass(c + 'MainLineOffset', c + 'IsDenied');
  921. } else {
  922. tarteaucitron.userInterface.removeClass(c + 'AllAllowed', c + 'IsSelected');
  923. tarteaucitron.userInterface.removeClass(c + 'AllDenied', c + 'IsSelected');
  924. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsAllowed');
  925. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsDenied');
  926. }
  927. // close the alert if all service have been reviewed
  928. if (nbPending === 0) {
  929. tarteaucitron.userInterface.closeAlert();
  930. }
  931. if (tarteaucitron.services[key].cookies.length > 0 && status === false) {
  932. tarteaucitron.cookie.purge(tarteaucitron.services[key].cookies);
  933. }
  934. if (status === true) {
  935. if (document.getElementById('tacCL' + key) !== null) {
  936. document.getElementById('tacCL' + key).innerHTML = '...';
  937. }
  938. setTimeout(function () {
  939. tarteaucitron.cookie.checkCount(key);
  940. }, 2500);
  941. } else {
  942. tarteaucitron.cookie.checkCount(key);
  943. }
  944. }
  945. // groups
  946. var cats = document.querySelectorAll('[id^="tarteaucitronServicesTitle_"]')
  947. cats.forEach(function(item) {
  948. var cat = item.getAttribute('id').replace(/^(tarteaucitronServicesTitle_)/, ""),
  949. total = document.getElementById("tarteaucitronServices_"+cat).childElementCount;
  950. var doc = document.getElementById("tarteaucitronServices_"+cat),
  951. groupdenied = 0,
  952. groupallowed = 0;
  953. for (var ii = 0; ii < doc.children.length; ii++) {
  954. if (doc.children[ii].className == "tarteaucitronLine tarteaucitronIsDenied") {
  955. groupdenied++;
  956. }
  957. if (doc.children[ii].className == "tarteaucitronLine tarteaucitronIsAllowed") {
  958. groupallowed++;
  959. }
  960. }
  961. if (total === groupallowed) {
  962. tarteaucitron.userInterface.removeClass('tarteaucitron-group-'+cat, 'tarteaucitronIsDenied');
  963. tarteaucitron.userInterface.addClass('tarteaucitron-group-'+cat, 'tarteaucitronIsAllowed');
  964. }
  965. if (total === groupdenied) {
  966. tarteaucitron.userInterface.addClass('tarteaucitron-group-'+cat, 'tarteaucitronIsDenied');
  967. tarteaucitron.userInterface.removeClass('tarteaucitron-group-'+cat, 'tarteaucitronIsAllowed');
  968. }
  969. if (total !== groupdenied && total !== groupallowed) {
  970. tarteaucitron.userInterface.removeClass('tarteaucitron-group-'+cat, 'tarteaucitronIsDenied');
  971. tarteaucitron.userInterface.removeClass('tarteaucitron-group-'+cat, 'tarteaucitronIsAllowed');
  972. }
  973. groupdenied = 0;
  974. groupallowed = 0;
  975. });
  976. },
  977. "openPanel": function () {
  978. "use strict";
  979. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'block');
  980. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
  981. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
  982. document.getElementById('tarteaucitronClosePanel').focus();
  983. document.getElementsByTagName('body')[0].classList.add('tarteaucitron-modal-open');
  984. tarteaucitron.userInterface.focusTrap();
  985. tarteaucitron.userInterface.jsSizing('main');
  986. //ie compatibility
  987. var tacOpenPanelEvent;
  988. if(typeof(Event) === 'function') {
  989. tacOpenPanelEvent = new Event("tac.open_panel");
  990. }else{
  991. tacOpenPanelEvent = document.createEvent('Event');
  992. tacOpenPanelEvent.initEvent("tac.open_panel", true, true);
  993. }
  994. //end ie compatibility
  995. window.dispatchEvent(tacOpenPanelEvent);
  996. },
  997. "closePanel": function () {
  998. "use strict";
  999. if (document.location.hash === tarteaucitron.hashtag) {
  1000. if (window.history) {
  1001. window.history.replaceState('', document.title, window.location.pathname + window.location.search);
  1002. } else {
  1003. document.location.hash = '';
  1004. }
  1005. }
  1006. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  1007. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
  1008. tarteaucitron.fallback(['tarteaucitronInfoBox'], function (elem) {
  1009. elem.style.display = 'none';
  1010. }, true);
  1011. if (tarteaucitron.reloadThePage === true) {
  1012. window.location.reload();
  1013. } else {
  1014. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
  1015. }
  1016. if (document.getElementById('tarteaucitronCloseAlert') !== null) {
  1017. document.getElementById('tarteaucitronCloseAlert').focus();
  1018. }
  1019. document.getElementsByTagName('body')[0].classList.remove('tarteaucitron-modal-open');
  1020. //ie compatibility
  1021. var tacClosePanelEvent;
  1022. if(typeof(Event) === 'function') {
  1023. tacClosePanelEvent = new Event("tac.close_panel");
  1024. }else{
  1025. tacClosePanelEvent = document.createEvent('Event');
  1026. tacClosePanelEvent.initEvent("tac.close_panel", true, true);
  1027. }
  1028. //end ie compatibility
  1029. window.dispatchEvent(tacClosePanelEvent);
  1030. },
  1031. "focusTrap": function() {
  1032. "use strict";
  1033. var focusableEls,
  1034. firstFocusableEl,
  1035. lastFocusableEl,
  1036. filtered;
  1037. focusableEls = document.getElementById('tarteaucitron').querySelectorAll('a[href], button');
  1038. filtered = [];
  1039. // get only visible items
  1040. for (var i = 0, max = focusableEls.length; i < max; i++) {
  1041. if (focusableEls[i].offsetHeight > 0) {
  1042. filtered.push(focusableEls[i]);
  1043. }
  1044. }
  1045. firstFocusableEl = filtered[0];
  1046. lastFocusableEl = filtered[filtered.length - 1];
  1047. //loop focus inside tarteaucitron
  1048. document.getElementById('tarteaucitron').addEventListener("keydown", function (evt) {
  1049. if ( evt.key === 'Tab' || evt.keyCode === 9 ) {
  1050. if ( evt.shiftKey ) /* shift + tab */ {
  1051. if (document.activeElement === firstFocusableEl) {
  1052. lastFocusableEl.focus();
  1053. evt.preventDefault();
  1054. }
  1055. } else /* tab */ {
  1056. if (document.activeElement === lastFocusableEl) {
  1057. firstFocusableEl.focus();
  1058. evt.preventDefault();
  1059. }
  1060. }
  1061. }
  1062. })
  1063. },
  1064. "openAlert": function () {
  1065. "use strict";
  1066. var c = 'tarteaucitron';
  1067. tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'block');
  1068. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'none');
  1069. tarteaucitron.userInterface.css(c + 'Icon', 'display', 'none');
  1070. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'block');
  1071. tarteaucitron.userInterface.addClass(c + 'Root', 'tarteaucitronBeforeVisible');
  1072. //ie compatibility
  1073. var tacOpenAlertEvent;
  1074. if(typeof(Event) === 'function') {
  1075. tacOpenAlertEvent = new Event("tac.open_alert");
  1076. }else{
  1077. tacOpenAlertEvent = document.createEvent('Event');
  1078. tacOpenAlertEvent.initEvent("tac.open_alert", true, true);
  1079. }
  1080. //end ie compatibility
  1081. window.dispatchEvent(tacOpenAlertEvent);
  1082. },
  1083. "closeAlert": function () {
  1084. "use strict";
  1085. var c = 'tarteaucitron';
  1086. tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'none');
  1087. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'block');
  1088. tarteaucitron.userInterface.css(c + 'Icon', 'display', 'block');
  1089. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'none');
  1090. tarteaucitron.userInterface.removeClass(c + 'Root', 'tarteaucitronBeforeVisible');
  1091. tarteaucitron.userInterface.jsSizing('box');
  1092. //ie compatibility
  1093. var tacCloseAlertEvent;
  1094. if(typeof(Event) === 'function') {
  1095. tacCloseAlertEvent = new Event("tac.close_alert");
  1096. }else{
  1097. tacCloseAlertEvent = document.createEvent('Event');
  1098. tacCloseAlertEvent.initEvent("tac.close_alert", true, true);
  1099. }
  1100. //end ie compatibility
  1101. window.dispatchEvent(tacCloseAlertEvent);
  1102. },
  1103. "toggleCookiesList": function () {
  1104. "use strict";
  1105. var div = document.getElementById('tarteaucitronCookiesListContainer');
  1106. if (div === null) {
  1107. return;
  1108. }
  1109. if (div.style.display !== 'block') {
  1110. tarteaucitron.cookie.number();
  1111. div.style.display = 'block';
  1112. tarteaucitron.userInterface.jsSizing('cookie');
  1113. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  1114. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
  1115. tarteaucitron.fallback(['tarteaucitronInfoBox'], function (elem) {
  1116. elem.style.display = 'none';
  1117. }, true);
  1118. } else {
  1119. div.style.display = 'none';
  1120. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  1121. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
  1122. }
  1123. },
  1124. "toggle": function (id, closeClass) {
  1125. "use strict";
  1126. var div = document.getElementById(id);
  1127. if (div === null) {
  1128. return;
  1129. }
  1130. if (closeClass !== undefined) {
  1131. tarteaucitron.fallback([closeClass], function (elem) {
  1132. if (elem.id !== id) {
  1133. elem.style.display = 'none';
  1134. }
  1135. }, true);
  1136. }
  1137. if (div.style.display !== 'block') {
  1138. div.style.display = 'block';
  1139. } else {
  1140. div.style.display = 'none';
  1141. }
  1142. },
  1143. "order": function (id) {
  1144. "use strict";
  1145. var main = document.getElementById('tarteaucitronServices_' + id),
  1146. allDivs,
  1147. store = [],
  1148. i;
  1149. if (main === null) {
  1150. return;
  1151. }
  1152. allDivs = main.childNodes;
  1153. if (typeof Array.prototype.map === 'function' && typeof Enumerable === 'undefined') {
  1154. Array.prototype.map.call(main.children, Object).sort(function (a, b) {
  1155. //var mainChildren = Array.from(main.children);
  1156. //mainChildren.sort(function (a, b) {
  1157. if (tarteaucitron.services[a.id.replace(/Line/g, '')].name > tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return 1; }
  1158. if (tarteaucitron.services[a.id.replace(/Line/g, '')].name < tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return -1; }
  1159. return 0;
  1160. }).forEach(function (element) {
  1161. main.appendChild(element);
  1162. });
  1163. }
  1164. },
  1165. "jsSizing": function (type) {
  1166. "use strict";
  1167. var scrollbarMarginRight = 10,
  1168. scrollbarWidthParent,
  1169. scrollbarWidthChild,
  1170. servicesHeight,
  1171. e = window,
  1172. a = 'inner',
  1173. windowInnerHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
  1174. mainTop,
  1175. mainHeight,
  1176. closeButtonHeight,
  1177. headerHeight,
  1178. cookiesListHeight,
  1179. cookiesCloseHeight,
  1180. cookiesTitleHeight,
  1181. paddingBox,
  1182. alertSmallHeight,
  1183. cookiesNumberHeight;
  1184. if (type === 'box') {
  1185. if (document.getElementById('tarteaucitronAlertSmall') !== null && document.getElementById('tarteaucitronCookiesNumber') !== null) {
  1186. // reset
  1187. tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', '0px 10px');
  1188. // calculate
  1189. alertSmallHeight = document.getElementById('tarteaucitronAlertSmall').offsetHeight;
  1190. cookiesNumberHeight = document.getElementById('tarteaucitronCookiesNumber').offsetHeight;
  1191. paddingBox = (alertSmallHeight - cookiesNumberHeight) / 2;
  1192. // apply
  1193. tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', paddingBox + 'px 10px');
  1194. }
  1195. } else if (type === 'main') {
  1196. // get the real window width for media query
  1197. if (window.innerWidth === undefined) {
  1198. a = 'client';
  1199. e = document.documentElement || document.body;
  1200. }
  1201. // height of the services list container
  1202. if (document.getElementById('tarteaucitron') !== null && document.getElementById('tarteaucitronClosePanel') !== null && document.getElementById('tarteaucitronMainLineOffset') !== null) {
  1203. // reset
  1204. tarteaucitron.userInterface.css('tarteaucitronServices', 'height', 'auto');
  1205. // calculate
  1206. mainHeight = document.getElementById('tarteaucitron').offsetHeight;
  1207. closeButtonHeight = document.getElementById('tarteaucitronClosePanel').offsetHeight;
  1208. // apply
  1209. servicesHeight = (mainHeight - closeButtonHeight + 2);
  1210. tarteaucitron.userInterface.css('tarteaucitronServices', 'height', servicesHeight + 'px');
  1211. tarteaucitron.userInterface.css('tarteaucitronServices', 'overflow-x', 'auto');
  1212. }
  1213. // align the main allow/deny button depending on scrollbar width
  1214. if (document.getElementById('tarteaucitronServices') !== null && document.getElementById('tarteaucitronScrollbarChild') !== null) {
  1215. // media query
  1216. if (e[a + 'Width'] <= 479) {
  1217. //tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginLeft', '11px');
  1218. } else if (e[a + 'Width'] <= 767) {
  1219. scrollbarMarginRight = 12;
  1220. }
  1221. scrollbarWidthParent = document.getElementById('tarteaucitronServices').offsetWidth;
  1222. scrollbarWidthChild = document.getElementById('tarteaucitronScrollbarChild').offsetWidth;
  1223. //tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginRight', ((scrollbarWidthParent - scrollbarWidthChild) + scrollbarMarginRight) + 'px');
  1224. }
  1225. // center the main panel
  1226. if (document.getElementById('tarteaucitron') !== null) {
  1227. // media query
  1228. if (e[a + 'Width'] <= 767) {
  1229. mainTop = 0;
  1230. } else {
  1231. mainTop = ((windowInnerHeight - document.getElementById('tarteaucitron').offsetHeight) / 2) - 21;
  1232. }
  1233. if (document.getElementById('tarteaucitronMainLineOffset') !== null) {
  1234. if (document.getElementById('tarteaucitron').offsetHeight < (windowInnerHeight / 2)) {
  1235. mainTop -= document.getElementById('tarteaucitronMainLineOffset').offsetHeight;
  1236. }
  1237. }
  1238. // correct
  1239. if (mainTop < 0) {
  1240. mainTop = 0;
  1241. }
  1242. // apply
  1243. tarteaucitron.userInterface.css('tarteaucitron', 'top', mainTop + 'px');
  1244. }
  1245. } else if (type === 'cookie') {
  1246. // put cookies list at bottom
  1247. if (document.getElementById('tarteaucitronAlertSmall') !== null) {
  1248. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'bottom', (document.getElementById('tarteaucitronAlertSmall').offsetHeight) + 'px');
  1249. }
  1250. // height of cookies list
  1251. if (document.getElementById('tarteaucitronCookiesListContainer') !== null) {
  1252. // reset
  1253. tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', 'auto');
  1254. // calculate
  1255. cookiesListHeight = document.getElementById('tarteaucitronCookiesListContainer').offsetHeight;
  1256. cookiesCloseHeight = document.getElementById('tarteaucitronClosePanelCookie').offsetHeight;
  1257. cookiesTitleHeight = document.getElementById('tarteaucitronCookiesTitle').offsetHeight;
  1258. // apply
  1259. tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', (cookiesListHeight - cookiesCloseHeight - cookiesTitleHeight - 2) + 'px');
  1260. }
  1261. }
  1262. }
  1263. },
  1264. "cookie": {
  1265. "owner": {},
  1266. "create": function (key, status) {
  1267. "use strict";
  1268. if (tarteaucitronForceExpire !== '') {
  1269. // The number of day(s)/hour(s) can't be higher than 1 year
  1270. if ((tarteaucitronExpireInDay && tarteaucitronForceExpire < 365) || (!tarteaucitronExpireInDay && tarteaucitronForceExpire < 8760)) {
  1271. if (tarteaucitronExpireInDay) {
  1272. // Multiplication to tranform the number of days to milliseconds
  1273. timeExpire = tarteaucitronForceExpire * 86400000;
  1274. } else {
  1275. // Multiplication to tranform the number of hours to milliseconds
  1276. timeExpire = tarteaucitronForceExpire * 3600000;
  1277. }
  1278. }
  1279. }
  1280. var d = new Date(),
  1281. time = d.getTime(),
  1282. expireTime = time + timeExpire, // 365 days
  1283. regex = new RegExp("!" + key + "=(wait|true|false)", "g"),
  1284. cookie = tarteaucitron.cookie.read().replace(regex, ""),
  1285. value = tarteaucitron.parameters.cookieName + '=' + cookie + '!' + key + '=' + status,
  1286. domain = (tarteaucitron.parameters.cookieDomain !== undefined && tarteaucitron.parameters.cookieDomain !== '') ? '; domain=' + tarteaucitron.parameters.cookieDomain : '',
  1287. secure = location.protocol === 'https:' ? '; Secure' : '';
  1288. d.setTime(expireTime);
  1289. document.cookie = value + '; expires=' + d.toGMTString() + '; path=/' + domain + secure + '; samesite=lax';
  1290. },
  1291. "read": function () {
  1292. "use strict";
  1293. var nameEQ = tarteaucitron.parameters.cookieName + "=",
  1294. ca = document.cookie.split(';'),
  1295. i,
  1296. c;
  1297. for (i = 0; i < ca.length; i += 1) {
  1298. c = ca[i];
  1299. while (c.charAt(0) === ' ') {
  1300. c = c.substring(1, c.length);
  1301. }
  1302. if (c.indexOf(nameEQ) === 0) {
  1303. return c.substring(nameEQ.length, c.length);
  1304. }
  1305. }
  1306. return '';
  1307. },
  1308. "purge": function (arr) {
  1309. "use strict";
  1310. var i;
  1311. for (i = 0; i < arr.length; i += 1) {
  1312. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/;';
  1313. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname + ';';
  1314. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname.split('.').slice(-2).join('.') + ';';
  1315. }
  1316. },
  1317. "checkCount": function (key) {
  1318. "use strict";
  1319. var arr = tarteaucitron.services[key].cookies,
  1320. nb = arr.length,
  1321. nbCurrent = 0,
  1322. html = '',
  1323. i,
  1324. status = document.cookie.indexOf(key + '=true');
  1325. if (status >= 0 && nb === 0) {
  1326. html += tarteaucitron.lang.useNoCookie;
  1327. } else if (status >= 0) {
  1328. for (i = 0; i < nb; i += 1) {
  1329. if (document.cookie.indexOf(arr[i] + '=') !== -1) {
  1330. nbCurrent += 1;
  1331. if (tarteaucitron.cookie.owner[arr[i]] === undefined) {
  1332. tarteaucitron.cookie.owner[arr[i]] = [];
  1333. }
  1334. if (tarteaucitron.cookie.crossIndexOf(tarteaucitron.cookie.owner[arr[i]], tarteaucitron.services[key].name) === false) {
  1335. tarteaucitron.cookie.owner[arr[i]].push(tarteaucitron.services[key].name);
  1336. }
  1337. }
  1338. }
  1339. if (nbCurrent > 0) {
  1340. html += tarteaucitron.lang.useCookieCurrent + ' ' + nbCurrent + ' cookie';
  1341. if (nbCurrent > 1) {
  1342. html += 's';
  1343. }
  1344. html += '.';
  1345. } else {
  1346. html += tarteaucitron.lang.useNoCookie;
  1347. }
  1348. } else if (nb === 0) {
  1349. html = tarteaucitron.lang.noCookie;
  1350. } else {
  1351. html += tarteaucitron.lang.useCookie + ' ' + nb + ' cookie';
  1352. if (nb > 1) {
  1353. html += 's';
  1354. }
  1355. html += '.';
  1356. }
  1357. if (document.getElementById('tacCL' + key) !== null) {
  1358. document.getElementById('tacCL' + key).innerHTML = html;
  1359. }
  1360. },
  1361. "crossIndexOf": function (arr, match) {
  1362. "use strict";
  1363. var i;
  1364. for (i = 0; i < arr.length; i += 1) {
  1365. if (arr[i] === match) {
  1366. return true;
  1367. }
  1368. }
  1369. return false;
  1370. },
  1371. "number": function () {
  1372. "use strict";
  1373. var cookies = document.cookie.split(';'),
  1374. nb = (document.cookie !== '') ? cookies.length : 0,
  1375. html = '',
  1376. i,
  1377. name,
  1378. namea,
  1379. nameb,
  1380. c,
  1381. d,
  1382. s = (nb > 1) ? 's' : '',
  1383. savedname,
  1384. regex = /^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i,
  1385. regexedDomain = (tarteaucitron.cdn.match(regex) !== null) ? tarteaucitron.cdn.match(regex)[1] : tarteaucitron.cdn,
  1386. host = (tarteaucitron.domain !== undefined) ? tarteaucitron.domain : regexedDomain;
  1387. cookies = cookies.sort(function (a, b) {
  1388. namea = a.split('=', 1).toString().replace(/ /g, '');
  1389. nameb = b.split('=', 1).toString().replace(/ /g, '');
  1390. c = (tarteaucitron.cookie.owner[namea] !== undefined) ? tarteaucitron.cookie.owner[namea] : '0';
  1391. d = (tarteaucitron.cookie.owner[nameb] !== undefined) ? tarteaucitron.cookie.owner[nameb] : '0';
  1392. if (c + a > d + b) { return 1; }
  1393. if (c + a < d + b) { return -1; }
  1394. return 0;
  1395. });
  1396. if (document.cookie !== '') {
  1397. for (i = 0; i < nb; i += 1) {
  1398. name = cookies[i].split('=', 1).toString().replace(/ /g, '');
  1399. if (tarteaucitron.cookie.owner[name] !== undefined && tarteaucitron.cookie.owner[name].join(' // ') !== savedname) {
  1400. savedname = tarteaucitron.cookie.owner[name].join(' // ');
  1401. html += '<div class="tarteaucitronHidden">';
  1402. html += ' <span class="tarteaucitronTitle tarteaucitronH3" role="heading" aria-level="3">';
  1403. html += ' ' + tarteaucitron.cookie.owner[name].join(' // ');
  1404. html += ' </span>';
  1405. html += '</div><ul class="cookie-list">';
  1406. } else if (tarteaucitron.cookie.owner[name] === undefined && host !== savedname) {
  1407. savedname = host;
  1408. html += '<div class="tarteaucitronHidden">';
  1409. html += ' <span class="tarteaucitronTitle tarteaucitronH3" role="heading" aria-level="3">';
  1410. html += ' ' + host;
  1411. html += ' </span>';
  1412. html += '</div><ul class="cookie-list">';
  1413. }
  1414. html += '<li class="tarteaucitronCookiesListMain">';
  1415. html += ' <div class="tarteaucitronCookiesListLeft"><button type="button" class="purgeBtn" data-cookie="' + tarteaucitron.fixSelfXSS(cookies[i].split('=', 1)) + '"><strong>&times;</strong></button> <strong>' + tarteaucitron.fixSelfXSS(name) + '</strong>';
  1416. html += ' </div>';
  1417. html += ' <div class="tarteaucitronCookiesListRight">' + tarteaucitron.fixSelfXSS(cookies[i].split('=').slice(1).join('=')) + '</div>';
  1418. html += '</li>';
  1419. }
  1420. html += '</ul>';
  1421. } else {
  1422. html += '<div class="tarteaucitronCookiesListMain">';
  1423. html += ' <div class="tarteaucitronCookiesListLeft"><strong>-</strong></div>';
  1424. html += ' <div class="tarteaucitronCookiesListRight"></div>';
  1425. html += '</div>';
  1426. }
  1427. html += '<div class="tarteaucitronHidden tarteaucitron-spacer-20"></div>';
  1428. if (document.getElementById('tarteaucitronCookiesList') !== null) {
  1429. document.getElementById('tarteaucitronCookiesList').innerHTML = html;
  1430. }
  1431. if (document.getElementById('tarteaucitronCookiesNumber') !== null) {
  1432. document.getElementById('tarteaucitronCookiesNumber').innerHTML = nb;
  1433. }
  1434. if (document.getElementById('tarteaucitronCookiesNumberBis') !== null) {
  1435. document.getElementById('tarteaucitronCookiesNumberBis').innerHTML = nb + ' cookie' + s;
  1436. }
  1437. var purgeBtns = document.getElementsByClassName("purgeBtn");
  1438. for (i = 0; i < purgeBtns.length; i++) {
  1439. tarteaucitron.addClickEventToElement(purgeBtns[i], function () {
  1440. tarteaucitron.cookie.purge([this.dataset.cookie]);
  1441. tarteaucitron.cookie.number();
  1442. tarteaucitron.userInterface.jsSizing('cookie');
  1443. return false;
  1444. });
  1445. }
  1446. for (i = 0; i < tarteaucitron.job.length; i += 1) {
  1447. tarteaucitron.cookie.checkCount(tarteaucitron.job[i]);
  1448. }
  1449. }
  1450. },
  1451. "fixSelfXSS": function(html) {
  1452. fixed = html.toString().replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
  1453. return fixed;
  1454. },
  1455. "getLanguage": function () {
  1456. "use strict";
  1457. var availableLanguages = 'bg,ca,cn,cs,da,de,el,en,es,fi,fr,hu,it,ja,lv,nl,no,oc,pl,pt,ro,ru,se,sk,sv,tr,vi,zh',
  1458. defaultLanguage = 'en';
  1459. if (tarteaucitronForceLanguage !== '') {
  1460. if (availableLanguages.indexOf(tarteaucitronForceLanguage) !== -1) {
  1461. return tarteaucitronForceLanguage;
  1462. }
  1463. }
  1464. if (!navigator) { return 'en'; }
  1465. var lang = navigator.language || navigator.browserLanguage ||
  1466. navigator.systemLanguage || navigator.userLang || null,
  1467. userLanguage = lang ? lang.substr(0, 2) : null;
  1468. if (availableLanguages.indexOf(userLanguage) === -1) {
  1469. return defaultLanguage;
  1470. }
  1471. return userLanguage;
  1472. },
  1473. "getLocale": function () {
  1474. "use strict";
  1475. if (!navigator) { return 'en_US'; }
  1476. var lang = navigator.language || navigator.browserLanguage ||
  1477. navigator.systemLanguage || navigator.userLang || null,
  1478. userLanguage = lang ? lang.substr(0, 2) : null;
  1479. if (userLanguage === 'fr') {
  1480. return 'fr_FR';
  1481. } else if (userLanguage === 'en') {
  1482. return 'en_US';
  1483. } else if (userLanguage === 'de') {
  1484. return 'de_DE';
  1485. } else if (userLanguage === 'es') {
  1486. return 'es_ES';
  1487. } else if (userLanguage === 'it') {
  1488. return 'it_IT';
  1489. } else if (userLanguage === 'pt') {
  1490. return 'pt_PT';
  1491. } else if (userLanguage === 'nl') {
  1492. return 'nl_NL';
  1493. } else if (userLanguage === 'el') {
  1494. return 'el_EL';
  1495. } else {
  1496. return 'en_US';
  1497. }
  1498. },
  1499. "addScript": function (url, id, callback, execute, attrName, attrVal, internal) {
  1500. "use strict";
  1501. var script,
  1502. done = false;
  1503. if (execute === false) {
  1504. if (typeof callback === 'function') {
  1505. callback();
  1506. }
  1507. } else {
  1508. script = document.createElement('script');
  1509. script.id = (id !== undefined) ? id : '';
  1510. script.async = true;
  1511. script.src = url;
  1512. if (attrName !== undefined && attrVal !== undefined) {
  1513. script.setAttribute(attrName, attrVal);
  1514. }
  1515. if (typeof callback === 'function') {
  1516. if ( !tarteaucitron.parameters.useExternalJs || !internal ) {
  1517. script.onreadystatechange = script.onload = function () {
  1518. var state = script.readyState;
  1519. if (!done && (!state || /loaded|complete/.test(state))) {
  1520. done = true;
  1521. callback();
  1522. }
  1523. };
  1524. } else {
  1525. callback();
  1526. }
  1527. }
  1528. if ( !tarteaucitron.parameters.useExternalJs || !internal ) {
  1529. document.getElementsByTagName('head')[0].appendChild(script);
  1530. }
  1531. }
  1532. },
  1533. "addInternalScript": function (url, id, callback, execute, attrName, attrVal) {
  1534. tarteaucitron.addScript(url, id, callback, execute, attrName, attrVal, true);
  1535. },
  1536. "makeAsync": {
  1537. "antiGhost": 0,
  1538. "buffer": '',
  1539. "init": function (url, id) {
  1540. "use strict";
  1541. var savedWrite = document.write,
  1542. savedWriteln = document.writeln;
  1543. document.write = function (content) {
  1544. tarteaucitron.makeAsync.buffer += content;
  1545. };
  1546. document.writeln = function (content) {
  1547. tarteaucitron.makeAsync.buffer += content.concat("\n");
  1548. };
  1549. setTimeout(function () {
  1550. document.write = savedWrite;
  1551. document.writeln = savedWriteln;
  1552. }, 20000);
  1553. tarteaucitron.makeAsync.getAndParse(url, id);
  1554. },
  1555. "getAndParse": function (url, id) {
  1556. "use strict";
  1557. if (tarteaucitron.makeAsync.antiGhost > 9) {
  1558. tarteaucitron.makeAsync.antiGhost = 0;
  1559. return;
  1560. }
  1561. tarteaucitron.makeAsync.antiGhost += 1;
  1562. tarteaucitron.addInternalScript(url, '', function () {
  1563. if (document.getElementById(id) !== null) {
  1564. document.getElementById(id).innerHTML += "<span class='tarteaucitron-display-none'>&nbsp;</span>" + tarteaucitron.makeAsync.buffer;
  1565. tarteaucitron.makeAsync.buffer = '';
  1566. tarteaucitron.makeAsync.execJS(id);
  1567. }
  1568. });
  1569. },
  1570. "execJS": function (id) {
  1571. /* not strict because third party scripts may have errors */
  1572. var i,
  1573. scripts,
  1574. childId,
  1575. type;
  1576. if (document.getElementById(id) === null) {
  1577. return;
  1578. }
  1579. scripts = document.getElementById(id).getElementsByTagName('script');
  1580. for (i = 0; i < scripts.length; i += 1) {
  1581. type = (scripts[i].getAttribute('type') !== null) ? scripts[i].getAttribute('type') : '';
  1582. if (type === '') {
  1583. type = (scripts[i].getAttribute('language') !== null) ? scripts[i].getAttribute('language') : '';
  1584. }
  1585. if (scripts[i].getAttribute('src') !== null && scripts[i].getAttribute('src') !== '') {
  1586. childId = id + Math.floor(Math.random() * 99999999999);
  1587. document.getElementById(id).innerHTML += '<div id="' + childId + '"></div>';
  1588. tarteaucitron.makeAsync.getAndParse(scripts[i].getAttribute('src'), childId);
  1589. } else if (type.indexOf('javascript') !== -1 || type === '') {
  1590. eval(scripts[i].innerHTML);
  1591. }
  1592. }
  1593. }
  1594. },
  1595. "fallback": function (matchClass, content, noInner) {
  1596. "use strict";
  1597. var elems = document.getElementsByTagName('*'),
  1598. i,
  1599. index = 0;
  1600. for (i in elems) {
  1601. if (elems[i] !== undefined) {
  1602. for (index = 0; index < matchClass.length; index += 1) {
  1603. if ((' ' + elems[i].className + ' ')
  1604. .indexOf(' ' + matchClass[index] + ' ') > -1) {
  1605. if (typeof content === 'function') {
  1606. if (noInner === true) {
  1607. content(elems[i]);
  1608. } else {
  1609. elems[i].innerHTML = content(elems[i]);
  1610. }
  1611. } else {
  1612. elems[i].innerHTML = content;
  1613. }
  1614. }
  1615. }
  1616. }
  1617. }
  1618. },
  1619. "engage": function (id) {
  1620. "use strict";
  1621. var html = '',
  1622. r = Math.floor(Math.random() * 100000),
  1623. engage = tarteaucitron.services[id].name + ' ' + tarteaucitron.lang.fallback;
  1624. if (tarteaucitron.lang['engage-' + id] !== undefined) {
  1625. engage = tarteaucitron.lang['engage-' + id];
  1626. }
  1627. html += '<div class="tac_activate tac_activate_' + id + '">';
  1628. html += ' <div class="tac_float">';
  1629. html += ' ' + engage;
  1630. html += ' <button type="button" class="tarteaucitronAllow" id="Eng' + r + 'ed' + id + '">';
  1631. html += ' <span class="tarteaucitronCheck"></span> ' + tarteaucitron.lang.allow;
  1632. html += ' </button>';
  1633. html += ' </div>';
  1634. html += '</div>';
  1635. return html;
  1636. },
  1637. "extend": function (a, b) {
  1638. "use strict";
  1639. var prop;
  1640. for (prop in b) {
  1641. if (b.hasOwnProperty(prop)) {
  1642. a[prop] = b[prop];
  1643. }
  1644. }
  1645. },
  1646. "proTemp": '',
  1647. "proTimer": function () {
  1648. "use strict";
  1649. setTimeout(tarteaucitron.proPing, 500);
  1650. },
  1651. "pro": function (list) {
  1652. "use strict";
  1653. tarteaucitron.proTemp += list;
  1654. clearTimeout(tarteaucitron.proTimer);
  1655. tarteaucitron.proTimer = setTimeout(tarteaucitron.proPing, 500);
  1656. },
  1657. "proPing": function () {
  1658. "use strict";
  1659. if (tarteaucitron.uuid !== '' && tarteaucitron.uuid !== undefined && tarteaucitron.proTemp !== '') {
  1660. var div = document.getElementById('tarteaucitronPremium'),
  1661. timestamp = new Date().getTime(),
  1662. url = 'https://tarteaucitron.io/log/?';
  1663. if (div === null) {
  1664. return;
  1665. }
  1666. url += 'account=' + tarteaucitron.uuid + '&';
  1667. url += 'domain=' + tarteaucitron.domain + '&';
  1668. url += 'status=' + encodeURIComponent(tarteaucitron.proTemp) + '&';
  1669. url += '_time=' + timestamp;
  1670. div.innerHTML = '<img src="' + url + '" class="tarteaucitron-display-none" alt="" />';
  1671. tarteaucitron.proTemp = '';
  1672. }
  1673. tarteaucitron.cookie.number();
  1674. },
  1675. "AddOrUpdate" : function(source, custom){
  1676. /**
  1677. Utility function to Add or update the fields of obj1 with the ones in obj2
  1678. */
  1679. for(key in custom){
  1680. if(custom[key] instanceof Object){
  1681. source[key] = tarteaucitron.AddOrUpdate(source[key], custom[key]);
  1682. }else{
  1683. source[key] = custom[key];
  1684. }
  1685. }
  1686. return source;
  1687. },
  1688. "getElemWidth": function(elem) {
  1689. return elem.getAttribute('width') || elem.clientWidth;
  1690. },
  1691. "getElemHeight": function(elem) {
  1692. return elem.getAttribute('height') || elem.clientHeight;
  1693. },
  1694. "addClickEventToId": function (elemId, func) {
  1695. tarteaucitron.addClickEventToElement(document.getElementById(elemId), func);
  1696. },
  1697. "addClickEventToElement": function (e, func) {
  1698. if (e) {
  1699. if (e.addEventListener) {
  1700. e.addEventListener("click", func);
  1701. } else {
  1702. e.attachEvent("onclick", func);
  1703. }
  1704. }
  1705. },
  1706. "triggerJobsAfterAjaxCall": function() {
  1707. tarteaucitron.job.forEach(function(e) { tarteaucitron.job.push(e) });
  1708. var allowBtns = document.getElementsByClassName("tarteaucitronAllow");
  1709. for (i = 0; i < allowBtns.length; i++) {
  1710. tarteaucitron.addClickEventToElement(allowBtns[i], function () {
  1711. tarteaucitron.userInterface.respond(this, true);
  1712. });
  1713. }
  1714. var denyBtns = document.getElementsByClassName("tarteaucitronDeny");
  1715. for (i = 0; i < denyBtns.length; i++) {
  1716. tarteaucitron.addClickEventToElement(denyBtns[i], function () {
  1717. tarteaucitron.userInterface.respond(this, false);
  1718. });
  1719. }
  1720. }
  1721. };