tarteaucitron.js 87 KB

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