tarteaucitron.js 87 KB

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