tarteaucitron.js 80 KB

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