tarteaucitron.js 87 KB

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