tarteaucitron.js 88 KB

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