tarteaucitron.js 80 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753
  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" 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" 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">';
  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 + '" 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" 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. d.setTime(expireTime);
  1143. document.cookie = value + '; expires=' + d.toGMTString() + '; path=/;' + domain;
  1144. },
  1145. "read": function () {
  1146. "use strict";
  1147. var nameEQ = tarteaucitron.parameters.cookieName + "=",
  1148. ca = document.cookie.split(';'),
  1149. i,
  1150. c;
  1151. for (i = 0; i < ca.length; i += 1) {
  1152. c = ca[i];
  1153. while (c.charAt(0) === ' ') {
  1154. c = c.substring(1, c.length);
  1155. }
  1156. if (c.indexOf(nameEQ) === 0) {
  1157. return c.substring(nameEQ.length, c.length);
  1158. }
  1159. }
  1160. return '';
  1161. },
  1162. "purge": function (arr) {
  1163. "use strict";
  1164. var i;
  1165. for (i = 0; i < arr.length; i += 1) {
  1166. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/;';
  1167. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname + ';';
  1168. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname.split('.').slice(-2).join('.') + ';';
  1169. }
  1170. },
  1171. "checkCount": function (key) {
  1172. "use strict";
  1173. var arr = tarteaucitron.services[key].cookies,
  1174. nb = arr.length,
  1175. nbCurrent = 0,
  1176. html = '',
  1177. i,
  1178. status = document.cookie.indexOf(key + '=true');
  1179. if (status >= 0 && nb === 0) {
  1180. html += tarteaucitron.lang.useNoCookie;
  1181. } else if (status >= 0) {
  1182. for (i = 0; i < nb; i += 1) {
  1183. if (document.cookie.indexOf(arr[i] + '=') !== -1) {
  1184. nbCurrent += 1;
  1185. if (tarteaucitron.cookie.owner[arr[i]] === undefined) {
  1186. tarteaucitron.cookie.owner[arr[i]] = [];
  1187. }
  1188. if (tarteaucitron.cookie.crossIndexOf(tarteaucitron.cookie.owner[arr[i]], tarteaucitron.services[key].name) === false) {
  1189. tarteaucitron.cookie.owner[arr[i]].push(tarteaucitron.services[key].name);
  1190. }
  1191. }
  1192. }
  1193. if (nbCurrent > 0) {
  1194. html += tarteaucitron.lang.useCookieCurrent + ' ' + nbCurrent + ' cookie';
  1195. if (nbCurrent > 1) {
  1196. html += 's';
  1197. }
  1198. html += '.';
  1199. } else {
  1200. html += tarteaucitron.lang.useNoCookie;
  1201. }
  1202. } else if (nb === 0) {
  1203. html = tarteaucitron.lang.noCookie;
  1204. } else {
  1205. html += tarteaucitron.lang.useCookie + ' ' + nb + ' cookie';
  1206. if (nb > 1) {
  1207. html += 's';
  1208. }
  1209. html += '.';
  1210. }
  1211. if (document.getElementById('tacCL' + key) !== null) {
  1212. document.getElementById('tacCL' + key).innerHTML = html;
  1213. }
  1214. },
  1215. "crossIndexOf": function (arr, match) {
  1216. "use strict";
  1217. var i;
  1218. for (i = 0; i < arr.length; i += 1) {
  1219. if (arr[i] === match) {
  1220. return true;
  1221. }
  1222. }
  1223. return false;
  1224. },
  1225. "number": function () {
  1226. "use strict";
  1227. var cookies = document.cookie.split(';'),
  1228. nb = (document.cookie !== '') ? cookies.length : 0,
  1229. html = '',
  1230. i,
  1231. name,
  1232. namea,
  1233. nameb,
  1234. c,
  1235. d,
  1236. s = (nb > 1) ? 's' : '',
  1237. savedname,
  1238. regex = /^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i,
  1239. regexedDomain = (tarteaucitron.cdn.match(regex) !== null) ? tarteaucitron.cdn.match(regex)[1] : tarteaucitron.cdn,
  1240. host = (tarteaucitron.domain !== undefined) ? tarteaucitron.domain : regexedDomain;
  1241. cookies = cookies.sort(function (a, b) {
  1242. namea = a.split('=', 1).toString().replace(/ /g, '');
  1243. nameb = b.split('=', 1).toString().replace(/ /g, '');
  1244. c = (tarteaucitron.cookie.owner[namea] !== undefined) ? tarteaucitron.cookie.owner[namea] : '0';
  1245. d = (tarteaucitron.cookie.owner[nameb] !== undefined) ? tarteaucitron.cookie.owner[nameb] : '0';
  1246. if (c + a > d + b) { return 1; }
  1247. if (c + a < d + b) { return -1; }
  1248. return 0;
  1249. });
  1250. if (document.cookie !== '') {
  1251. for (i = 0; i < nb; i += 1) {
  1252. name = cookies[i].split('=', 1).toString().replace(/ /g, '');
  1253. if (tarteaucitron.cookie.owner[name] !== undefined && tarteaucitron.cookie.owner[name].join(' // ') !== savedname) {
  1254. savedname = tarteaucitron.cookie.owner[name].join(' // ');
  1255. html += '<div class="tarteaucitronHidden">';
  1256. html += ' <span class="tarteaucitronTitle tarteaucitronH3" role="heading" aria-level="3">';
  1257. html += ' ' + tarteaucitron.cookie.owner[name].join(' // ');
  1258. html += ' </span>';
  1259. html += '</div><ul class="cookie-list">';
  1260. } else if (tarteaucitron.cookie.owner[name] === undefined && host !== savedname) {
  1261. savedname = host;
  1262. html += '<div class="tarteaucitronHidden">';
  1263. html += ' <span class="tarteaucitronTitle tarteaucitronH3" role="heading" aria-level="3">';
  1264. html += ' ' + host;
  1265. html += ' </span>';
  1266. html += '</div><ul class="cookie-list">';
  1267. }
  1268. html += '<li class="tarteaucitronCookiesListMain">';
  1269. 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>';
  1270. html += ' </div>';
  1271. html += ' <div class="tarteaucitronCookiesListRight">' + tarteaucitron.fixSelfXSS(cookies[i].split('=').slice(1).join('=')) + '</div>';
  1272. html += '</li>';
  1273. }
  1274. html += '</ul>';
  1275. } else {
  1276. html += '<div class="tarteaucitronCookiesListMain">';
  1277. html += ' <div class="tarteaucitronCookiesListLeft"><strong>-</strong></div>';
  1278. html += ' <div class="tarteaucitronCookiesListRight"></div>';
  1279. html += '</div>';
  1280. }
  1281. html += '<div class="tarteaucitronHidden" style="height:20px;display:block"></div>';
  1282. if (document.getElementById('tarteaucitronCookiesList') !== null) {
  1283. document.getElementById('tarteaucitronCookiesList').innerHTML = html;
  1284. }
  1285. if (document.getElementById('tarteaucitronCookiesNumber') !== null) {
  1286. document.getElementById('tarteaucitronCookiesNumber').innerHTML = nb;
  1287. }
  1288. if (document.getElementById('tarteaucitronCookiesNumberBis') !== null) {
  1289. document.getElementById('tarteaucitronCookiesNumberBis').innerHTML = nb + ' cookie' + s;
  1290. }
  1291. var purgeBtns = document.getElementsByClassName("purgeBtn");
  1292. for (let i = 0; i < purgeBtns.length; i++) {
  1293. tarteaucitron.addClickEventToElement(purgeBtns[i], function () {
  1294. tarteaucitron.cookie.purge([this.dataset.cookie]);
  1295. tarteaucitron.cookie.number();
  1296. tarteaucitron.userInterface.jsSizing('cookie');
  1297. return false;
  1298. });
  1299. }
  1300. for (i = 0; i < tarteaucitron.job.length; i += 1) {
  1301. tarteaucitron.cookie.checkCount(tarteaucitron.job[i]);
  1302. }
  1303. }
  1304. },
  1305. "fixSelfXSS": function(html) {
  1306. fixed = html.toString().replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
  1307. return fixed;
  1308. },
  1309. "getLanguage": function () {
  1310. "use strict";
  1311. 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',
  1312. defaultLanguage = 'en';
  1313. if (tarteaucitronForceLanguage !== '') {
  1314. if (availableLanguages.indexOf(tarteaucitronForceLanguage) !== -1) {
  1315. return tarteaucitronForceLanguage;
  1316. }
  1317. }
  1318. if (!navigator) { return 'en'; }
  1319. var lang = navigator.language || navigator.browserLanguage ||
  1320. navigator.systemLanguage || navigator.userLang || null,
  1321. userLanguage = lang ? lang.substr(0, 2) : null;
  1322. if (availableLanguages.indexOf(userLanguage) === -1) {
  1323. return defaultLanguage;
  1324. }
  1325. return userLanguage;
  1326. },
  1327. "getLocale": function () {
  1328. "use strict";
  1329. if (!navigator) { return 'en_US'; }
  1330. var lang = navigator.language || navigator.browserLanguage ||
  1331. navigator.systemLanguage || navigator.userLang || null,
  1332. userLanguage = lang ? lang.substr(0, 2) : null;
  1333. if (userLanguage === 'fr') {
  1334. return 'fr_FR';
  1335. } else if (userLanguage === 'en') {
  1336. return 'en_US';
  1337. } else if (userLanguage === 'de') {
  1338. return 'de_DE';
  1339. } else if (userLanguage === 'es') {
  1340. return 'es_ES';
  1341. } else if (userLanguage === 'it') {
  1342. return 'it_IT';
  1343. } else if (userLanguage === 'pt') {
  1344. return 'pt_PT';
  1345. } else if (userLanguage === 'nl') {
  1346. return 'nl_NL';
  1347. } else if (userLanguage === 'el') {
  1348. return 'el_EL';
  1349. } else {
  1350. return 'en_US';
  1351. }
  1352. },
  1353. "addScript": function (url, id, callback, execute, attrName, attrVal, internal) {
  1354. "use strict";
  1355. var script,
  1356. done = false;
  1357. if (execute === false) {
  1358. if (typeof callback === 'function') {
  1359. callback();
  1360. }
  1361. } else {
  1362. script = document.createElement('script');
  1363. script.type = 'text/javascript';
  1364. script.id = (id !== undefined) ? id : '';
  1365. script.async = true;
  1366. script.src = url;
  1367. if (attrName !== undefined && attrVal !== undefined) {
  1368. script.setAttribute(attrName, attrVal);
  1369. }
  1370. if (typeof callback === 'function') {
  1371. if ( !tarteaucitron.parameters.useExternalJs ) {
  1372. script.onreadystatechange = script.onload = function () {
  1373. var state = script.readyState;
  1374. if (!done && (!state || /loaded|complete/.test(state))) {
  1375. done = true;
  1376. callback();
  1377. }
  1378. };
  1379. } else {
  1380. callback();
  1381. }
  1382. }
  1383. if ( !tarteaucitron.parameters.useExternalJs || !internal ) {
  1384. document.getElementsByTagName('head')[0].appendChild(script);
  1385. }
  1386. }
  1387. },
  1388. "addInternalScript": function (url, id, callback, execute, attrName, attrVal) {
  1389. tarteaucitron.addScript(url, id, callback, execute, attrName, attrVal, true);
  1390. },
  1391. "makeAsync": {
  1392. "antiGhost": 0,
  1393. "buffer": '',
  1394. "init": function (url, id) {
  1395. "use strict";
  1396. var savedWrite = document.write,
  1397. savedWriteln = document.writeln;
  1398. document.write = function (content) {
  1399. tarteaucitron.makeAsync.buffer += content;
  1400. };
  1401. document.writeln = function (content) {
  1402. tarteaucitron.makeAsync.buffer += content.concat("\n");
  1403. };
  1404. setTimeout(function () {
  1405. document.write = savedWrite;
  1406. document.writeln = savedWriteln;
  1407. }, 20000);
  1408. tarteaucitron.makeAsync.getAndParse(url, id);
  1409. },
  1410. "getAndParse": function (url, id) {
  1411. "use strict";
  1412. if (tarteaucitron.makeAsync.antiGhost > 9) {
  1413. tarteaucitron.makeAsync.antiGhost = 0;
  1414. return;
  1415. }
  1416. tarteaucitron.makeAsync.antiGhost += 1;
  1417. tarteaucitron.addInternalScript(url, '', function () {
  1418. if (document.getElementById(id) !== null) {
  1419. document.getElementById(id).innerHTML += "<span style='display:none'>&nbsp;</span>" + tarteaucitron.makeAsync.buffer;
  1420. tarteaucitron.makeAsync.buffer = '';
  1421. tarteaucitron.makeAsync.execJS(id);
  1422. }
  1423. });
  1424. },
  1425. "execJS": function (id) {
  1426. /* not strict because third party scripts may have errors */
  1427. var i,
  1428. scripts,
  1429. childId,
  1430. type;
  1431. if (document.getElementById(id) === null) {
  1432. return;
  1433. }
  1434. scripts = document.getElementById(id).getElementsByTagName('script');
  1435. for (i = 0; i < scripts.length; i += 1) {
  1436. type = (scripts[i].getAttribute('type') !== null) ? scripts[i].getAttribute('type') : '';
  1437. if (type === '') {
  1438. type = (scripts[i].getAttribute('language') !== null) ? scripts[i].getAttribute('language') : '';
  1439. }
  1440. if (scripts[i].getAttribute('src') !== null && scripts[i].getAttribute('src') !== '') {
  1441. childId = id + Math.floor(Math.random() * 99999999999);
  1442. document.getElementById(id).innerHTML += '<div id="' + childId + '"></div>';
  1443. tarteaucitron.makeAsync.getAndParse(scripts[i].getAttribute('src'), childId);
  1444. } else if (type.indexOf('javascript') !== -1 || type === '') {
  1445. eval(scripts[i].innerHTML);
  1446. }
  1447. }
  1448. }
  1449. },
  1450. "fallback": function (matchClass, content, noInner) {
  1451. "use strict";
  1452. var elems = document.getElementsByTagName('*'),
  1453. i,
  1454. index = 0;
  1455. for (i in elems) {
  1456. if (elems[i] !== undefined) {
  1457. for (index = 0; index < matchClass.length; index += 1) {
  1458. if ((' ' + elems[i].className + ' ')
  1459. .indexOf(' ' + matchClass[index] + ' ') > -1) {
  1460. if (typeof content === 'function') {
  1461. if (noInner === true) {
  1462. content(elems[i]);
  1463. } else {
  1464. elems[i].innerHTML = content(elems[i]);
  1465. }
  1466. } else {
  1467. elems[i].innerHTML = content;
  1468. }
  1469. }
  1470. }
  1471. }
  1472. }
  1473. },
  1474. "engage": function (id) {
  1475. "use strict";
  1476. var html = '',
  1477. r = Math.floor(Math.random() * 100000),
  1478. engage = tarteaucitron.services[id].name + ' ' + tarteaucitron.lang.fallback;
  1479. if (tarteaucitron.lang['engage-' + id] !== undefined) {
  1480. engage = tarteaucitron.lang['engage-' + id];
  1481. }
  1482. html += '<div class="tac_activate">';
  1483. html += ' <div class="tac_float">';
  1484. html += ' ' + engage;
  1485. // html += ' <button type="button" class="tarteaucitronAllow" id="Eng' + r + 'ed' + id + '" onclick="tarteaucitron.userInterface.respond(this, true);">';
  1486. html += ' <button type="button" class="tarteaucitronAllow" id="Eng' + r + 'ed' + id + '">';
  1487. html += ' &#10003; ' + tarteaucitron.lang.allow;
  1488. html += ' </button>';
  1489. html += ' </div>';
  1490. html += '</div>';
  1491. return html;
  1492. },
  1493. "extend": function (a, b) {
  1494. "use strict";
  1495. var prop;
  1496. for (prop in b) {
  1497. if (b.hasOwnProperty(prop)) {
  1498. a[prop] = b[prop];
  1499. }
  1500. }
  1501. },
  1502. "proTemp": '',
  1503. "proTimer": function () {
  1504. "use strict";
  1505. setTimeout(tarteaucitron.proPing, 500);
  1506. },
  1507. "pro": function (list) {
  1508. "use strict";
  1509. tarteaucitron.proTemp += list;
  1510. clearTimeout(tarteaucitron.proTimer);
  1511. tarteaucitron.proTimer = setTimeout(tarteaucitron.proPing, 500);
  1512. },
  1513. "proPing": function () {
  1514. "use strict";
  1515. if (tarteaucitron.uuid !== '' && tarteaucitron.uuid !== undefined && tarteaucitron.proTemp !== '') {
  1516. var div = document.getElementById('tarteaucitronPremium'),
  1517. timestamp = new Date().getTime(),
  1518. url = 'https://tarteaucitron.io/log/?';
  1519. if (div === null) {
  1520. return;
  1521. }
  1522. url += 'account=' + tarteaucitron.uuid + '&';
  1523. url += 'domain=' + tarteaucitron.domain + '&';
  1524. url += 'status=' + encodeURIComponent(tarteaucitron.proTemp) + '&';
  1525. url += '_time=' + timestamp;
  1526. div.innerHTML = '<img src="' + url + '" style="display:none" />';
  1527. tarteaucitron.proTemp = '';
  1528. }
  1529. tarteaucitron.cookie.number();
  1530. },
  1531. "AddOrUpdate" : function(source, custom){
  1532. /**
  1533. Utility function to Add or update the fields of obj1 with the ones in obj2
  1534. */
  1535. for(key in custom){
  1536. if(custom[key] instanceof Object){
  1537. source[key] = tarteaucitron.AddOrUpdate(source[key], custom[key]);
  1538. }else{
  1539. source[key] = custom[key];
  1540. }
  1541. }
  1542. return source;
  1543. },
  1544. "getElemWidth": function(elem) {
  1545. return elem.getAttribute('width') || elem.clientWidth;
  1546. },
  1547. "getElemHeight": function(elem) {
  1548. return elem.getAttribute('height') || elem.clientHeight;
  1549. },
  1550. "addClickEventToId": function (elemId, func) {
  1551. tarteaucitron.addClickEventToElement(document.getElementById(elemId), func);
  1552. },
  1553. "addClickEventToElement": function (e, func) {
  1554. if (e) {
  1555. if (e.addEventListener) {
  1556. e.addEventListener("click", func);
  1557. } else {
  1558. e.attachEvent("onclick", func);
  1559. }
  1560. }
  1561. }
  1562. };