tarteaucitron.js 89 KB

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