tarteaucitron.js 85 KB

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