tarteaucitron.js 85 KB

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