tarteaucitron.js 87 KB

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