tarteaucitron.js 77 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667
  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": 20200730,
  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" onclick="tarteaucitron.userInterface.closePanel();" aria-label="' + tarteaucitron.lang.close + '"></button>';
  266. html += '<div id="tarteaucitron" role="dialog" aria-labelledby="dialogTitle">';
  267. html += ' <button type="button" id="tarteaucitronClosePanel" onclick="tarteaucitron.userInterface.closePanel();">';
  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" onclick="document.location = tarteaucitron.parameters.privacyUrl">';
  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" onclick="tarteaucitron.userInterface.respondAll(true);">';
  287. html += ' &#10003; ' + tarteaucitron.lang.allowAll;
  288. html += ' </button> ';
  289. html += ' <button type="button" id="tarteaucitronAllDenied" class="tarteaucitronDeny" onclick="tarteaucitron.userInterface.respondAll(false);">';
  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" onclick="tarteaucitron.userInterface.toggle(\'tarteaucitronDetails' + cat[i] + '\', \'tarteaucitronInfoBox\');return false">&#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" id="tarteaucitronScrollbarChild" style="height:20px;display:block"></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" onclick="tarteaucitron.userInterface.openPanel();">';
  345. html += ' ' + tarteaucitron.lang.personalize;
  346. html += ' </button>';
  347. if (tarteaucitron.parameters.privacyUrl !== "") {
  348. html += ' <button type="button" id="tarteaucitronPrivacyUrl" onclick="document.location = tarteaucitron.parameters.privacyUrl">';
  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="tarteaucitronPersonalize" onclick="tarteaucitron.userInterface.respondAll(true);">';
  367. html += ' &#10003; ' + tarteaucitron.lang.acceptAll;
  368. html += ' </button>';
  369. if (tarteaucitron.parameters.DenyAllCta) {
  370. html += ' <button type="button" class="tarteaucitronCTAButton tarteaucitronDeny" onclick="tarteaucitron.userInterface.respondAll(false);">';
  371. html += ' &#10007; ' + tarteaucitron.lang.denyAll;
  372. html += ' </button>';
  373. html += ' <br/><br/>';
  374. }
  375. html += ' <button type="button" id="tarteaucitronCloseAlert" onclick="tarteaucitron.userInterface.openPanel();">';
  376. html += ' ' + tarteaucitron.lang.personalize;
  377. html += ' </button>';
  378. if (tarteaucitron.parameters.privacyUrl !== "") {
  379. html += ' <button type="button" id="tarteaucitronPrivacyUrl" onclick="document.location = tarteaucitron.parameters.privacyUrl">';
  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" onclick="tarteaucitron.userInterface.openPanel();">';
  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" onclick="tarteaucitron.userInterface.toggleCookiesList();">0</button>';
  400. html += ' <div id="tarteaucitronCookiesListContainer">';
  401. html += ' <button type="button" id="tarteaucitronClosePanelCookie" onclick="tarteaucitron.userInterface.closePanel();">';
  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 + '" style="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" onclick="location.reload();">';
  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. });
  508. });
  509. if(tarteaucitron.events.load) {
  510. tarteaucitron.events.load();
  511. }
  512. },
  513. "addService": function (serviceId) {
  514. "use strict";
  515. var html = '',
  516. s = tarteaucitron.services,
  517. service = s[serviceId],
  518. cookie = tarteaucitron.cookie.read(),
  519. hostname = document.location.hostname,
  520. hostRef = document.referrer.split('/')[2],
  521. isNavigating = (hostRef === hostname && window.location.href !== tarteaucitron.parameters.privacyUrl),
  522. isAutostart = (!service.needConsent),
  523. isWaiting = (cookie.indexOf(service.key + '=wait') >= 0),
  524. isDenied = (cookie.indexOf(service.key + '=false') >= 0),
  525. isAllowed = ((cookie.indexOf(service.key + '=true') >= 0) || (!service.needConsent && cookie.indexOf(service.key + '=false') < 0)),
  526. isResponded = (cookie.indexOf(service.key + '=false') >= 0 || cookie.indexOf(service.key + '=true') >= 0),
  527. isDNTRequested = (navigator.doNotTrack === "1" || navigator.doNotTrack === "yes" || navigator.msDoNotTrack === "1" || window.doNotTrack === "1");
  528. if (tarteaucitron.added[service.key] !== true) {
  529. tarteaucitron.added[service.key] = true;
  530. html += '<li id="' + service.key + 'Line" class="tarteaucitronLine">';
  531. html += ' <div class="tarteaucitronName">';
  532. html += ' <span class="tarteaucitronH3" role="heading" aria-level="3">' + service.name + '</span>';
  533. html += ' <span id="tacCL' + service.key + '" class="tarteaucitronListCookies"></span><br/>';
  534. if (tarteaucitron.parameters.moreInfoLink == true) {
  535. var link = 'https://tarteaucitron.io/service/' + service.key + '/';
  536. if (service.readmoreLink !== undefined && service.readmoreLink !== '') {
  537. link = service.readmoreLink;
  538. }
  539. if (tarteaucitron.parameters.readmoreLink !== undefined && tarteaucitron.parameters.readmoreLink !== '') {
  540. link = tarteaucitron.parameters.readmoreLink;
  541. }
  542. html += ' <a href="' + link + '" target="_blank" rel="noreferrer noopener" title="'+ tarteaucitron.lang.cookieDetail + ' ' + service.name + ' ' + tarteaucitron.lang.ourSite + ' ' + tarteaucitron.lang.newWindow +'">';
  543. html += ' ' + tarteaucitron.lang.more;
  544. html += ' </a>';
  545. html += ' - ';
  546. html += ' <a href="' + service.uri + '" target="_blank" rel="noreferrer noopener" title="' + service.name + ' ' + tarteaucitron.lang.newWindow + '">';
  547. html += ' ' + tarteaucitron.lang.source;
  548. html += ' </a>';
  549. }
  550. html += ' </div>';
  551. html += ' <div class="tarteaucitronAsk">';
  552. html += ' <button type="button" id="' + service.key + 'Allowed" class="tarteaucitronAllow" onclick="tarteaucitron.userInterface.respond(this, true);">';
  553. html += ' &#10003; ' + tarteaucitron.lang.allow;
  554. html += ' </button> ';
  555. html += ' <button type="button" id="' + service.key + 'Denied" class="tarteaucitronDeny" onclick="tarteaucitron.userInterface.respond(this, false);">';
  556. html += ' &#10007; ' + tarteaucitron.lang.deny;
  557. html += ' </button>';
  558. html += ' </div>';
  559. html += '</li>';
  560. tarteaucitron.userInterface.css('tarteaucitronServicesTitle_' + service.type, 'display', 'block');
  561. if (document.getElementById('tarteaucitronServices_' + service.type) !== null) {
  562. document.getElementById('tarteaucitronServices_' + service.type).innerHTML += html;
  563. }
  564. tarteaucitron.userInterface.css('tarteaucitronNoServicesTitle', 'display', 'none');
  565. tarteaucitron.userInterface.order(service.type);
  566. }
  567. tarteaucitron.pro('!' + service.key + '=' + isAllowed);
  568. // allow by default for non EU
  569. if (isResponded === false && tarteaucitron.user.bypass === true) {
  570. isAllowed = true;
  571. tarteaucitron.cookie.create(service.key, true);
  572. }
  573. if ((!isResponded && (isAutostart || (isNavigating && isWaiting)) && !tarteaucitron.highPrivacy) || isAllowed) {
  574. if (!isAllowed) {
  575. tarteaucitron.cookie.create(service.key, true);
  576. }
  577. if (tarteaucitron.launch[service.key] !== true) {
  578. tarteaucitron.launch[service.key] = true;
  579. service.js();
  580. tarteaucitron.sendEvent(service.key + '_loaded');
  581. }
  582. tarteaucitron.state[service.key] = true;
  583. tarteaucitron.userInterface.color(service.key, true);
  584. } else if (isDenied) {
  585. if (typeof service.fallback === 'function') {
  586. service.fallback();
  587. }
  588. tarteaucitron.state[service.key] = false;
  589. tarteaucitron.userInterface.color(service.key, false);
  590. } else if (!isResponded && isDNTRequested && tarteaucitron.handleBrowserDNTRequest) {
  591. tarteaucitron.cookie.create(service.key, 'false');
  592. if (typeof service.fallback === 'function') {
  593. service.fallback();
  594. }
  595. tarteaucitron.state[service.key] = false;
  596. tarteaucitron.userInterface.color(service.key, false);
  597. } else if (!isResponded) {
  598. tarteaucitron.cookie.create(service.key, 'wait');
  599. if (typeof service.fallback === 'function') {
  600. service.fallback();
  601. }
  602. tarteaucitron.userInterface.color(service.key, 'wait');
  603. tarteaucitron.userInterface.openAlert();
  604. }
  605. tarteaucitron.cookie.checkCount(service.key);
  606. tarteaucitron.sendEvent(service.key + '_added')
  607. },
  608. "sendEvent" : function(event_key) {
  609. if(event_key !== undefined) {
  610. //ie compatibility
  611. var send_event_item;
  612. if(typeof(Event) === 'function') {
  613. send_event_item = new Event(event_key);
  614. }else{
  615. send_event_item = document.createEvent('Event');
  616. send_event_item.initEvent(event_key, true, true);
  617. }
  618. //end ie compatibility
  619. document.dispatchEvent(send_event_item);
  620. }
  621. },
  622. "cleanArray": function cleanArray(arr) {
  623. "use strict";
  624. var i,
  625. len = arr.length,
  626. out = [],
  627. obj = {},
  628. s = tarteaucitron.services;
  629. for (i = 0; i < len; i += 1) {
  630. if (!obj[arr[i]]) {
  631. obj[arr[i]] = {};
  632. if (tarteaucitron.services[arr[i]] !== undefined) {
  633. out.push(arr[i]);
  634. }
  635. }
  636. }
  637. out = out.sort(function (a, b) {
  638. if (s[a].type + s[a].key > s[b].type + s[b].key) { return 1; }
  639. if (s[a].type + s[a].key < s[b].type + s[b].key) { return -1; }
  640. return 0;
  641. });
  642. return out;
  643. },
  644. "userInterface": {
  645. "css": function (id, property, value) {
  646. "use strict";
  647. if (document.getElementById(id) !== null) {
  648. document.getElementById(id).style[property] = value;
  649. }
  650. },
  651. "addClass": function (id, className) {
  652. "use strict";
  653. if (document.getElementById(id) !== null) {
  654. document.getElementById(id).classList.add(className);
  655. }
  656. },
  657. "removeClass": function (id, className) {
  658. "use strict";
  659. if (document.getElementById(id) !== null) {
  660. document.getElementById(id).classList.remove(className);
  661. }
  662. },
  663. "respondAll": function (status) {
  664. "use strict";
  665. var s = tarteaucitron.services,
  666. service,
  667. key,
  668. index = 0;
  669. for (index = 0; index < tarteaucitron.job.length; index += 1) {
  670. service = s[tarteaucitron.job[index]];
  671. key = service.key;
  672. if (tarteaucitron.state[key] !== status) {
  673. if (status === false && tarteaucitron.launch[key] === true) {
  674. tarteaucitron.reloadThePage = true;
  675. }
  676. if (tarteaucitron.launch[key] !== true && status === true) {
  677. tarteaucitron.pro('!' + key + '=engage');
  678. tarteaucitron.launch[key] = true;
  679. tarteaucitron.services[key].js();
  680. }
  681. tarteaucitron.state[key] = status;
  682. tarteaucitron.cookie.create(key, status);
  683. tarteaucitron.userInterface.color(key, status);
  684. }
  685. }
  686. },
  687. "respond": function (el, status) {
  688. "use strict";
  689. var key = el.id.replace(new RegExp("(Eng[0-9]+|Allow|Deni)ed", "g"), '');
  690. // return if same state
  691. if (tarteaucitron.state[key] === status) {
  692. return;
  693. }
  694. if (status === false && tarteaucitron.launch[key] === true) {
  695. tarteaucitron.reloadThePage = true;
  696. }
  697. // if not already launched... launch the service
  698. if (status === true) {
  699. if (tarteaucitron.launch[key] !== true) {
  700. tarteaucitron.pro('!' + key + '=engage');
  701. tarteaucitron.launch[key] = true;
  702. tarteaucitron.sendEvent(key + '_loaded');
  703. tarteaucitron.services[key].js();
  704. }
  705. }
  706. tarteaucitron.state[key] = status;
  707. tarteaucitron.cookie.create(key, status);
  708. tarteaucitron.userInterface.color(key, status);
  709. },
  710. "color": function (key, status) {
  711. "use strict";
  712. var c = 'tarteaucitron',
  713. nbDenied = 0,
  714. nbPending = 0,
  715. nbAllowed = 0,
  716. sum = tarteaucitron.job.length,
  717. index;
  718. if (status === true) {
  719. document.getElementById(key + 'Line').classList.add('tarteaucitronIsAllowed');
  720. document.getElementById(key + 'Line').classList.remove('tarteaucitronIsDenied');
  721. } else if (status === false) {
  722. document.getElementById(key + 'Line').classList.remove('tarteaucitronIsAllowed');
  723. document.getElementById(key + 'Line').classList.add('tarteaucitronIsDenied');
  724. }
  725. // check if all services are allowed
  726. for (index = 0; index < sum; index += 1) {
  727. if (tarteaucitron.state[tarteaucitron.job[index]] === false) {
  728. nbDenied += 1;
  729. } else if (tarteaucitron.state[tarteaucitron.job[index]] === undefined) {
  730. nbPending += 1;
  731. } else if (tarteaucitron.state[tarteaucitron.job[index]] === true) {
  732. nbAllowed += 1;
  733. }
  734. }
  735. tarteaucitron.userInterface.css(c + 'DotGreen', 'width', ((100 / sum) * nbAllowed) + '%');
  736. tarteaucitron.userInterface.css(c + 'DotYellow', 'width', ((100 / sum) * nbPending) + '%');
  737. tarteaucitron.userInterface.css(c + 'DotRed', 'width', ((100 / sum) * nbDenied) + '%');
  738. if (nbDenied === 0 && nbPending === 0) {
  739. tarteaucitron.userInterface.removeClass(c + 'AllDenied', c + 'IsSelected');
  740. tarteaucitron.userInterface.addClass(c + 'AllAllowed', c + 'IsSelected');
  741. tarteaucitron.userInterface.addClass(c + 'MainLineOffset', c + 'IsAllowed');
  742. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsDenied');
  743. } else if (nbAllowed === 0 && nbPending === 0) {
  744. tarteaucitron.userInterface.removeClass(c + 'AllAllowed', c + 'IsSelected');
  745. tarteaucitron.userInterface.addClass(c + 'AllDenied', c + 'IsSelected');
  746. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsAllowed');
  747. tarteaucitron.userInterface.addClass(c + 'MainLineOffset', c + 'IsDenied');
  748. } else {
  749. tarteaucitron.userInterface.removeClass(c + 'AllAllowed', c + 'IsSelected');
  750. tarteaucitron.userInterface.removeClass(c + 'AllDenied', c + 'IsSelected');
  751. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsAllowed');
  752. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsDenied');
  753. }
  754. // close the alert if all service have been reviewed
  755. if (nbPending === 0) {
  756. tarteaucitron.userInterface.closeAlert();
  757. }
  758. if (tarteaucitron.services[key].cookies.length > 0 && status === false) {
  759. tarteaucitron.cookie.purge(tarteaucitron.services[key].cookies);
  760. }
  761. if (status === true) {
  762. if (document.getElementById('tacCL' + key) !== null) {
  763. document.getElementById('tacCL' + key).innerHTML = '...';
  764. }
  765. setTimeout(function () {
  766. tarteaucitron.cookie.checkCount(key);
  767. }, 2500);
  768. } else {
  769. tarteaucitron.cookie.checkCount(key);
  770. }
  771. },
  772. "openPanel": function () {
  773. "use strict";
  774. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'block');
  775. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
  776. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
  777. document.getElementById('tarteaucitronClosePanel').focus();
  778. document.getElementsByTagName('body')[0].classList.add('modal-open');
  779. tarteaucitron.userInterface.focusTrap();
  780. tarteaucitron.userInterface.jsSizing('main');
  781. //ie compatibility
  782. var tacOpenPanelEvent;
  783. if(typeof(Event) === 'function') {
  784. tacOpenPanelEvent = new Event("tac.open_panel");
  785. }else{
  786. tacOpenPanelEvent = document.createEvent('Event');
  787. tacOpenPanelEvent.initEvent("tac.open_panel", true, true);
  788. }
  789. //end ie compatibility
  790. window.dispatchEvent(tacOpenPanelEvent);
  791. },
  792. "closePanel": function () {
  793. "use strict";
  794. if (document.location.hash === tarteaucitron.hashtag) {
  795. if (window.history) {
  796. window.history.replaceState('', document.title, window.location.pathname + window.location.search);
  797. } else {
  798. document.location.hash = '';
  799. }
  800. }
  801. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  802. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
  803. tarteaucitron.fallback(['tarteaucitronInfoBox'], function (elem) {
  804. elem.style.display = 'none';
  805. }, true);
  806. if (tarteaucitron.reloadThePage === true) {
  807. window.location.reload();
  808. } else {
  809. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
  810. }
  811. if (document.getElementById('tarteaucitronCloseAlert') !== null) {
  812. document.getElementById('tarteaucitronCloseAlert').focus();
  813. }
  814. document.getElementsByTagName('body')[0].classList.remove('modal-open');
  815. //ie compatibility
  816. var tacClosePanelEvent;
  817. if(typeof(Event) === 'function') {
  818. tacClosePanelEvent = new Event("tac.close_panel");
  819. }else{
  820. tacClosePanelEvent = document.createEvent('Event');
  821. tacClosePanelEvent.initEvent("tac.close_panel", true, true);
  822. }
  823. //end ie compatibility
  824. window.dispatchEvent(tacClosePanelEvent);
  825. },
  826. "focusTrap": function() {
  827. "use strict";
  828. var focusableEls,
  829. firstFocusableEl,
  830. lastFocusableEl,
  831. filtered;
  832. focusableEls = document.getElementById('tarteaucitron').querySelectorAll('a[href], button');
  833. filtered = [];
  834. // get only visible items
  835. for (var i = 0, max = focusableEls.length; i < max; i++) {
  836. if (focusableEls[i].offsetHeight > 0) {
  837. filtered.push(focusableEls[i]);
  838. }
  839. }
  840. firstFocusableEl = filtered[0];
  841. lastFocusableEl = filtered[filtered.length - 1];
  842. //loop focus inside tarteaucitron
  843. document.getElementById('tarteaucitron').addEventListener("keydown", function (evt) {
  844. if ( evt.key === 'Tab' || evt.keyCode === 9 ) {
  845. if ( evt.shiftKey ) /* shift + tab */ {
  846. if (document.activeElement === firstFocusableEl) {
  847. lastFocusableEl.focus();
  848. evt.preventDefault();
  849. }
  850. } else /* tab */ {
  851. if (document.activeElement === lastFocusableEl) {
  852. firstFocusableEl.focus();
  853. evt.preventDefault();
  854. }
  855. }
  856. }
  857. })
  858. },
  859. "openAlert": function () {
  860. "use strict";
  861. var c = 'tarteaucitron';
  862. tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'block');
  863. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'none');
  864. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'block');
  865. tarteaucitron.userInterface.addClass(c + 'Root', 'tarteaucitronBeforeVisible');
  866. //ie compatibility
  867. var tacOpenAlertEvent;
  868. if(typeof(Event) === 'function') {
  869. tacOpenAlertEvent = new Event("tac.open_alert");
  870. }else{
  871. tacOpenAlertEvent = document.createEvent('Event');
  872. tacOpenAlertEvent.initEvent("tac.open_alert", true, true);
  873. }
  874. //end ie compatibility
  875. window.dispatchEvent(tacOpenAlertEvent);
  876. },
  877. "closeAlert": function () {
  878. "use strict";
  879. var c = 'tarteaucitron';
  880. tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'none');
  881. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'block');
  882. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'none');
  883. tarteaucitron.userInterface.removeClass(c + 'Root', 'tarteaucitronBeforeVisible');
  884. tarteaucitron.userInterface.jsSizing('box');
  885. //ie compatibility
  886. var tacCloseAlertEvent;
  887. if(typeof(Event) === 'function') {
  888. tacCloseAlertEvent = new Event("tac.close_alert");
  889. }else{
  890. tacCloseAlertEvent = document.createEvent('Event');
  891. tacCloseAlertEvent.initEvent("tac.close_alert", true, true);
  892. }
  893. //end ie compatibility
  894. window.dispatchEvent(tacCloseAlertEvent);
  895. },
  896. "toggleCookiesList": function () {
  897. "use strict";
  898. var div = document.getElementById('tarteaucitronCookiesListContainer');
  899. if (div === null) {
  900. return;
  901. }
  902. if (div.style.display !== 'block') {
  903. tarteaucitron.cookie.number();
  904. div.style.display = 'block';
  905. tarteaucitron.userInterface.jsSizing('cookie');
  906. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  907. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
  908. tarteaucitron.fallback(['tarteaucitronInfoBox'], function (elem) {
  909. elem.style.display = 'none';
  910. }, true);
  911. } else {
  912. div.style.display = 'none';
  913. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  914. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
  915. }
  916. },
  917. "toggle": function (id, closeClass) {
  918. "use strict";
  919. var div = document.getElementById(id);
  920. if (div === null) {
  921. return;
  922. }
  923. if (closeClass !== undefined) {
  924. tarteaucitron.fallback([closeClass], function (elem) {
  925. if (elem.id !== id) {
  926. elem.style.display = 'none';
  927. }
  928. }, true);
  929. }
  930. if (div.style.display !== 'block') {
  931. div.style.display = 'block';
  932. } else {
  933. div.style.display = 'none';
  934. }
  935. },
  936. "order": function (id) {
  937. "use strict";
  938. var main = document.getElementById('tarteaucitronServices_' + id),
  939. allDivs,
  940. store = [],
  941. i;
  942. if (main === null) {
  943. return;
  944. }
  945. allDivs = main.childNodes;
  946. if (typeof Array.prototype.map === 'function' && typeof Enumerable === 'undefined') {
  947. Array.prototype.map.call(main.children, Object).sort(function (a, b) {
  948. //var mainChildren = Array.from(main.children);
  949. //mainChildren.sort(function (a, b) {
  950. if (tarteaucitron.services[a.id.replace(/Line/g, '')].name > tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return 1; }
  951. if (tarteaucitron.services[a.id.replace(/Line/g, '')].name < tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return -1; }
  952. return 0;
  953. }).forEach(function (element) {
  954. main.appendChild(element);
  955. });
  956. }
  957. },
  958. "jsSizing": function (type) {
  959. "use strict";
  960. var scrollbarMarginRight = 10,
  961. scrollbarWidthParent,
  962. scrollbarWidthChild,
  963. servicesHeight,
  964. e = window,
  965. a = 'inner',
  966. windowInnerHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
  967. mainTop,
  968. mainHeight,
  969. closeButtonHeight,
  970. headerHeight,
  971. cookiesListHeight,
  972. cookiesCloseHeight,
  973. cookiesTitleHeight,
  974. paddingBox,
  975. alertSmallHeight,
  976. cookiesNumberHeight;
  977. if (type === 'box') {
  978. if (document.getElementById('tarteaucitronAlertSmall') !== null && document.getElementById('tarteaucitronCookiesNumber') !== null) {
  979. // reset
  980. tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', '0px 10px');
  981. // calculate
  982. alertSmallHeight = document.getElementById('tarteaucitronAlertSmall').offsetHeight;
  983. cookiesNumberHeight = document.getElementById('tarteaucitronCookiesNumber').offsetHeight;
  984. paddingBox = (alertSmallHeight - cookiesNumberHeight) / 2;
  985. // apply
  986. tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', paddingBox + 'px 10px');
  987. }
  988. } else if (type === 'main') {
  989. // get the real window width for media query
  990. if (window.innerWidth === undefined) {
  991. a = 'client';
  992. e = document.documentElement || document.body;
  993. }
  994. // height of the services list container
  995. if (document.getElementById('tarteaucitron') !== null && document.getElementById('tarteaucitronClosePanel') !== null && document.getElementById('tarteaucitronMainLineOffset') !== null) {
  996. // reset
  997. tarteaucitron.userInterface.css('tarteaucitronServices', 'height', 'auto');
  998. // calculate
  999. mainHeight = document.getElementById('tarteaucitron').offsetHeight;
  1000. closeButtonHeight = document.getElementById('tarteaucitronClosePanel').offsetHeight;
  1001. // apply
  1002. servicesHeight = (mainHeight - closeButtonHeight + 2);
  1003. tarteaucitron.userInterface.css('tarteaucitronServices', 'height', servicesHeight + 'px');
  1004. tarteaucitron.userInterface.css('tarteaucitronServices', 'overflow-x', 'auto');
  1005. }
  1006. // align the main allow/deny button depending on scrollbar width
  1007. if (document.getElementById('tarteaucitronServices') !== null && document.getElementById('tarteaucitronScrollbarChild') !== null) {
  1008. // media query
  1009. if (e[a + 'Width'] <= 479) {
  1010. tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginLeft', '11px');
  1011. } else if (e[a + 'Width'] <= 767) {
  1012. scrollbarMarginRight = 12;
  1013. }
  1014. scrollbarWidthParent = document.getElementById('tarteaucitronServices').offsetWidth;
  1015. scrollbarWidthChild = document.getElementById('tarteaucitronScrollbarChild').offsetWidth;
  1016. tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginRight', ((scrollbarWidthParent - scrollbarWidthChild) + scrollbarMarginRight) + 'px');
  1017. }
  1018. // center the main panel
  1019. if (document.getElementById('tarteaucitron') !== null) {
  1020. // media query
  1021. if (e[a + 'Width'] <= 767) {
  1022. mainTop = 0;
  1023. } else {
  1024. mainTop = ((windowInnerHeight - document.getElementById('tarteaucitron').offsetHeight) / 2) - 21;
  1025. }
  1026. if (document.getElementById('tarteaucitronMainLineOffset') !== null) {
  1027. if (document.getElementById('tarteaucitron').offsetHeight < (windowInnerHeight / 2)) {
  1028. mainTop -= document.getElementById('tarteaucitronMainLineOffset').offsetHeight;
  1029. }
  1030. }
  1031. // correct
  1032. if (mainTop < 0) {
  1033. mainTop = 0;
  1034. }
  1035. // apply
  1036. tarteaucitron.userInterface.css('tarteaucitron', 'top', mainTop + 'px');
  1037. }
  1038. } else if (type === 'cookie') {
  1039. // put cookies list at bottom
  1040. if (document.getElementById('tarteaucitronAlertSmall') !== null) {
  1041. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'bottom', (document.getElementById('tarteaucitronAlertSmall').offsetHeight) + 'px');
  1042. }
  1043. // height of cookies list
  1044. if (document.getElementById('tarteaucitronCookiesListContainer') !== null) {
  1045. // reset
  1046. tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', 'auto');
  1047. // calculate
  1048. cookiesListHeight = document.getElementById('tarteaucitronCookiesListContainer').offsetHeight;
  1049. cookiesCloseHeight = document.getElementById('tarteaucitronClosePanelCookie').offsetHeight;
  1050. cookiesTitleHeight = document.getElementById('tarteaucitronCookiesTitle').offsetHeight;
  1051. // apply
  1052. tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', (cookiesListHeight - cookiesCloseHeight - cookiesTitleHeight - 2) + 'px');
  1053. }
  1054. }
  1055. }
  1056. },
  1057. "cookie": {
  1058. "owner": {},
  1059. "create": function (key, status) {
  1060. "use strict";
  1061. if (tarteaucitronForceExpire !== '') {
  1062. // The number of day(s)/hour(s) can't be higher than 1 year
  1063. if ((tarteaucitronExpireInDay && tarteaucitronForceExpire < 365) || (!tarteaucitronExpireInDay && tarteaucitronForceExpire < 8760)) {
  1064. if (tarteaucitronExpireInDay) {
  1065. // Multiplication to tranform the number of days to milliseconds
  1066. timeExpire = tarteaucitronForceExpire * 86400000;
  1067. } else {
  1068. // Multiplication to tranform the number of hours to milliseconds
  1069. timeExpire = tarteaucitronForceExpire * 3600000;
  1070. }
  1071. }
  1072. }
  1073. var d = new Date(),
  1074. time = d.getTime(),
  1075. expireTime = time + timeExpire, // 365 days
  1076. regex = new RegExp("!" + key + "=(wait|true|false)", "g"),
  1077. cookie = tarteaucitron.cookie.read().replace(regex, ""),
  1078. value = tarteaucitron.parameters.cookieName + '=' + cookie + '!' + key + '=' + status,
  1079. domain = (tarteaucitron.parameters.cookieDomain !== undefined && tarteaucitron.parameters.cookieDomain !== '') ? 'domain=' + tarteaucitron.parameters.cookieDomain + ';' : '';
  1080. d.setTime(expireTime);
  1081. document.cookie = value + '; expires=' + d.toGMTString() + '; path=/;' + domain;
  1082. },
  1083. "read": function () {
  1084. "use strict";
  1085. var nameEQ = tarteaucitron.parameters.cookieName + "=",
  1086. ca = document.cookie.split(';'),
  1087. i,
  1088. c;
  1089. for (i = 0; i < ca.length; i += 1) {
  1090. c = ca[i];
  1091. while (c.charAt(0) === ' ') {
  1092. c = c.substring(1, c.length);
  1093. }
  1094. if (c.indexOf(nameEQ) === 0) {
  1095. return c.substring(nameEQ.length, c.length);
  1096. }
  1097. }
  1098. return '';
  1099. },
  1100. "purge": function (arr) {
  1101. "use strict";
  1102. var i;
  1103. for (i = 0; i < arr.length; i += 1) {
  1104. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/;';
  1105. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname + ';';
  1106. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname.split('.').slice(-2).join('.') + ';';
  1107. }
  1108. },
  1109. "checkCount": function (key) {
  1110. "use strict";
  1111. var arr = tarteaucitron.services[key].cookies,
  1112. nb = arr.length,
  1113. nbCurrent = 0,
  1114. html = '',
  1115. i,
  1116. status = document.cookie.indexOf(key + '=true');
  1117. if (status >= 0 && nb === 0) {
  1118. html += tarteaucitron.lang.useNoCookie;
  1119. } else if (status >= 0) {
  1120. for (i = 0; i < nb; i += 1) {
  1121. if (document.cookie.indexOf(arr[i] + '=') !== -1) {
  1122. nbCurrent += 1;
  1123. if (tarteaucitron.cookie.owner[arr[i]] === undefined) {
  1124. tarteaucitron.cookie.owner[arr[i]] = [];
  1125. }
  1126. if (tarteaucitron.cookie.crossIndexOf(tarteaucitron.cookie.owner[arr[i]], tarteaucitron.services[key].name) === false) {
  1127. tarteaucitron.cookie.owner[arr[i]].push(tarteaucitron.services[key].name);
  1128. }
  1129. }
  1130. }
  1131. if (nbCurrent > 0) {
  1132. html += tarteaucitron.lang.useCookieCurrent + ' ' + nbCurrent + ' cookie';
  1133. if (nbCurrent > 1) {
  1134. html += 's';
  1135. }
  1136. html += '.';
  1137. } else {
  1138. html += tarteaucitron.lang.useNoCookie;
  1139. }
  1140. } else if (nb === 0) {
  1141. html = tarteaucitron.lang.noCookie;
  1142. } else {
  1143. html += tarteaucitron.lang.useCookie + ' ' + nb + ' cookie';
  1144. if (nb > 1) {
  1145. html += 's';
  1146. }
  1147. html += '.';
  1148. }
  1149. if (document.getElementById('tacCL' + key) !== null) {
  1150. document.getElementById('tacCL' + key).innerHTML = html;
  1151. }
  1152. },
  1153. "crossIndexOf": function (arr, match) {
  1154. "use strict";
  1155. var i;
  1156. for (i = 0; i < arr.length; i += 1) {
  1157. if (arr[i] === match) {
  1158. return true;
  1159. }
  1160. }
  1161. return false;
  1162. },
  1163. "number": function () {
  1164. "use strict";
  1165. var cookies = document.cookie.split(';'),
  1166. nb = (document.cookie !== '') ? cookies.length : 0,
  1167. html = '',
  1168. i,
  1169. name,
  1170. namea,
  1171. nameb,
  1172. c,
  1173. d,
  1174. s = (nb > 1) ? 's' : '',
  1175. savedname,
  1176. regex = /^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i,
  1177. regexedDomain = (tarteaucitron.cdn.match(regex) !== null) ? tarteaucitron.cdn.match(regex)[1] : tarteaucitron.cdn,
  1178. host = (tarteaucitron.domain !== undefined) ? tarteaucitron.domain : regexedDomain;
  1179. cookies = cookies.sort(function (a, b) {
  1180. namea = a.split('=', 1).toString().replace(/ /g, '');
  1181. nameb = b.split('=', 1).toString().replace(/ /g, '');
  1182. c = (tarteaucitron.cookie.owner[namea] !== undefined) ? tarteaucitron.cookie.owner[namea] : '0';
  1183. d = (tarteaucitron.cookie.owner[nameb] !== undefined) ? tarteaucitron.cookie.owner[nameb] : '0';
  1184. if (c + a > d + b) { return 1; }
  1185. if (c + a < d + b) { return -1; }
  1186. return 0;
  1187. });
  1188. if (document.cookie !== '') {
  1189. for (i = 0; i < nb; i += 1) {
  1190. name = cookies[i].split('=', 1).toString().replace(/ /g, '');
  1191. if (tarteaucitron.cookie.owner[name] !== undefined && tarteaucitron.cookie.owner[name].join(' // ') !== savedname) {
  1192. savedname = tarteaucitron.cookie.owner[name].join(' // ');
  1193. html += '<div class="tarteaucitronHidden">';
  1194. html += ' <span class="tarteaucitronTitle tarteaucitronH3" role="heading" aria-level="3">';
  1195. html += ' ' + tarteaucitron.cookie.owner[name].join(' // ');
  1196. html += ' </span>';
  1197. html += '</div><ul class="cookie-list">';
  1198. } else if (tarteaucitron.cookie.owner[name] === undefined && host !== savedname) {
  1199. savedname = host;
  1200. html += '<div class="tarteaucitronHidden">';
  1201. html += ' <span class="tarteaucitronTitle tarteaucitronH3" role="heading" aria-level="3">';
  1202. html += ' ' + host;
  1203. html += ' </span>';
  1204. html += '</div><ul class="cookie-list">';
  1205. }
  1206. html += '<li class="tarteaucitronCookiesListMain">';
  1207. html += ' <div class="tarteaucitronCookiesListLeft"><button type="button" onclick="tarteaucitron.cookie.purge([\'' + tarteaucitron.fixSelfXSS(cookies[i].split('=', 1)) + '\']);tarteaucitron.cookie.number();tarteaucitron.userInterface.jsSizing(\'cookie\');return false"><strong>&times;</strong></button> <strong>' + tarteaucitron.fixSelfXSS(name) + '</strong>';
  1208. html += ' </div>';
  1209. html += ' <div class="tarteaucitronCookiesListRight">' + tarteaucitron.fixSelfXSS(cookies[i].split('=').slice(1).join('=')) + '</div>';
  1210. html += '</li>';
  1211. }
  1212. html += '</ul>';
  1213. } else {
  1214. html += '<div class="tarteaucitronCookiesListMain">';
  1215. html += ' <div class="tarteaucitronCookiesListLeft"><strong>-</strong></div>';
  1216. html += ' <div class="tarteaucitronCookiesListRight"></div>';
  1217. html += '</div>';
  1218. }
  1219. html += '<div class="tarteaucitronHidden" style="height:20px;display:block"></div>';
  1220. if (document.getElementById('tarteaucitronCookiesList') !== null) {
  1221. document.getElementById('tarteaucitronCookiesList').innerHTML = html;
  1222. }
  1223. if (document.getElementById('tarteaucitronCookiesNumber') !== null) {
  1224. document.getElementById('tarteaucitronCookiesNumber').innerHTML = nb;
  1225. }
  1226. if (document.getElementById('tarteaucitronCookiesNumberBis') !== null) {
  1227. document.getElementById('tarteaucitronCookiesNumberBis').innerHTML = nb + ' cookie' + s;
  1228. }
  1229. for (i = 0; i < tarteaucitron.job.length; i += 1) {
  1230. tarteaucitron.cookie.checkCount(tarteaucitron.job[i]);
  1231. }
  1232. }
  1233. },
  1234. "fixSelfXSS": function(html) {
  1235. fixed = html.toString().replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
  1236. return fixed;
  1237. },
  1238. "getLanguage": function () {
  1239. "use strict";
  1240. 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',
  1241. defaultLanguage = 'en';
  1242. if (tarteaucitronForceLanguage !== '') {
  1243. if (availableLanguages.indexOf(tarteaucitronForceLanguage) !== -1) {
  1244. return tarteaucitronForceLanguage;
  1245. }
  1246. }
  1247. if (!navigator) { return 'en'; }
  1248. var lang = navigator.language || navigator.browserLanguage ||
  1249. navigator.systemLanguage || navigator.userLang || null,
  1250. userLanguage = lang ? lang.substr(0, 2) : null;
  1251. if (availableLanguages.indexOf(userLanguage) === -1) {
  1252. return defaultLanguage;
  1253. }
  1254. return userLanguage;
  1255. },
  1256. "getLocale": function () {
  1257. "use strict";
  1258. if (!navigator) { return 'en_US'; }
  1259. var lang = navigator.language || navigator.browserLanguage ||
  1260. navigator.systemLanguage || navigator.userLang || null,
  1261. userLanguage = lang ? lang.substr(0, 2) : null;
  1262. if (userLanguage === 'fr') {
  1263. return 'fr_FR';
  1264. } else if (userLanguage === 'en') {
  1265. return 'en_US';
  1266. } else if (userLanguage === 'de') {
  1267. return 'de_DE';
  1268. } else if (userLanguage === 'es') {
  1269. return 'es_ES';
  1270. } else if (userLanguage === 'it') {
  1271. return 'it_IT';
  1272. } else if (userLanguage === 'pt') {
  1273. return 'pt_PT';
  1274. } else if (userLanguage === 'nl') {
  1275. return 'nl_NL';
  1276. } else if (userLanguage === 'el') {
  1277. return 'el_EL';
  1278. } else {
  1279. return 'en_US';
  1280. }
  1281. },
  1282. "addScript": function (url, id, callback, execute, attrName, attrVal, internal) {
  1283. "use strict";
  1284. var script,
  1285. done = false;
  1286. if (execute === false) {
  1287. if (typeof callback === 'function') {
  1288. callback();
  1289. }
  1290. } else {
  1291. script = document.createElement('script');
  1292. script.type = 'text/javascript';
  1293. script.id = (id !== undefined) ? id : '';
  1294. script.async = true;
  1295. script.src = url;
  1296. if (attrName !== undefined && attrVal !== undefined) {
  1297. script.setAttribute(attrName, attrVal);
  1298. }
  1299. if (typeof callback === 'function') {
  1300. if ( !tarteaucitron.parameters.useExternalJs ) {
  1301. script.onreadystatechange = script.onload = function () {
  1302. var state = script.readyState;
  1303. if (!done && (!state || /loaded|complete/.test(state))) {
  1304. done = true;
  1305. callback();
  1306. }
  1307. };
  1308. } else {
  1309. callback();
  1310. }
  1311. }
  1312. if ( !tarteaucitron.parameters.useExternalJs || !internal ) {
  1313. document.getElementsByTagName('head')[0].appendChild(script);
  1314. }
  1315. }
  1316. },
  1317. "addInternalScript": function (url, id, callback, execute, attrName, attrVal) {
  1318. tarteaucitron.addScript(url, id, callback, execute, attrName, attrVal, true);
  1319. },
  1320. "makeAsync": {
  1321. "antiGhost": 0,
  1322. "buffer": '',
  1323. "init": function (url, id) {
  1324. "use strict";
  1325. var savedWrite = document.write,
  1326. savedWriteln = document.writeln;
  1327. document.write = function (content) {
  1328. tarteaucitron.makeAsync.buffer += content;
  1329. };
  1330. document.writeln = function (content) {
  1331. tarteaucitron.makeAsync.buffer += content.concat("\n");
  1332. };
  1333. setTimeout(function () {
  1334. document.write = savedWrite;
  1335. document.writeln = savedWriteln;
  1336. }, 20000);
  1337. tarteaucitron.makeAsync.getAndParse(url, id);
  1338. },
  1339. "getAndParse": function (url, id) {
  1340. "use strict";
  1341. if (tarteaucitron.makeAsync.antiGhost > 9) {
  1342. tarteaucitron.makeAsync.antiGhost = 0;
  1343. return;
  1344. }
  1345. tarteaucitron.makeAsync.antiGhost += 1;
  1346. tarteaucitron.addInternalScript(url, '', function () {
  1347. if (document.getElementById(id) !== null) {
  1348. document.getElementById(id).innerHTML += "<span style='display:none'>&nbsp;</span>" + tarteaucitron.makeAsync.buffer;
  1349. tarteaucitron.makeAsync.buffer = '';
  1350. tarteaucitron.makeAsync.execJS(id);
  1351. }
  1352. });
  1353. },
  1354. "execJS": function (id) {
  1355. /* not strict because third party scripts may have errors */
  1356. var i,
  1357. scripts,
  1358. childId,
  1359. type;
  1360. if (document.getElementById(id) === null) {
  1361. return;
  1362. }
  1363. scripts = document.getElementById(id).getElementsByTagName('script');
  1364. for (i = 0; i < scripts.length; i += 1) {
  1365. type = (scripts[i].getAttribute('type') !== null) ? scripts[i].getAttribute('type') : '';
  1366. if (type === '') {
  1367. type = (scripts[i].getAttribute('language') !== null) ? scripts[i].getAttribute('language') : '';
  1368. }
  1369. if (scripts[i].getAttribute('src') !== null && scripts[i].getAttribute('src') !== '') {
  1370. childId = id + Math.floor(Math.random() * 99999999999);
  1371. document.getElementById(id).innerHTML += '<div id="' + childId + '"></div>';
  1372. tarteaucitron.makeAsync.getAndParse(scripts[i].getAttribute('src'), childId);
  1373. } else if (type.indexOf('javascript') !== -1 || type === '') {
  1374. eval(scripts[i].innerHTML);
  1375. }
  1376. }
  1377. }
  1378. },
  1379. "fallback": function (matchClass, content, noInner) {
  1380. "use strict";
  1381. var elems = document.getElementsByTagName('*'),
  1382. i,
  1383. index = 0;
  1384. for (i in elems) {
  1385. if (elems[i] !== undefined) {
  1386. for (index = 0; index < matchClass.length; index += 1) {
  1387. if ((' ' + elems[i].className + ' ')
  1388. .indexOf(' ' + matchClass[index] + ' ') > -1) {
  1389. if (typeof content === 'function') {
  1390. if (noInner === true) {
  1391. content(elems[i]);
  1392. } else {
  1393. elems[i].innerHTML = content(elems[i]);
  1394. }
  1395. } else {
  1396. elems[i].innerHTML = content;
  1397. }
  1398. }
  1399. }
  1400. }
  1401. }
  1402. },
  1403. "engage": function (id) {
  1404. "use strict";
  1405. var html = '',
  1406. r = Math.floor(Math.random() * 100000),
  1407. engage = tarteaucitron.services[id].name + ' ' + tarteaucitron.lang.fallback;
  1408. if (tarteaucitron.lang['engage-' + id] !== undefined) {
  1409. engage = tarteaucitron.lang['engage-' + id];
  1410. }
  1411. html += '<div class="tac_activate">';
  1412. html += ' <div class="tac_float">';
  1413. html += ' ' + engage;
  1414. html += ' <button type="button" class="tarteaucitronAllow" id="Eng' + r + 'ed' + id + '" onclick="tarteaucitron.userInterface.respond(this, true);">';
  1415. html += ' &#10003; ' + tarteaucitron.lang.allow;
  1416. html += ' </button>';
  1417. html += ' </div>';
  1418. html += '</div>';
  1419. return html;
  1420. },
  1421. "extend": function (a, b) {
  1422. "use strict";
  1423. var prop;
  1424. for (prop in b) {
  1425. if (b.hasOwnProperty(prop)) {
  1426. a[prop] = b[prop];
  1427. }
  1428. }
  1429. },
  1430. "proTemp": '',
  1431. "proTimer": function () {
  1432. "use strict";
  1433. setTimeout(tarteaucitron.proPing, 500);
  1434. },
  1435. "pro": function (list) {
  1436. "use strict";
  1437. tarteaucitron.proTemp += list;
  1438. clearTimeout(tarteaucitron.proTimer);
  1439. tarteaucitron.proTimer = setTimeout(tarteaucitron.proPing, 500);
  1440. },
  1441. "proPing": function () {
  1442. "use strict";
  1443. if (tarteaucitron.uuid !== '' && tarteaucitron.uuid !== undefined && tarteaucitron.proTemp !== '') {
  1444. var div = document.getElementById('tarteaucitronPremium'),
  1445. timestamp = new Date().getTime(),
  1446. url = 'https://tarteaucitron.io/log/?';
  1447. if (div === null) {
  1448. return;
  1449. }
  1450. url += 'account=' + tarteaucitron.uuid + '&';
  1451. url += 'domain=' + tarteaucitron.domain + '&';
  1452. url += 'status=' + encodeURIComponent(tarteaucitron.proTemp) + '&';
  1453. url += '_time=' + timestamp;
  1454. div.innerHTML = '<img src="' + url + '" style="display:none" />';
  1455. tarteaucitron.proTemp = '';
  1456. }
  1457. tarteaucitron.cookie.number();
  1458. },
  1459. "AddOrUpdate" : function(source, custom){
  1460. /**
  1461. Utility function to Add or update the fields of obj1 with the ones in obj2
  1462. */
  1463. for(key in custom){
  1464. if(custom[key] instanceof Object){
  1465. source[key] = tarteaucitron.AddOrUpdate(source[key], custom[key]);
  1466. }else{
  1467. source[key] = custom[key];
  1468. }
  1469. }
  1470. return source;
  1471. },
  1472. "getElemWidth": function(elem) {
  1473. return elem.getAttribute('width') || elem.clientWidth;
  1474. },
  1475. "getElemHeight": function(elem) {
  1476. return elem.getAttribute('height') || elem.clientHeight;
  1477. }
  1478. };