tarteaucitron.js 85 KB

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