tarteaucitron.js 87 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807
  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. },
  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 + '"><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>';
  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/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">';
  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"), i;
  565. for (i = 0; i < toggleBtns.length; i++) {
  566. toggleBtns[i].dataset.index = i;
  567. tarteaucitron.addClickEventToElement(toggleBtns[i], function () {
  568. tarteaucitron.userInterface.toggle('tarteaucitronDetails' + cat[this.dataset.index], 'tarteaucitronInfoBox');
  569. return false;
  570. });
  571. }
  572. var allowBtns = document.getElementsByClassName("tarteaucitronAllow");
  573. for (i = 0; i < allowBtns.length; i++) {
  574. tarteaucitron.addClickEventToElement(allowBtns[i], function () {
  575. tarteaucitron.userInterface.respond(this, true);
  576. });
  577. }
  578. var denyBtns = document.getElementsByClassName("tarteaucitronDeny");
  579. for (i = 0; i < denyBtns.length; i++) {
  580. tarteaucitron.addClickEventToElement(denyBtns[i], function () {
  581. tarteaucitron.userInterface.respond(this, false);
  582. });
  583. }
  584. }, 500);
  585. });
  586. });
  587. if(tarteaucitron.events.load) {
  588. tarteaucitron.events.load();
  589. }
  590. },
  591. "addService": function (serviceId) {
  592. "use strict";
  593. var html = '',
  594. s = tarteaucitron.services,
  595. service = s[serviceId],
  596. cookie = tarteaucitron.cookie.read(),
  597. hostname = document.location.hostname,
  598. hostRef = document.referrer.split('/')[2],
  599. isNavigating = (hostRef === hostname && window.location.href !== tarteaucitron.parameters.privacyUrl),
  600. isAutostart = (!service.needConsent),
  601. isWaiting = (cookie.indexOf(service.key + '=wait') >= 0),
  602. isDenied = (cookie.indexOf(service.key + '=false') >= 0),
  603. isAllowed = ((cookie.indexOf(service.key + '=true') >= 0) || (!service.needConsent && cookie.indexOf(service.key + '=false') < 0)),
  604. isResponded = (cookie.indexOf(service.key + '=false') >= 0 || cookie.indexOf(service.key + '=true') >= 0),
  605. isDNTRequested = (navigator.doNotTrack === "1" || navigator.doNotTrack === "yes" || navigator.msDoNotTrack === "1" || window.doNotTrack === "1");
  606. if (tarteaucitron.added[service.key] !== true) {
  607. tarteaucitron.added[service.key] = true;
  608. html += '<li id="' + service.key + 'Line" class="tarteaucitronLine">';
  609. html += ' <div class="tarteaucitronName">';
  610. html += ' <span class="tarteaucitronH3" role="heading" aria-level="3">' + service.name + '</span>';
  611. html += ' <span id="tacCL' + service.key + '" class="tarteaucitronListCookies"></span><br/>';
  612. if (tarteaucitron.parameters.moreInfoLink == true) {
  613. var link = 'https://tarteaucitron.io/service/' + service.key + '/';
  614. if (service.readmoreLink !== undefined && service.readmoreLink !== '') {
  615. link = service.readmoreLink;
  616. }
  617. if (tarteaucitron.parameters.readmoreLink !== undefined && tarteaucitron.parameters.readmoreLink !== '') {
  618. link = tarteaucitron.parameters.readmoreLink;
  619. }
  620. html += ' <a href="' + link + '" target="_blank" rel="noreferrer noopener nofollow" title="'+ tarteaucitron.lang.cookieDetail + ' ' + service.name + ' ' + tarteaucitron.lang.ourSite + ' ' + tarteaucitron.lang.newWindow +'">';
  621. html += ' ' + tarteaucitron.lang.more;
  622. html += ' </a>';
  623. html += ' - ';
  624. html += ' <a href="' + service.uri + '" target="_blank" rel="noreferrer noopener" title="' + service.name + ' ' + tarteaucitron.lang.newWindow + '">';
  625. html += ' ' + tarteaucitron.lang.source;
  626. html += ' </a>';
  627. }
  628. html += ' </div>';
  629. html += ' <div class="tarteaucitronAsk">';
  630. html += ' <button type="button" id="' + service.key + 'Allowed" class="tarteaucitronAllow">';
  631. html += ' <span class="tarteaucitronCheck"></span> ' + tarteaucitron.lang.allow;
  632. html += ' </button> ';
  633. html += ' <button type="button" id="' + service.key + 'Denied" class="tarteaucitronDeny">';
  634. html += ' <span class="tarteaucitronCross"></span> ' + tarteaucitron.lang.deny;
  635. html += ' </button>';
  636. html += ' </div>';
  637. html += '</li>';
  638. tarteaucitron.userInterface.css('tarteaucitronServicesTitle_' + service.type, 'display', 'block');
  639. if (document.getElementById('tarteaucitronServices_' + service.type) !== null) {
  640. document.getElementById('tarteaucitronServices_' + service.type).innerHTML += html;
  641. }
  642. tarteaucitron.userInterface.css('tarteaucitronNoServicesTitle', 'display', 'none');
  643. tarteaucitron.userInterface.order(service.type);
  644. tarteaucitron.addClickEventToId(service.key + 'Allowed', function () {
  645. tarteaucitron.userInterface.respond(this, true);
  646. });
  647. tarteaucitron.addClickEventToId(service.key + 'Denied', function () {
  648. tarteaucitron.userInterface.respond(this, false);
  649. });
  650. }
  651. tarteaucitron.pro('!' + service.key + '=' + isAllowed);
  652. // allow by default for non EU
  653. if (isResponded === false && tarteaucitron.user.bypass === true) {
  654. isAllowed = true;
  655. tarteaucitron.cookie.create(service.key, true);
  656. }
  657. if ((!isResponded && (isAutostart || (isNavigating && isWaiting)) && !tarteaucitron.highPrivacy) || isAllowed) {
  658. if (!isAllowed || (!service.needConsent && cookie.indexOf(service.key + '=false') < 0)) {
  659. tarteaucitron.cookie.create(service.key, true);
  660. }
  661. if (tarteaucitron.launch[service.key] !== true) {
  662. tarteaucitron.launch[service.key] = true;
  663. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + service.key + "_") < 0) { service.js(); }
  664. tarteaucitron.sendEvent(service.key + '_loaded');
  665. }
  666. tarteaucitron.state[service.key] = true;
  667. tarteaucitron.userInterface.color(service.key, true);
  668. } else if (isDenied) {
  669. if (typeof service.fallback === 'function') {
  670. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + service.key + "_") < 0) { service.fallback(); }
  671. }
  672. tarteaucitron.state[service.key] = false;
  673. tarteaucitron.userInterface.color(service.key, false);
  674. } else if (!isResponded && isDNTRequested && tarteaucitron.handleBrowserDNTRequest) {
  675. tarteaucitron.cookie.create(service.key, 'false');
  676. if (typeof service.fallback === 'function') {
  677. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + service.key + "_") < 0) { service.fallback(); }
  678. }
  679. tarteaucitron.state[service.key] = false;
  680. tarteaucitron.userInterface.color(service.key, false);
  681. } else if (!isResponded) {
  682. tarteaucitron.cookie.create(service.key, 'wait');
  683. if (typeof service.fallback === 'function') {
  684. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + service.key + "_") < 0) { service.fallback(); }
  685. }
  686. tarteaucitron.userInterface.color(service.key, 'wait');
  687. tarteaucitron.userInterface.openAlert();
  688. }
  689. tarteaucitron.cookie.checkCount(service.key);
  690. tarteaucitron.sendEvent(service.key + '_added')
  691. },
  692. "sendEvent" : function(event_key) {
  693. if(event_key !== undefined) {
  694. //ie compatibility
  695. var send_event_item;
  696. if(typeof(Event) === 'function') {
  697. send_event_item = new Event(event_key);
  698. }else{
  699. send_event_item = document.createEvent('Event');
  700. send_event_item.initEvent(event_key, true, true);
  701. }
  702. //end ie compatibility
  703. document.dispatchEvent(send_event_item);
  704. }
  705. },
  706. "cleanArray": function cleanArray(arr) {
  707. "use strict";
  708. var i,
  709. len = arr.length,
  710. out = [],
  711. obj = {},
  712. s = tarteaucitron.services;
  713. for (i = 0; i < len; i += 1) {
  714. if (!obj[arr[i]]) {
  715. obj[arr[i]] = {};
  716. if (tarteaucitron.services[arr[i]] !== undefined) {
  717. out.push(arr[i]);
  718. }
  719. }
  720. }
  721. out = out.sort(function (a, b) {
  722. if (s[a].type + s[a].key > s[b].type + s[b].key) { return 1; }
  723. if (s[a].type + s[a].key < s[b].type + s[b].key) { return -1; }
  724. return 0;
  725. });
  726. return out;
  727. },
  728. "userInterface": {
  729. "css": function (id, property, value) {
  730. "use strict";
  731. if (document.getElementById(id) !== null) {
  732. if (property == "display" && value == "none" && (id == "tarteaucitron" || id == "tarteaucitronBack" || id == "tarteaucitronAlertBig")) {
  733. document.getElementById(id).style["opacity"] = "0";
  734. setTimeout(function() {document.getElementById(id).style[property] = value;}, 200);
  735. } else {
  736. document.getElementById(id).style[property] = value;
  737. if (property == "display" && value == "block" && (id == "tarteaucitron" || id == "tarteaucitronAlertBig")) {
  738. document.getElementById(id).style["opacity"] = "0";
  739. setTimeout(function() {document.getElementById(id).style["opacity"] = "1";}, 1);
  740. }
  741. if (property == "display" && value == "block" && id == "tarteaucitronBack") {
  742. document.getElementById(id).style["opacity"] = "0";
  743. setTimeout(function() {document.getElementById(id).style["opacity"] = "0.7";}, 1);
  744. }
  745. }
  746. }
  747. },
  748. "addClass": function (id, className) {
  749. "use strict";
  750. if (document.getElementById(id) !== null) {
  751. document.getElementById(id).classList.add(className);
  752. }
  753. },
  754. "removeClass": function (id, className) {
  755. "use strict";
  756. if (document.getElementById(id) !== null) {
  757. document.getElementById(id).classList.remove(className);
  758. }
  759. },
  760. "respondAll": function (status) {
  761. "use strict";
  762. var s = tarteaucitron.services,
  763. service,
  764. key,
  765. index = 0;
  766. for (index = 0; index < tarteaucitron.job.length; index += 1) {
  767. service = s[tarteaucitron.job[index]];
  768. key = service.key;
  769. if (tarteaucitron.state[key] !== status) {
  770. if (status === false && tarteaucitron.launch[key] === true) {
  771. tarteaucitron.reloadThePage = true;
  772. }
  773. if (tarteaucitron.launch[key] !== true && status === true) {
  774. tarteaucitron.pro('!' + key + '=engage');
  775. tarteaucitron.launch[key] = true;
  776. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + key + "_") < 0) { tarteaucitron.services[key].js(); }
  777. tarteaucitron.sendEvent(key + '_loaded');
  778. }
  779. tarteaucitron.state[key] = status;
  780. tarteaucitron.cookie.create(key, status);
  781. tarteaucitron.userInterface.color(key, status);
  782. }
  783. }
  784. },
  785. "respond": function (el, status) {
  786. "use strict";
  787. if (el.id === '') {
  788. return;
  789. }
  790. var key = el.id.replace(new RegExp("(Eng[0-9]+|Allow|Deni)ed", "g"), '');
  791. if (key.substring(0, 13) === 'tarteaucitron' || key === '') {return;}
  792. // return if same state
  793. if (tarteaucitron.state[key] === status) {
  794. return;
  795. }
  796. if (status === false && tarteaucitron.launch[key] === true) {
  797. tarteaucitron.reloadThePage = true;
  798. }
  799. // if not already launched... launch the service
  800. if (status === true) {
  801. if (tarteaucitron.launch[key] !== true) {
  802. tarteaucitron.pro('!' + key + '=engage');
  803. tarteaucitron.launch[key] = true;
  804. tarteaucitron.sendEvent(key + '_loaded');
  805. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + key + "_") < 0) { tarteaucitron.services[key].js(); }
  806. }
  807. }
  808. tarteaucitron.state[key] = status;
  809. tarteaucitron.cookie.create(key, status);
  810. tarteaucitron.userInterface.color(key, status);
  811. },
  812. "color": function (key, status) {
  813. "use strict";
  814. var c = 'tarteaucitron',
  815. nbDenied = 0,
  816. nbPending = 0,
  817. nbAllowed = 0,
  818. sum = tarteaucitron.job.length,
  819. index;
  820. if (status === true) {
  821. document.getElementById(key + 'Line').classList.add('tarteaucitronIsAllowed');
  822. document.getElementById(key + 'Line').classList.remove('tarteaucitronIsDenied');
  823. } else if (status === false) {
  824. document.getElementById(key + 'Line').classList.remove('tarteaucitronIsAllowed');
  825. document.getElementById(key + 'Line').classList.add('tarteaucitronIsDenied');
  826. }
  827. // check if all services are allowed
  828. for (index = 0; index < sum; index += 1) {
  829. if (tarteaucitron.state[tarteaucitron.job[index]] === false) {
  830. nbDenied += 1;
  831. } else if (tarteaucitron.state[tarteaucitron.job[index]] === undefined) {
  832. nbPending += 1;
  833. } else if (tarteaucitron.state[tarteaucitron.job[index]] === true) {
  834. nbAllowed += 1;
  835. }
  836. }
  837. tarteaucitron.userInterface.css(c + 'DotGreen', 'width', ((100 / sum) * nbAllowed) + '%');
  838. tarteaucitron.userInterface.css(c + 'DotYellow', 'width', ((100 / sum) * nbPending) + '%');
  839. tarteaucitron.userInterface.css(c + 'DotRed', 'width', ((100 / sum) * nbDenied) + '%');
  840. if (nbDenied === 0 && nbPending === 0) {
  841. tarteaucitron.userInterface.removeClass(c + 'AllDenied', c + 'IsSelected');
  842. tarteaucitron.userInterface.addClass(c + 'AllAllowed', c + 'IsSelected');
  843. tarteaucitron.userInterface.addClass(c + 'MainLineOffset', c + 'IsAllowed');
  844. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsDenied');
  845. } else if (nbAllowed === 0 && nbPending === 0) {
  846. tarteaucitron.userInterface.removeClass(c + 'AllAllowed', c + 'IsSelected');
  847. tarteaucitron.userInterface.addClass(c + 'AllDenied', c + 'IsSelected');
  848. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsAllowed');
  849. tarteaucitron.userInterface.addClass(c + 'MainLineOffset', c + 'IsDenied');
  850. } else {
  851. tarteaucitron.userInterface.removeClass(c + 'AllAllowed', c + 'IsSelected');
  852. tarteaucitron.userInterface.removeClass(c + 'AllDenied', c + 'IsSelected');
  853. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsAllowed');
  854. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsDenied');
  855. }
  856. // close the alert if all service have been reviewed
  857. if (nbPending === 0) {
  858. tarteaucitron.userInterface.closeAlert();
  859. }
  860. if (tarteaucitron.services[key].cookies.length > 0 && status === false) {
  861. tarteaucitron.cookie.purge(tarteaucitron.services[key].cookies);
  862. }
  863. if (status === true) {
  864. if (document.getElementById('tacCL' + key) !== null) {
  865. document.getElementById('tacCL' + key).innerHTML = '...';
  866. }
  867. setTimeout(function () {
  868. tarteaucitron.cookie.checkCount(key);
  869. }, 2500);
  870. } else {
  871. tarteaucitron.cookie.checkCount(key);
  872. }
  873. },
  874. "openPanel": function () {
  875. "use strict";
  876. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'block');
  877. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
  878. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
  879. document.getElementById('tarteaucitronClosePanel').focus();
  880. document.getElementsByTagName('body')[0].classList.add('modal-open');
  881. tarteaucitron.userInterface.focusTrap();
  882. tarteaucitron.userInterface.jsSizing('main');
  883. //ie compatibility
  884. var tacOpenPanelEvent;
  885. if(typeof(Event) === 'function') {
  886. tacOpenPanelEvent = new Event("tac.open_panel");
  887. }else{
  888. tacOpenPanelEvent = document.createEvent('Event');
  889. tacOpenPanelEvent.initEvent("tac.open_panel", true, true);
  890. }
  891. //end ie compatibility
  892. window.dispatchEvent(tacOpenPanelEvent);
  893. },
  894. "closePanel": function () {
  895. "use strict";
  896. if (document.location.hash === tarteaucitron.hashtag) {
  897. if (window.history) {
  898. window.history.replaceState('', document.title, window.location.pathname + window.location.search);
  899. } else {
  900. document.location.hash = '';
  901. }
  902. }
  903. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  904. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
  905. tarteaucitron.fallback(['tarteaucitronInfoBox'], function (elem) {
  906. elem.style.display = 'none';
  907. }, true);
  908. if (tarteaucitron.reloadThePage === true) {
  909. window.location.reload();
  910. } else {
  911. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
  912. }
  913. if (document.getElementById('tarteaucitronCloseAlert') !== null) {
  914. document.getElementById('tarteaucitronCloseAlert').focus();
  915. }
  916. document.getElementsByTagName('body')[0].classList.remove('modal-open');
  917. //ie compatibility
  918. var tacClosePanelEvent;
  919. if(typeof(Event) === 'function') {
  920. tacClosePanelEvent = new Event("tac.close_panel");
  921. }else{
  922. tacClosePanelEvent = document.createEvent('Event');
  923. tacClosePanelEvent.initEvent("tac.close_panel", true, true);
  924. }
  925. //end ie compatibility
  926. window.dispatchEvent(tacClosePanelEvent);
  927. },
  928. "focusTrap": function() {
  929. "use strict";
  930. var focusableEls,
  931. firstFocusableEl,
  932. lastFocusableEl,
  933. filtered;
  934. focusableEls = document.getElementById('tarteaucitron').querySelectorAll('a[href], button');
  935. filtered = [];
  936. // get only visible items
  937. for (var i = 0, max = focusableEls.length; i < max; i++) {
  938. if (focusableEls[i].offsetHeight > 0) {
  939. filtered.push(focusableEls[i]);
  940. }
  941. }
  942. firstFocusableEl = filtered[0];
  943. lastFocusableEl = filtered[filtered.length - 1];
  944. //loop focus inside tarteaucitron
  945. document.getElementById('tarteaucitron').addEventListener("keydown", function (evt) {
  946. if ( evt.key === 'Tab' || evt.keyCode === 9 ) {
  947. if ( evt.shiftKey ) /* shift + tab */ {
  948. if (document.activeElement === firstFocusableEl) {
  949. lastFocusableEl.focus();
  950. evt.preventDefault();
  951. }
  952. } else /* tab */ {
  953. if (document.activeElement === lastFocusableEl) {
  954. firstFocusableEl.focus();
  955. evt.preventDefault();
  956. }
  957. }
  958. }
  959. })
  960. },
  961. "openAlert": function () {
  962. "use strict";
  963. var c = 'tarteaucitron';
  964. tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'block');
  965. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'none');
  966. tarteaucitron.userInterface.css(c + 'Icon', 'display', 'none');
  967. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'block');
  968. tarteaucitron.userInterface.addClass(c + 'Root', 'tarteaucitronBeforeVisible');
  969. //ie compatibility
  970. var tacOpenAlertEvent;
  971. if(typeof(Event) === 'function') {
  972. tacOpenAlertEvent = new Event("tac.open_alert");
  973. }else{
  974. tacOpenAlertEvent = document.createEvent('Event');
  975. tacOpenAlertEvent.initEvent("tac.open_alert", true, true);
  976. }
  977. //end ie compatibility
  978. window.dispatchEvent(tacOpenAlertEvent);
  979. },
  980. "closeAlert": function () {
  981. "use strict";
  982. var c = 'tarteaucitron';
  983. tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'none');
  984. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'block');
  985. tarteaucitron.userInterface.css(c + 'Icon', 'display', 'block');
  986. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'none');
  987. tarteaucitron.userInterface.removeClass(c + 'Root', 'tarteaucitronBeforeVisible');
  988. tarteaucitron.userInterface.jsSizing('box');
  989. //ie compatibility
  990. var tacCloseAlertEvent;
  991. if(typeof(Event) === 'function') {
  992. tacCloseAlertEvent = new Event("tac.close_alert");
  993. }else{
  994. tacCloseAlertEvent = document.createEvent('Event');
  995. tacCloseAlertEvent.initEvent("tac.close_alert", true, true);
  996. }
  997. //end ie compatibility
  998. window.dispatchEvent(tacCloseAlertEvent);
  999. },
  1000. "toggleCookiesList": function () {
  1001. "use strict";
  1002. var div = document.getElementById('tarteaucitronCookiesListContainer');
  1003. if (div === null) {
  1004. return;
  1005. }
  1006. if (div.style.display !== 'block') {
  1007. tarteaucitron.cookie.number();
  1008. div.style.display = 'block';
  1009. tarteaucitron.userInterface.jsSizing('cookie');
  1010. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  1011. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
  1012. tarteaucitron.fallback(['tarteaucitronInfoBox'], function (elem) {
  1013. elem.style.display = 'none';
  1014. }, true);
  1015. } else {
  1016. div.style.display = 'none';
  1017. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  1018. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
  1019. }
  1020. },
  1021. "toggle": function (id, closeClass) {
  1022. "use strict";
  1023. var div = document.getElementById(id);
  1024. if (div === null) {
  1025. return;
  1026. }
  1027. if (closeClass !== undefined) {
  1028. tarteaucitron.fallback([closeClass], function (elem) {
  1029. if (elem.id !== id) {
  1030. elem.style.display = 'none';
  1031. }
  1032. }, true);
  1033. }
  1034. if (div.style.display !== 'block') {
  1035. div.style.display = 'block';
  1036. } else {
  1037. div.style.display = 'none';
  1038. }
  1039. },
  1040. "order": function (id) {
  1041. "use strict";
  1042. var main = document.getElementById('tarteaucitronServices_' + id),
  1043. allDivs,
  1044. store = [],
  1045. i;
  1046. if (main === null) {
  1047. return;
  1048. }
  1049. allDivs = main.childNodes;
  1050. if (typeof Array.prototype.map === 'function' && typeof Enumerable === 'undefined') {
  1051. Array.prototype.map.call(main.children, Object).sort(function (a, b) {
  1052. //var mainChildren = Array.from(main.children);
  1053. //mainChildren.sort(function (a, b) {
  1054. if (tarteaucitron.services[a.id.replace(/Line/g, '')].name > tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return 1; }
  1055. if (tarteaucitron.services[a.id.replace(/Line/g, '')].name < tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return -1; }
  1056. return 0;
  1057. }).forEach(function (element) {
  1058. main.appendChild(element);
  1059. });
  1060. }
  1061. },
  1062. "jsSizing": function (type) {
  1063. "use strict";
  1064. var scrollbarMarginRight = 10,
  1065. scrollbarWidthParent,
  1066. scrollbarWidthChild,
  1067. servicesHeight,
  1068. e = window,
  1069. a = 'inner',
  1070. windowInnerHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
  1071. mainTop,
  1072. mainHeight,
  1073. closeButtonHeight,
  1074. headerHeight,
  1075. cookiesListHeight,
  1076. cookiesCloseHeight,
  1077. cookiesTitleHeight,
  1078. paddingBox,
  1079. alertSmallHeight,
  1080. cookiesNumberHeight;
  1081. if (type === 'box') {
  1082. if (document.getElementById('tarteaucitronAlertSmall') !== null && document.getElementById('tarteaucitronCookiesNumber') !== null) {
  1083. // reset
  1084. tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', '0px 10px');
  1085. // calculate
  1086. alertSmallHeight = document.getElementById('tarteaucitronAlertSmall').offsetHeight;
  1087. cookiesNumberHeight = document.getElementById('tarteaucitronCookiesNumber').offsetHeight;
  1088. paddingBox = (alertSmallHeight - cookiesNumberHeight) / 2;
  1089. // apply
  1090. tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', paddingBox + 'px 10px');
  1091. }
  1092. } else if (type === 'main') {
  1093. // get the real window width for media query
  1094. if (window.innerWidth === undefined) {
  1095. a = 'client';
  1096. e = document.documentElement || document.body;
  1097. }
  1098. // height of the services list container
  1099. if (document.getElementById('tarteaucitron') !== null && document.getElementById('tarteaucitronClosePanel') !== null && document.getElementById('tarteaucitronMainLineOffset') !== null) {
  1100. // reset
  1101. tarteaucitron.userInterface.css('tarteaucitronServices', 'height', 'auto');
  1102. // calculate
  1103. mainHeight = document.getElementById('tarteaucitron').offsetHeight;
  1104. closeButtonHeight = document.getElementById('tarteaucitronClosePanel').offsetHeight;
  1105. // apply
  1106. servicesHeight = (mainHeight - closeButtonHeight + 2);
  1107. tarteaucitron.userInterface.css('tarteaucitronServices', 'height', servicesHeight + 'px');
  1108. tarteaucitron.userInterface.css('tarteaucitronServices', 'overflow-x', 'auto');
  1109. }
  1110. // align the main allow/deny button depending on scrollbar width
  1111. if (document.getElementById('tarteaucitronServices') !== null && document.getElementById('tarteaucitronScrollbarChild') !== null) {
  1112. // media query
  1113. if (e[a + 'Width'] <= 479) {
  1114. //tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginLeft', '11px');
  1115. } else if (e[a + 'Width'] <= 767) {
  1116. scrollbarMarginRight = 12;
  1117. }
  1118. scrollbarWidthParent = document.getElementById('tarteaucitronServices').offsetWidth;
  1119. scrollbarWidthChild = document.getElementById('tarteaucitronScrollbarChild').offsetWidth;
  1120. //tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginRight', ((scrollbarWidthParent - scrollbarWidthChild) + scrollbarMarginRight) + 'px');
  1121. }
  1122. // center the main panel
  1123. if (document.getElementById('tarteaucitron') !== null) {
  1124. // media query
  1125. if (e[a + 'Width'] <= 767) {
  1126. mainTop = 0;
  1127. } else {
  1128. mainTop = ((windowInnerHeight - document.getElementById('tarteaucitron').offsetHeight) / 2) - 21;
  1129. }
  1130. if (document.getElementById('tarteaucitronMainLineOffset') !== null) {
  1131. if (document.getElementById('tarteaucitron').offsetHeight < (windowInnerHeight / 2)) {
  1132. mainTop -= document.getElementById('tarteaucitronMainLineOffset').offsetHeight;
  1133. }
  1134. }
  1135. // correct
  1136. if (mainTop < 0) {
  1137. mainTop = 0;
  1138. }
  1139. // apply
  1140. tarteaucitron.userInterface.css('tarteaucitron', 'top', mainTop + 'px');
  1141. }
  1142. } else if (type === 'cookie') {
  1143. // put cookies list at bottom
  1144. if (document.getElementById('tarteaucitronAlertSmall') !== null) {
  1145. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'bottom', (document.getElementById('tarteaucitronAlertSmall').offsetHeight) + 'px');
  1146. }
  1147. // height of cookies list
  1148. if (document.getElementById('tarteaucitronCookiesListContainer') !== null) {
  1149. // reset
  1150. tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', 'auto');
  1151. // calculate
  1152. cookiesListHeight = document.getElementById('tarteaucitronCookiesListContainer').offsetHeight;
  1153. cookiesCloseHeight = document.getElementById('tarteaucitronClosePanelCookie').offsetHeight;
  1154. cookiesTitleHeight = document.getElementById('tarteaucitronCookiesTitle').offsetHeight;
  1155. // apply
  1156. tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', (cookiesListHeight - cookiesCloseHeight - cookiesTitleHeight - 2) + 'px');
  1157. }
  1158. }
  1159. }
  1160. },
  1161. "cookie": {
  1162. "owner": {},
  1163. "create": function (key, status) {
  1164. "use strict";
  1165. if (tarteaucitronForceExpire !== '') {
  1166. // The number of day(s)/hour(s) can't be higher than 1 year
  1167. if ((tarteaucitronExpireInDay && tarteaucitronForceExpire < 365) || (!tarteaucitronExpireInDay && tarteaucitronForceExpire < 8760)) {
  1168. if (tarteaucitronExpireInDay) {
  1169. // Multiplication to tranform the number of days to milliseconds
  1170. timeExpire = tarteaucitronForceExpire * 86400000;
  1171. } else {
  1172. // Multiplication to tranform the number of hours to milliseconds
  1173. timeExpire = tarteaucitronForceExpire * 3600000;
  1174. }
  1175. }
  1176. }
  1177. var d = new Date(),
  1178. time = d.getTime(),
  1179. expireTime = time + timeExpire, // 365 days
  1180. regex = new RegExp("!" + key + "=(wait|true|false)", "g"),
  1181. cookie = tarteaucitron.cookie.read().replace(regex, ""),
  1182. value = tarteaucitron.parameters.cookieName + '=' + cookie + '!' + key + '=' + status,
  1183. domain = (tarteaucitron.parameters.cookieDomain !== undefined && tarteaucitron.parameters.cookieDomain !== '') ? '; domain=' + tarteaucitron.parameters.cookieDomain : '',
  1184. secure = location.protocol === 'https:' ? '; Secure' : '';
  1185. d.setTime(expireTime);
  1186. document.cookie = value + '; expires=' + d.toGMTString() + '; path=/' + domain + secure + '; samesite=lax';
  1187. },
  1188. "read": function () {
  1189. "use strict";
  1190. var nameEQ = tarteaucitron.parameters.cookieName + "=",
  1191. ca = document.cookie.split(';'),
  1192. i,
  1193. c;
  1194. for (i = 0; i < ca.length; i += 1) {
  1195. c = ca[i];
  1196. while (c.charAt(0) === ' ') {
  1197. c = c.substring(1, c.length);
  1198. }
  1199. if (c.indexOf(nameEQ) === 0) {
  1200. return c.substring(nameEQ.length, c.length);
  1201. }
  1202. }
  1203. return '';
  1204. },
  1205. "purge": function (arr) {
  1206. "use strict";
  1207. var i;
  1208. for (i = 0; i < arr.length; i += 1) {
  1209. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/;';
  1210. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname + ';';
  1211. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname.split('.').slice(-2).join('.') + ';';
  1212. }
  1213. },
  1214. "checkCount": function (key) {
  1215. "use strict";
  1216. var arr = tarteaucitron.services[key].cookies,
  1217. nb = arr.length,
  1218. nbCurrent = 0,
  1219. html = '',
  1220. i,
  1221. status = document.cookie.indexOf(key + '=true');
  1222. if (status >= 0 && nb === 0) {
  1223. html += tarteaucitron.lang.useNoCookie;
  1224. } else if (status >= 0) {
  1225. for (i = 0; i < nb; i += 1) {
  1226. if (document.cookie.indexOf(arr[i] + '=') !== -1) {
  1227. nbCurrent += 1;
  1228. if (tarteaucitron.cookie.owner[arr[i]] === undefined) {
  1229. tarteaucitron.cookie.owner[arr[i]] = [];
  1230. }
  1231. if (tarteaucitron.cookie.crossIndexOf(tarteaucitron.cookie.owner[arr[i]], tarteaucitron.services[key].name) === false) {
  1232. tarteaucitron.cookie.owner[arr[i]].push(tarteaucitron.services[key].name);
  1233. }
  1234. }
  1235. }
  1236. if (nbCurrent > 0) {
  1237. html += tarteaucitron.lang.useCookieCurrent + ' ' + nbCurrent + ' cookie';
  1238. if (nbCurrent > 1) {
  1239. html += 's';
  1240. }
  1241. html += '.';
  1242. } else {
  1243. html += tarteaucitron.lang.useNoCookie;
  1244. }
  1245. } else if (nb === 0) {
  1246. html = tarteaucitron.lang.noCookie;
  1247. } else {
  1248. html += tarteaucitron.lang.useCookie + ' ' + nb + ' cookie';
  1249. if (nb > 1) {
  1250. html += 's';
  1251. }
  1252. html += '.';
  1253. }
  1254. if (document.getElementById('tacCL' + key) !== null) {
  1255. document.getElementById('tacCL' + key).innerHTML = html;
  1256. }
  1257. },
  1258. "crossIndexOf": function (arr, match) {
  1259. "use strict";
  1260. var i;
  1261. for (i = 0; i < arr.length; i += 1) {
  1262. if (arr[i] === match) {
  1263. return true;
  1264. }
  1265. }
  1266. return false;
  1267. },
  1268. "number": function () {
  1269. "use strict";
  1270. var cookies = document.cookie.split(';'),
  1271. nb = (document.cookie !== '') ? cookies.length : 0,
  1272. html = '',
  1273. i,
  1274. name,
  1275. namea,
  1276. nameb,
  1277. c,
  1278. d,
  1279. s = (nb > 1) ? 's' : '',
  1280. savedname,
  1281. regex = /^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i,
  1282. regexedDomain = (tarteaucitron.cdn.match(regex) !== null) ? tarteaucitron.cdn.match(regex)[1] : tarteaucitron.cdn,
  1283. host = (tarteaucitron.domain !== undefined) ? tarteaucitron.domain : regexedDomain;
  1284. cookies = cookies.sort(function (a, b) {
  1285. namea = a.split('=', 1).toString().replace(/ /g, '');
  1286. nameb = b.split('=', 1).toString().replace(/ /g, '');
  1287. c = (tarteaucitron.cookie.owner[namea] !== undefined) ? tarteaucitron.cookie.owner[namea] : '0';
  1288. d = (tarteaucitron.cookie.owner[nameb] !== undefined) ? tarteaucitron.cookie.owner[nameb] : '0';
  1289. if (c + a > d + b) { return 1; }
  1290. if (c + a < d + b) { return -1; }
  1291. return 0;
  1292. });
  1293. if (document.cookie !== '') {
  1294. for (i = 0; i < nb; i += 1) {
  1295. name = cookies[i].split('=', 1).toString().replace(/ /g, '');
  1296. if (tarteaucitron.cookie.owner[name] !== undefined && tarteaucitron.cookie.owner[name].join(' // ') !== savedname) {
  1297. savedname = tarteaucitron.cookie.owner[name].join(' // ');
  1298. html += '<div class="tarteaucitronHidden">';
  1299. html += ' <span class="tarteaucitronTitle tarteaucitronH3" role="heading" aria-level="3">';
  1300. html += ' ' + tarteaucitron.cookie.owner[name].join(' // ');
  1301. html += ' </span>';
  1302. html += '</div><ul class="cookie-list">';
  1303. } else if (tarteaucitron.cookie.owner[name] === undefined && host !== savedname) {
  1304. savedname = host;
  1305. html += '<div class="tarteaucitronHidden">';
  1306. html += ' <span class="tarteaucitronTitle tarteaucitronH3" role="heading" aria-level="3">';
  1307. html += ' ' + host;
  1308. html += ' </span>';
  1309. html += '</div><ul class="cookie-list">';
  1310. }
  1311. html += '<li class="tarteaucitronCookiesListMain">';
  1312. 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>';
  1313. html += ' </div>';
  1314. html += ' <div class="tarteaucitronCookiesListRight">' + tarteaucitron.fixSelfXSS(cookies[i].split('=').slice(1).join('=')) + '</div>';
  1315. html += '</li>';
  1316. }
  1317. html += '</ul>';
  1318. } else {
  1319. html += '<div class="tarteaucitronCookiesListMain">';
  1320. html += ' <div class="tarteaucitronCookiesListLeft"><strong>-</strong></div>';
  1321. html += ' <div class="tarteaucitronCookiesListRight"></div>';
  1322. html += '</div>';
  1323. }
  1324. html += '<div class="tarteaucitronHidden spacer-20"></div>';
  1325. if (document.getElementById('tarteaucitronCookiesList') !== null) {
  1326. document.getElementById('tarteaucitronCookiesList').innerHTML = html;
  1327. }
  1328. if (document.getElementById('tarteaucitronCookiesNumber') !== null) {
  1329. document.getElementById('tarteaucitronCookiesNumber').innerHTML = nb;
  1330. }
  1331. if (document.getElementById('tarteaucitronCookiesNumberBis') !== null) {
  1332. document.getElementById('tarteaucitronCookiesNumberBis').innerHTML = nb + ' cookie' + s;
  1333. }
  1334. var purgeBtns = document.getElementsByClassName("purgeBtn");
  1335. for (i = 0; i < purgeBtns.length; i++) {
  1336. tarteaucitron.addClickEventToElement(purgeBtns[i], function () {
  1337. tarteaucitron.cookie.purge([this.dataset.cookie]);
  1338. tarteaucitron.cookie.number();
  1339. tarteaucitron.userInterface.jsSizing('cookie');
  1340. return false;
  1341. });
  1342. }
  1343. for (i = 0; i < tarteaucitron.job.length; i += 1) {
  1344. tarteaucitron.cookie.checkCount(tarteaucitron.job[i]);
  1345. }
  1346. }
  1347. },
  1348. "fixSelfXSS": function(html) {
  1349. fixed = html.toString().replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
  1350. return fixed;
  1351. },
  1352. "getLanguage": function () {
  1353. "use strict";
  1354. 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',
  1355. defaultLanguage = 'en';
  1356. if (tarteaucitronForceLanguage !== '') {
  1357. if (availableLanguages.indexOf(tarteaucitronForceLanguage) !== -1) {
  1358. return tarteaucitronForceLanguage;
  1359. }
  1360. }
  1361. if (!navigator) { return 'en'; }
  1362. var lang = navigator.language || navigator.browserLanguage ||
  1363. navigator.systemLanguage || navigator.userLang || null,
  1364. userLanguage = lang ? lang.substr(0, 2) : null;
  1365. if (availableLanguages.indexOf(userLanguage) === -1) {
  1366. return defaultLanguage;
  1367. }
  1368. return userLanguage;
  1369. },
  1370. "getLocale": function () {
  1371. "use strict";
  1372. if (!navigator) { return 'en_US'; }
  1373. var lang = navigator.language || navigator.browserLanguage ||
  1374. navigator.systemLanguage || navigator.userLang || null,
  1375. userLanguage = lang ? lang.substr(0, 2) : null;
  1376. if (userLanguage === 'fr') {
  1377. return 'fr_FR';
  1378. } else if (userLanguage === 'en') {
  1379. return 'en_US';
  1380. } else if (userLanguage === 'de') {
  1381. return 'de_DE';
  1382. } else if (userLanguage === 'es') {
  1383. return 'es_ES';
  1384. } else if (userLanguage === 'it') {
  1385. return 'it_IT';
  1386. } else if (userLanguage === 'pt') {
  1387. return 'pt_PT';
  1388. } else if (userLanguage === 'nl') {
  1389. return 'nl_NL';
  1390. } else if (userLanguage === 'el') {
  1391. return 'el_EL';
  1392. } else {
  1393. return 'en_US';
  1394. }
  1395. },
  1396. "addScript": function (url, id, callback, execute, attrName, attrVal, internal) {
  1397. "use strict";
  1398. var script,
  1399. done = false;
  1400. if (execute === false) {
  1401. if (typeof callback === 'function') {
  1402. callback();
  1403. }
  1404. } else {
  1405. script = document.createElement('script');
  1406. script.type = 'text/javascript';
  1407. script.id = (id !== undefined) ? id : '';
  1408. script.async = true;
  1409. script.src = url;
  1410. if (attrName !== undefined && attrVal !== undefined) {
  1411. script.setAttribute(attrName, attrVal);
  1412. }
  1413. if (typeof callback === 'function') {
  1414. if ( !tarteaucitron.parameters.useExternalJs || !internal ) {
  1415. script.onreadystatechange = script.onload = function () {
  1416. var state = script.readyState;
  1417. if (!done && (!state || /loaded|complete/.test(state))) {
  1418. done = true;
  1419. callback();
  1420. }
  1421. };
  1422. } else {
  1423. callback();
  1424. }
  1425. }
  1426. if ( !tarteaucitron.parameters.useExternalJs || !internal ) {
  1427. document.getElementsByTagName('head')[0].appendChild(script);
  1428. }
  1429. }
  1430. },
  1431. "addInternalScript": function (url, id, callback, execute, attrName, attrVal) {
  1432. tarteaucitron.addScript(url, id, callback, execute, attrName, attrVal, true);
  1433. },
  1434. "makeAsync": {
  1435. "antiGhost": 0,
  1436. "buffer": '',
  1437. "init": function (url, id) {
  1438. "use strict";
  1439. var savedWrite = document.write,
  1440. savedWriteln = document.writeln;
  1441. document.write = function (content) {
  1442. tarteaucitron.makeAsync.buffer += content;
  1443. };
  1444. document.writeln = function (content) {
  1445. tarteaucitron.makeAsync.buffer += content.concat("\n");
  1446. };
  1447. setTimeout(function () {
  1448. document.write = savedWrite;
  1449. document.writeln = savedWriteln;
  1450. }, 20000);
  1451. tarteaucitron.makeAsync.getAndParse(url, id);
  1452. },
  1453. "getAndParse": function (url, id) {
  1454. "use strict";
  1455. if (tarteaucitron.makeAsync.antiGhost > 9) {
  1456. tarteaucitron.makeAsync.antiGhost = 0;
  1457. return;
  1458. }
  1459. tarteaucitron.makeAsync.antiGhost += 1;
  1460. tarteaucitron.addInternalScript(url, '', function () {
  1461. if (document.getElementById(id) !== null) {
  1462. document.getElementById(id).innerHTML += "<span class='display-none'>&nbsp;</span>" + tarteaucitron.makeAsync.buffer;
  1463. tarteaucitron.makeAsync.buffer = '';
  1464. tarteaucitron.makeAsync.execJS(id);
  1465. }
  1466. });
  1467. },
  1468. "execJS": function (id) {
  1469. /* not strict because third party scripts may have errors */
  1470. var i,
  1471. scripts,
  1472. childId,
  1473. type;
  1474. if (document.getElementById(id) === null) {
  1475. return;
  1476. }
  1477. scripts = document.getElementById(id).getElementsByTagName('script');
  1478. for (i = 0; i < scripts.length; i += 1) {
  1479. type = (scripts[i].getAttribute('type') !== null) ? scripts[i].getAttribute('type') : '';
  1480. if (type === '') {
  1481. type = (scripts[i].getAttribute('language') !== null) ? scripts[i].getAttribute('language') : '';
  1482. }
  1483. if (scripts[i].getAttribute('src') !== null && scripts[i].getAttribute('src') !== '') {
  1484. childId = id + Math.floor(Math.random() * 99999999999);
  1485. document.getElementById(id).innerHTML += '<div id="' + childId + '"></div>';
  1486. tarteaucitron.makeAsync.getAndParse(scripts[i].getAttribute('src'), childId);
  1487. } else if (type.indexOf('javascript') !== -1 || type === '') {
  1488. eval(scripts[i].innerHTML);
  1489. }
  1490. }
  1491. }
  1492. },
  1493. "fallback": function (matchClass, content, noInner) {
  1494. "use strict";
  1495. var elems = document.getElementsByTagName('*'),
  1496. i,
  1497. index = 0;
  1498. for (i in elems) {
  1499. if (elems[i] !== undefined) {
  1500. for (index = 0; index < matchClass.length; index += 1) {
  1501. if ((' ' + elems[i].className + ' ')
  1502. .indexOf(' ' + matchClass[index] + ' ') > -1) {
  1503. if (typeof content === 'function') {
  1504. if (noInner === true) {
  1505. content(elems[i]);
  1506. } else {
  1507. elems[i].innerHTML = content(elems[i]);
  1508. }
  1509. } else {
  1510. elems[i].innerHTML = content;
  1511. }
  1512. }
  1513. }
  1514. }
  1515. }
  1516. },
  1517. "engage": function (id) {
  1518. "use strict";
  1519. var html = '',
  1520. r = Math.floor(Math.random() * 100000),
  1521. engage = tarteaucitron.services[id].name + ' ' + tarteaucitron.lang.fallback;
  1522. if (tarteaucitron.lang['engage-' + id] !== undefined) {
  1523. engage = tarteaucitron.lang['engage-' + id];
  1524. }
  1525. html += '<div class="tac_activate tac_activate_' + id + '">';
  1526. html += ' <div class="tac_float">';
  1527. html += ' ' + engage;
  1528. html += ' <button type="button" class="tarteaucitronAllow" id="Eng' + r + 'ed' + id + '">';
  1529. html += ' <span class="tarteaucitronCheck"></span> ' + tarteaucitron.lang.allow;
  1530. html += ' </button>';
  1531. html += ' </div>';
  1532. html += '</div>';
  1533. return html;
  1534. },
  1535. "extend": function (a, b) {
  1536. "use strict";
  1537. var prop;
  1538. for (prop in b) {
  1539. if (b.hasOwnProperty(prop)) {
  1540. a[prop] = b[prop];
  1541. }
  1542. }
  1543. },
  1544. "proTemp": '',
  1545. "proTimer": function () {
  1546. "use strict";
  1547. setTimeout(tarteaucitron.proPing, 500);
  1548. },
  1549. "pro": function (list) {
  1550. "use strict";
  1551. tarteaucitron.proTemp += list;
  1552. clearTimeout(tarteaucitron.proTimer);
  1553. tarteaucitron.proTimer = setTimeout(tarteaucitron.proPing, 500);
  1554. },
  1555. "proPing": function () {
  1556. "use strict";
  1557. if (tarteaucitron.uuid !== '' && tarteaucitron.uuid !== undefined && tarteaucitron.proTemp !== '') {
  1558. var div = document.getElementById('tarteaucitronPremium'),
  1559. timestamp = new Date().getTime(),
  1560. url = 'https://tarteaucitron.io/log/?';
  1561. if (div === null) {
  1562. return;
  1563. }
  1564. url += 'account=' + tarteaucitron.uuid + '&';
  1565. url += 'domain=' + tarteaucitron.domain + '&';
  1566. url += 'status=' + encodeURIComponent(tarteaucitron.proTemp) + '&';
  1567. url += '_time=' + timestamp;
  1568. div.innerHTML = '<img src="' + url + '" class="display-none" alt="" />';
  1569. tarteaucitron.proTemp = '';
  1570. }
  1571. tarteaucitron.cookie.number();
  1572. },
  1573. "AddOrUpdate" : function(source, custom){
  1574. /**
  1575. Utility function to Add or update the fields of obj1 with the ones in obj2
  1576. */
  1577. for(key in custom){
  1578. if(custom[key] instanceof Object){
  1579. source[key] = tarteaucitron.AddOrUpdate(source[key], custom[key]);
  1580. }else{
  1581. source[key] = custom[key];
  1582. }
  1583. }
  1584. return source;
  1585. },
  1586. "getElemWidth": function(elem) {
  1587. return elem.getAttribute('width') || elem.clientWidth;
  1588. },
  1589. "getElemHeight": function(elem) {
  1590. return elem.getAttribute('height') || elem.clientHeight;
  1591. },
  1592. "addClickEventToId": function (elemId, func) {
  1593. tarteaucitron.addClickEventToElement(document.getElementById(elemId), func);
  1594. },
  1595. "addClickEventToElement": function (e, func) {
  1596. if (e) {
  1597. if (e.addEventListener) {
  1598. e.addEventListener("click", func);
  1599. } else {
  1600. e.attachEvent("onclick", func);
  1601. }
  1602. }
  1603. }
  1604. };