tarteaucitron.js 81 KB

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