tarteaucitron.js 88 KB

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