tarteaucitron.js 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402
  1. /*jslint browser: true, evil: true */
  2. // define correct path for files inclusion
  3. var scripts = document.getElementsByTagName('script'),
  4. path = scripts[scripts.length - 1].src.split('?')[0],
  5. tarteaucitronForceCDN = (tarteaucitronForceCDN === undefined) ? '' : tarteaucitronForceCDN,
  6. cdn = (tarteaucitronForceCDN === '') ? path.split('/').slice(0, -1).join('/') + '/' : tarteaucitronForceCDN,
  7. alreadyLaunch = (alreadyLaunch === undefined) ? 0 : alreadyLaunch,
  8. tarteaucitronForceLanguage = (tarteaucitronForceLanguage === undefined) ? '' : tarteaucitronForceLanguage,
  9. tarteaucitronForceExpire = (tarteaucitronForceExpire === undefined) ? '' : tarteaucitronForceExpire,
  10. tarteaucitronCustomText = (tarteaucitronCustomText === undefined) ? '' : tarteaucitronCustomText,
  11. timeExipre = 31536000000,
  12. tarteaucitronProLoadServices,
  13. tarteaucitronNoAdBlocker = false;
  14. var tarteaucitron = {
  15. "version": 323,
  16. "cdn": cdn,
  17. "user": {},
  18. "lang": {},
  19. "services": {},
  20. "added": [],
  21. "idprocessed": [],
  22. "state": [],
  23. "launch": [],
  24. "parameters": {},
  25. "isAjax": false,
  26. "reloadThePage": false,
  27. "init": function (params) {
  28. "use strict";
  29. var origOpen;
  30. tarteaucitron.parameters = params;
  31. if (alreadyLaunch === 0) {
  32. alreadyLaunch = 1;
  33. if (window.addEventListener) {
  34. window.addEventListener("load", function () {
  35. tarteaucitron.load();
  36. tarteaucitron.fallback(['tarteaucitronOpenPanel'], function (elem) {
  37. elem.addEventListener("click", function (event) {
  38. tarteaucitron.userInterface.openPanel();
  39. event.preventDefault();
  40. }, false);
  41. }, true);
  42. }, false);
  43. window.addEventListener("scroll", function () {
  44. var scrollPos = window.pageYOffset || document.documentElement.scrollTop,
  45. heightPosition;
  46. if (document.getElementById('tarteaucitronAlertBig') !== null && !tarteaucitron.highPrivacy) {
  47. if (document.getElementById('tarteaucitronAlertBig').style.display === 'block') {
  48. heightPosition = document.getElementById('tarteaucitronAlertBig').offsetHeight + 'px';
  49. if (scrollPos > (screen.height * 2)) {
  50. tarteaucitron.userInterface.respondAll(true);
  51. } else if (scrollPos > (screen.height / 2)) {
  52. document.getElementById('tarteaucitronDisclaimerAlert').innerHTML = '<strong>' + tarteaucitron.lang.alertBigScroll + '</strong> ' + tarteaucitron.lang.alertBig;
  53. }
  54. if (tarteaucitron.orientation === 'top') {
  55. document.getElementById('tarteaucitronPercentage').style.top = heightPosition;
  56. } else {
  57. document.getElementById('tarteaucitronPercentage').style.bottom = heightPosition;
  58. }
  59. document.getElementById('tarteaucitronPercentage').style.width = ((100 / (screen.height * 2)) * scrollPos) + '%';
  60. }
  61. }
  62. }, false);
  63. window.addEventListener("keydown", function (evt) {
  64. if (evt.keyCode === 27) {
  65. tarteaucitron.userInterface.closePanel();
  66. }
  67. }, false);
  68. window.addEventListener("hashchange", function () {
  69. if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
  70. tarteaucitron.userInterface.openPanel();
  71. }
  72. }, false);
  73. window.addEventListener("resize", function () {
  74. if (document.getElementById('tarteaucitron') !== null) {
  75. if (document.getElementById('tarteaucitron').style.display === 'block') {
  76. tarteaucitron.userInterface.jsSizing('main');
  77. }
  78. }
  79. if (document.getElementById('tarteaucitronCookiesListContainer') !== null) {
  80. if (document.getElementById('tarteaucitronCookiesListContainer').style.display === 'block') {
  81. tarteaucitron.userInterface.jsSizing('cookie');
  82. }
  83. }
  84. }, false);
  85. } else {
  86. window.attachEvent("onload", function () {
  87. tarteaucitron.load();
  88. tarteaucitron.fallback(['tarteaucitronOpenPanel'], function (elem) {
  89. elem.attachEvent("onclick", function (event) {
  90. tarteaucitron.userInterface.openPanel();
  91. event.preventDefault();
  92. });
  93. }, true);
  94. });
  95. window.attachEvent("onscroll", function () {
  96. var scrollPos = window.pageYOffset || document.documentElement.scrollTop,
  97. heightPosition;
  98. if (document.getElementById('tarteaucitronAlertBig') !== null && !tarteaucitron.highPrivacy) {
  99. if (document.getElementById('tarteaucitronAlertBig').style.display === 'block') {
  100. heightPosition = document.getElementById('tarteaucitronAlertBig').offsetHeight + 'px';
  101. if (scrollPos > (screen.height * 2)) {
  102. tarteaucitron.userInterface.respondAll(true);
  103. } else if (scrollPos > (screen.height / 2)) {
  104. document.getElementById('tarteaucitronDisclaimerAlert').innerHTML = '<strong>' + tarteaucitron.lang.alertBigScroll + '</strong> ' + tarteaucitron.lang.alertBig;
  105. }
  106. if (tarteaucitron.orientation === 'top') {
  107. document.getElementById('tarteaucitronPercentage').style.top = heightPosition;
  108. } else {
  109. document.getElementById('tarteaucitronPercentage').style.bottom = heightPosition;
  110. }
  111. document.getElementById('tarteaucitronPercentage').style.width = ((100 / (screen.height * 2)) * scrollPos) + '%';
  112. }
  113. }
  114. });
  115. window.attachEvent("onkeydown", function (evt) {
  116. if (evt.keyCode === 27) {
  117. tarteaucitron.userInterface.closePanel();
  118. }
  119. if ( evt.keyCode === 9 && focusableEls.indexOf(evt.target) >= 0) {
  120. if ( evt.shiftKey ) /* shift + tab */ {
  121. if (document.activeElement === firstFocusableEl) {
  122. lastFocusableEl.focus();
  123. evt.preventDefault();
  124. }
  125. } else /* tab */ {
  126. if (document.activeElement === lastFocusableEl) {
  127. firstFocusableEl.focus();
  128. evt.preventDefault();
  129. }
  130. }
  131. }
  132. });
  133. window.attachEvent("onhashchange", function () {
  134. if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
  135. tarteaucitron.userInterface.openPanel();
  136. }
  137. });
  138. window.attachEvent("onresize", function () {
  139. if (document.getElementById('tarteaucitron') !== null) {
  140. if (document.getElementById('tarteaucitron').style.display === 'block') {
  141. tarteaucitron.userInterface.jsSizing('main');
  142. }
  143. }
  144. if (document.getElementById('tarteaucitronCookiesListContainer') !== null) {
  145. if (document.getElementById('tarteaucitronCookiesListContainer').style.display === 'block') {
  146. tarteaucitron.userInterface.jsSizing('cookie');
  147. }
  148. }
  149. });
  150. }
  151. if (typeof XMLHttpRequest !== 'undefined') {
  152. origOpen = XMLHttpRequest.prototype.open;
  153. XMLHttpRequest.prototype.open = function () {
  154. if (window.addEventListener) {
  155. this.addEventListener("load", function () {
  156. if (typeof tarteaucitronProLoadServices === 'function') {
  157. tarteaucitronProLoadServices();
  158. }
  159. }, false);
  160. } else if (typeof this.attachEvent !== 'undefined') {
  161. this.attachEvent("onload", function () {
  162. if (typeof tarteaucitronProLoadServices === 'function') {
  163. tarteaucitronProLoadServices();
  164. }
  165. });
  166. } else {
  167. if (typeof tarteaucitronProLoadServices === 'function') {
  168. setTimeout(tarteaucitronProLoadServices, 1000);
  169. }
  170. }
  171. try {
  172. origOpen.apply(this, arguments);
  173. } catch (err) {}
  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": false,
  190. "orientation": "top",
  191. "removeCredit": false,
  192. "showAlertSmall": true,
  193. "cookieslist": true,
  194. "handleBrowserDNTRequest": false
  195. },
  196. params = tarteaucitron.parameters;
  197. // Step 0: get params
  198. if (params !== undefined) {
  199. tarteaucitron.extend(defaults, params);
  200. }
  201. // global
  202. tarteaucitron.orientation = defaults.orientation;
  203. tarteaucitron.hashtag = defaults.hashtag;
  204. tarteaucitron.highPrivacy = defaults.highPrivacy;
  205. tarteaucitron.handleBrowserDNTRequest = defaults.handleBrowserDNTRequest;
  206. // Step 1: load css
  207. linkElement.rel = 'stylesheet';
  208. linkElement.type = 'text/css';
  209. linkElement.href = cdn + 'css/tarteaucitron.css?v=' + tarteaucitron.version;
  210. document.getElementsByTagName('head')[0].appendChild(linkElement);
  211. // Step 2: load language and services
  212. tarteaucitron.addScript(pathToLang, '', function () {
  213. if(tarteaucitronCustomText !== ''){
  214. tarteaucitron.lang = tarteaucitron.AddOrUpdate(tarteaucitron.lang, tarteaucitronCustomText);
  215. }
  216. tarteaucitron.addScript(pathToServices, '', function () {
  217. var body = document.body,
  218. div = document.createElement('div'),
  219. html = '',
  220. index,
  221. orientation = 'Top',
  222. cat = ['ads', 'analytic', 'api', 'comment', 'social', 'support', 'video', 'other'],
  223. i;
  224. cat = cat.sort(function (a, b) {
  225. if (tarteaucitron.lang[a].title > tarteaucitron.lang[b].title) { return 1; }
  226. if (tarteaucitron.lang[a].title < tarteaucitron.lang[b].title) { return -1; }
  227. return 0;
  228. });
  229. // Step 3: prepare the html
  230. html += '<div id="tarteaucitronPremium"></div>';
  231. html += '<button id="tarteaucitronBack" onclick="tarteaucitron.userInterface.closePanel();" aria-label="' + tarteaucitron.lang.close + '"></button>';
  232. html += '<div id="tarteaucitron" role="dialog" aria-labelledby="dialogTitle">';
  233. html += ' <button id="tarteaucitronClosePanel" onclick="tarteaucitron.userInterface.closePanel();">';
  234. html += ' ' + tarteaucitron.lang.close;
  235. html += ' </button>';
  236. html += ' <div id="tarteaucitronServices">';
  237. html += ' <div class="tarteaucitronLine tarteaucitronMainLine" id="tarteaucitronMainLineOffset"><h1 id="dialogTitle">'+ tarteaucitron.lang.title + '</h1>';
  238. html += ' <div class="tarteaucitronName">';
  239. html += ' <button onclick="tarteaucitron.userInterface.toggle(\'tarteaucitronInfo\', \'tarteaucitronInfoBox\');return false" aria-label="' + tarteaucitron.lang.toggleInfoBox + '">&#10011;</button> <h2>' + tarteaucitron.lang.all + '</h2>';
  240. html += ' </div>';
  241. html += ' <div class="tarteaucitronAsk" id="tarteaucitronScrollbarAdjust">';
  242. html += ' <button id="tarteaucitronAllAllowed" class="tarteaucitronAllow" onclick="tarteaucitron.userInterface.respondAll(true);">';
  243. html += ' &#10003; ' + tarteaucitron.lang.allowAll;
  244. html += ' </button> ';
  245. html += ' <button id="tarteaucitronAllDenied" class="tarteaucitronDeny" onclick="tarteaucitron.userInterface.respondAll(false);">';
  246. html += ' &#10007; ' + tarteaucitron.lang.denyAll;
  247. html += ' </button>';
  248. html += ' </div>';
  249. html += ' </div>';
  250. html += ' <div id="tarteaucitronInfo" class="tarteaucitronInfoBox">';
  251. html += ' ' + tarteaucitron.lang.disclaimer;
  252. if (defaults.removeCredit === false) {
  253. html += ' <br/><br/>';
  254. html += ' <a href="https://opt-out.ferank.eu/" rel="nofollow" target="_blank" rel="noopener" title="tarteaucitron ' + tarteaucitron.lang.newWindow + '">' + tarteaucitron.lang.credit + '</a>';
  255. }
  256. html += ' </div>';
  257. html += ' <div class="tarteaucitronBorder" id="tarteaucitronScrollbarParent">';
  258. html += ' <div class="clear"></div><ul>';
  259. for (i = 0; i < cat.length; i += 1) {
  260. html += ' <li id="tarteaucitronServicesTitle_' + cat[i] + '" class="tarteaucitronHidden">';
  261. html += ' <div class="tarteaucitronTitle">';
  262. html += ' <button onclick="tarteaucitron.userInterface.toggle(\'tarteaucitronDetails' + cat[i] + '\', \'tarteaucitronInfoBox\');return false">&#10011; ' + tarteaucitron.lang[cat[i]].title + '</button>';
  263. html += ' </div>';
  264. html += ' <div id="tarteaucitronDetails' + cat[i] + '" class="tarteaucitronDetails tarteaucitronInfoBox">';
  265. html += ' ' + tarteaucitron.lang[cat[i]].details;
  266. html += ' </div>';
  267. html += ' <ul id="tarteaucitronServices_' + cat[i] + '"></ul></li>';
  268. }
  269. html += ' </ul><div class="tarteaucitronHidden" id="tarteaucitronScrollbarChild" style="height:20px;display:block"></div>';
  270. html += ' </div>';
  271. html += ' </div>';
  272. html += '</div>';
  273. if (defaults.orientation === 'bottom') {
  274. orientation = 'Bottom';
  275. }
  276. if (defaults.highPrivacy) {
  277. html += '<div id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + '">';
  278. html += ' <span id="tarteaucitronDisclaimerAlert">';
  279. html += ' ' + tarteaucitron.lang.alertBigPrivacy;
  280. html += ' </span>';
  281. html += ' <button id="tarteaucitronPersonalize" onclick="tarteaucitron.userInterface.openPanel();">';
  282. html += ' ' + tarteaucitron.lang.personalize;
  283. html += ' </button>';
  284. html += '</div>';
  285. } else {
  286. html += '<div id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + '">';
  287. html += ' <span id="tarteaucitronDisclaimerAlert">';
  288. html += ' ' + tarteaucitron.lang.alertBigClick + ' ' + tarteaucitron.lang.alertBig;
  289. html += ' </span>';
  290. html += ' <button id="tarteaucitronPersonalize" onclick="tarteaucitron.userInterface.respondAll(true);">';
  291. html += ' &#10003; ' + tarteaucitron.lang.acceptAll;
  292. html += ' </button>';
  293. html += ' <button id="tarteaucitronCloseAlert" onclick="tarteaucitron.userInterface.openPanel();">';
  294. html += ' ' + tarteaucitron.lang.personalize;
  295. html += ' </button>';
  296. html += '</div>';
  297. html += '<div id="tarteaucitronPercentage"></div>';
  298. }
  299. if (defaults.showAlertSmall === true) {
  300. html += '<div id="tarteaucitronAlertSmall" class="tarteaucitronAlertSmall' + orientation + '">';
  301. html += ' <button id="tarteaucitronManager" onclick="tarteaucitron.userInterface.openPanel();">';
  302. html += ' ' + tarteaucitron.lang.alertSmall;
  303. html += ' <span id="tarteaucitronDot">';
  304. html += ' <span id="tarteaucitronDotGreen"></span>';
  305. html += ' <span id="tarteaucitronDotYellow"></span>';
  306. html += ' <span id="tarteaucitronDotRed"></span>';
  307. html += ' </span>';
  308. if (defaults.cookieslist === true) {
  309. html += ' </button><!-- @whitespace';
  310. html += ' --><button id="tarteaucitronCookiesNumber" onclick="tarteaucitron.userInterface.toggleCookiesList();">0</button>';
  311. html += ' <div id="tarteaucitronCookiesListContainer">';
  312. html += ' <button id="tarteaucitronClosePanelCookie" onclick="tarteaucitron.userInterface.closePanel();">';
  313. html += ' ' + tarteaucitron.lang.close;
  314. html += ' </button>';
  315. html += ' <div class="tarteaucitronCookiesListMain" id="tarteaucitronCookiesTitle">';
  316. html += ' <h2 id="tarteaucitronCookiesNumberBis">0 cookie</h2>';
  317. html += ' </div>';
  318. html += ' <div id="tarteaucitronCookiesList"></div>';
  319. html += ' </div>';
  320. } else {
  321. html += ' </div>';
  322. }
  323. html += '</div>';
  324. }
  325. tarteaucitron.addScript(tarteaucitron.cdn + 'advertising.js?v=' + tarteaucitron.version, '', function () {
  326. if (tarteaucitronNoAdBlocker === true || defaults.adblocker === false) {
  327. // create a wrapper container at the same level than tarteaucitron so we can add an aria-hidden when tarteaucitron is opened
  328. var wrapper = document.createElement('div');
  329. wrapper.id = "contentWrapper";
  330. while (document.body.firstChild)
  331. {
  332. wrapper.appendChild(document.body.firstChild);
  333. }
  334. // Append the wrapper to the body
  335. document.body.appendChild(wrapper);
  336. div.id = 'tarteaucitronRoot';
  337. body.appendChild(div, body);
  338. div.innerHTML = html;
  339. if (tarteaucitron.job !== undefined) {
  340. tarteaucitron.job = tarteaucitron.cleanArray(tarteaucitron.job);
  341. for (index = 0; index < tarteaucitron.job.length; index += 1) {
  342. tarteaucitron.addService(tarteaucitron.job[index]);
  343. }
  344. } else {
  345. tarteaucitron.job = []
  346. }
  347. tarteaucitron.isAjax = true;
  348. tarteaucitron.job.push = function (id) {
  349. // ie <9 hack
  350. if (typeof tarteaucitron.job.indexOf === 'undefined') {
  351. tarteaucitron.job.indexOf = function (obj, start) {
  352. var i,
  353. j = this.length;
  354. for (i = (start || 0); i < j; i += 1) {
  355. if (this[i] === obj) { return i; }
  356. }
  357. return -1;
  358. };
  359. }
  360. if (tarteaucitron.job.indexOf(id) === -1) {
  361. Array.prototype.push.call(this, id);
  362. }
  363. tarteaucitron.launch[id] = false;
  364. tarteaucitron.addService(id);
  365. };
  366. if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
  367. tarteaucitron.userInterface.openPanel();
  368. }
  369. tarteaucitron.cookie.number();
  370. setInterval(tarteaucitron.cookie.number, 60000);
  371. }
  372. }, defaults.adblocker);
  373. if (defaults.adblocker === true) {
  374. setTimeout(function () {
  375. if (tarteaucitronNoAdBlocker === false) {
  376. html = '<div id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + '" style="display:block" role="alert" aria-live="polite">';
  377. html += ' <p id="tarteaucitronDisclaimerAlert">';
  378. html += ' ' + tarteaucitron.lang.adblock + '<br/>';
  379. html += ' <strong>' + tarteaucitron.lang.adblock_call + '</strong>';
  380. html += ' </p>';
  381. html += ' <button id="tarteaucitronPersonalize" onclick="location.reload();">';
  382. html += ' ' + tarteaucitron.lang.reload;
  383. html += ' </button>';
  384. html += '</div>';
  385. html += '<div id="tarteaucitronPremium"></div>';
  386. // create wrapper container
  387. var wrapper = document.createElement('div');
  388. wrapper.id = "contentWrapper";
  389. while (document.body.firstChild)
  390. {
  391. wrapper.appendChild(document.body.firstChild);
  392. }
  393. // Append the wrapper to the body
  394. document.body.appendChild(wrapper);
  395. div.id = 'tarteaucitronRoot';
  396. body.appendChild(div, body);
  397. div.innerHTML = html;
  398. tarteaucitron.pro('!adblocker=true');
  399. } else {
  400. tarteaucitron.pro('!adblocker=false');
  401. }
  402. }, 1500);
  403. }
  404. });
  405. });
  406. },
  407. "addService": function (serviceId) {
  408. "use strict";
  409. var html = '',
  410. s = tarteaucitron.services,
  411. service = s[serviceId],
  412. cookie = tarteaucitron.cookie.read(),
  413. hostname = document.location.hostname,
  414. hostRef = document.referrer.split('/')[2],
  415. isNavigating = (hostRef === hostname) ? true : false,
  416. isAutostart = (!service.needConsent) ? true : false,
  417. isWaiting = (cookie.indexOf(service.key + '=wait') >= 0) ? true : false,
  418. isDenied = (cookie.indexOf(service.key + '=false') >= 0) ? true : false,
  419. isAllowed = (cookie.indexOf(service.key + '=true') >= 0) ? true : false,
  420. isResponded = (cookie.indexOf(service.key + '=false') >= 0 || cookie.indexOf(service.key + '=true') >= 0) ? true : false,
  421. isDNTRequested = (navigator.doNotTrack === "1" || navigator.doNotTrack === "yes" || navigator.msDoNotTrack === "1" || window.doNotTrack === "1") ? true : false;
  422. if (tarteaucitron.added[service.key] !== true) {
  423. tarteaucitron.added[service.key] = true;
  424. html += '<li id="' + service.key + 'Line" class="tarteaucitronLine">';
  425. html += ' <div class="tarteaucitronName">';
  426. html += ' <h3>' + service.name + '</h3><br/>';
  427. html += ' <span id="tacCL' + service.key + '" class="tarteaucitronListCookies"></span><br/>';
  428. html += ' <a href="https://opt-out.ferank.eu/service/' + service.key + '/" target="_blank" rel="noopener" title="'+ tarteaucitron.lang.cookieDetail + ' ' + service.name + ' ' + tarteaucitron.lang.ourSite + ' ' + tarteaucitron.lang.newWindow +'">';
  429. html += ' ' + tarteaucitron.lang.more;
  430. html += ' </a>';
  431. html += ' - ';
  432. html += ' <a href="' + service.uri + '" target="_blank" rel="noopener" title="' + service.name + ' ' + tarteaucitron.lang.newWindow + '">';
  433. html += ' ' + tarteaucitron.lang.source;
  434. html += ' </a>';
  435. html += ' </div>';
  436. html += ' <div class="tarteaucitronAsk">';
  437. html += ' <button id="' + service.key + 'Allowed" class="tarteaucitronAllow" onclick="tarteaucitron.userInterface.respond(this, true);">';
  438. html += ' &#10003; ' + tarteaucitron.lang.allow;
  439. html += ' </button> ';
  440. html += ' <button id="' + service.key + 'Denied" class="tarteaucitronDeny" onclick="tarteaucitron.userInterface.respond(this, false);">';
  441. html += ' &#10007; ' + tarteaucitron.lang.deny;
  442. html += ' </button>';
  443. html += ' </div>';
  444. html += '</li>';
  445. tarteaucitron.userInterface.css('tarteaucitronServicesTitle_' + service.type, 'display', 'block');
  446. if (document.getElementById('tarteaucitronServices_' + service.type) !== null) {
  447. document.getElementById('tarteaucitronServices_' + service.type).innerHTML += html;
  448. }
  449. tarteaucitron.userInterface.order(service.type);
  450. }
  451. // allow by default for non EU
  452. if (isResponded === false && tarteaucitron.user.bypass === true) {
  453. isAllowed = true;
  454. tarteaucitron.cookie.create(service.key, true);
  455. }
  456. if ((!isResponded && (isAutostart || (isNavigating && isWaiting)) && !tarteaucitron.highPrivacy) || isAllowed) {
  457. if (!isAllowed) {
  458. tarteaucitron.cookie.create(service.key, true);
  459. }
  460. if (tarteaucitron.launch[service.key] !== true) {
  461. tarteaucitron.launch[service.key] = true;
  462. service.js();
  463. }
  464. tarteaucitron.state[service.key] = true;
  465. tarteaucitron.userInterface.color(service.key, true);
  466. } else if (isDenied) {
  467. if (typeof service.fallback === 'function') {
  468. service.fallback();
  469. }
  470. tarteaucitron.state[service.key] = false;
  471. tarteaucitron.userInterface.color(service.key, false);
  472. } else if (!isResponded && isDNTRequested && tarteaucitron.handleBrowserDNTRequest) {
  473. tarteaucitron.cookie.create(service.key, 'false');
  474. if (typeof service.fallback === 'function') {
  475. service.fallback();
  476. }
  477. tarteaucitron.state[service.key] = false;
  478. tarteaucitron.userInterface.color(service.key, false);
  479. } else if (!isResponded) {
  480. tarteaucitron.cookie.create(service.key, 'wait');
  481. if (typeof service.fallback === 'function') {
  482. service.fallback();
  483. }
  484. tarteaucitron.userInterface.color(service.key, 'wait');
  485. tarteaucitron.userInterface.openAlert();
  486. }
  487. tarteaucitron.cookie.checkCount(service.key);
  488. },
  489. "cleanArray": function cleanArray(arr) {
  490. "use strict";
  491. var i,
  492. len = arr.length,
  493. out = [],
  494. obj = {},
  495. s = tarteaucitron.services;
  496. for (i = 0; i < len; i += 1) {
  497. if (!obj[arr[i]]) {
  498. obj[arr[i]] = {};
  499. if (tarteaucitron.services[arr[i]] !== undefined) {
  500. out.push(arr[i]);
  501. }
  502. }
  503. }
  504. out = out.sort(function (a, b) {
  505. if (s[a].type + s[a].key > s[b].type + s[b].key) { return 1; }
  506. if (s[a].type + s[a].key < s[b].type + s[b].key) { return -1; }
  507. return 0;
  508. });
  509. return out;
  510. },
  511. "userInterface": {
  512. "css": function (id, property, value) {
  513. "use strict";
  514. if (document.getElementById(id) !== null) {
  515. document.getElementById(id).style[property] = value;
  516. }
  517. },
  518. "respondAll": function (status) {
  519. "use strict";
  520. var s = tarteaucitron.services,
  521. service,
  522. key,
  523. index = 0;
  524. for (index = 0; index < tarteaucitron.job.length; index += 1) {
  525. service = s[tarteaucitron.job[index]];
  526. key = service.key;
  527. if (tarteaucitron.state[key] !== status) {
  528. if (status === false && tarteaucitron.launch[key] === true) {
  529. tarteaucitron.reloadThePage = true;
  530. }
  531. if (tarteaucitron.launch[key] !== true && status === true) {
  532. tarteaucitron.launch[key] = true;
  533. tarteaucitron.services[key].js();
  534. }
  535. tarteaucitron.state[key] = status;
  536. tarteaucitron.cookie.create(key, status);
  537. tarteaucitron.userInterface.color(key, status);
  538. }
  539. }
  540. },
  541. "respond": function (el, status) {
  542. "use strict";
  543. var key = el.id.replace(new RegExp("(Eng[0-9]+|Allow|Deni)ed", "g"), '');
  544. // return if same state
  545. if (tarteaucitron.state[key] === status) {
  546. return;
  547. }
  548. if (status === false && tarteaucitron.launch[key] === true) {
  549. tarteaucitron.reloadThePage = true;
  550. }
  551. // if not already launched... launch the service
  552. if (status === true) {
  553. if (tarteaucitron.launch[key] !== true) {
  554. tarteaucitron.launch[key] = true;
  555. tarteaucitron.services[key].js();
  556. }
  557. }
  558. tarteaucitron.state[key] = status;
  559. tarteaucitron.cookie.create(key, status);
  560. tarteaucitron.userInterface.color(key, status);
  561. },
  562. "color": function (key, status) {
  563. "use strict";
  564. var gray = '#808080',
  565. greenDark = '#1B870B',
  566. greenLight = '#E6FFE2',
  567. redDark = '#9C1A1A',
  568. redLight = '#FFE2E2',
  569. yellowDark = '#FBDA26',
  570. c = 'tarteaucitron',
  571. nbDenied = 0,
  572. nbPending = 0,
  573. nbAllowed = 0,
  574. sum = tarteaucitron.job.length,
  575. index;
  576. if (status === true) {
  577. tarteaucitron.userInterface.css(key + 'Line', 'borderLeft', '5px solid ' + greenDark);
  578. tarteaucitron.userInterface.css(key + 'Allowed', 'backgroundColor', greenDark);
  579. tarteaucitron.userInterface.css(key + 'Denied', 'backgroundColor', gray);
  580. } else if (status === false) {
  581. tarteaucitron.userInterface.css(key + 'Line', 'borderLeft', '5px solid ' + redDark);
  582. tarteaucitron.userInterface.css(key + 'Allowed', 'backgroundColor', gray);
  583. tarteaucitron.userInterface.css(key + 'Denied', 'backgroundColor', redDark);
  584. }
  585. // check if all services are allowed
  586. for (index = 0; index < sum; index += 1) {
  587. if (tarteaucitron.state[tarteaucitron.job[index]] === false) {
  588. nbDenied += 1;
  589. } else if (tarteaucitron.state[tarteaucitron.job[index]] === undefined) {
  590. nbPending += 1;
  591. } else if (tarteaucitron.state[tarteaucitron.job[index]] === true) {
  592. nbAllowed += 1;
  593. }
  594. }
  595. tarteaucitron.userInterface.css(c + 'DotGreen', 'width', ((100 / sum) * nbAllowed) + '%');
  596. tarteaucitron.userInterface.css(c + 'DotYellow', 'width', ((100 / sum) * nbPending) + '%');
  597. tarteaucitron.userInterface.css(c + 'DotRed', 'width', ((100 / sum) * nbDenied) + '%');
  598. if (nbDenied === 0 && nbPending === 0) {
  599. tarteaucitron.userInterface.css(c + 'AllAllowed', 'backgroundColor', greenDark);
  600. tarteaucitron.userInterface.css(c + 'AllDenied', 'backgroundColor', gray);
  601. } else if (nbAllowed === 0 && nbPending === 0) {
  602. tarteaucitron.userInterface.css(c + 'AllAllowed', 'backgroundColor', gray);
  603. tarteaucitron.userInterface.css(c + 'AllDenied', 'backgroundColor', redDark);
  604. } else {
  605. tarteaucitron.userInterface.css(c + 'AllAllowed', 'backgroundColor', gray);
  606. tarteaucitron.userInterface.css(c + 'AllDenied', 'backgroundColor', gray);
  607. }
  608. // close the alert if all service have been reviewed
  609. if (nbPending === 0) {
  610. tarteaucitron.userInterface.closeAlert();
  611. }
  612. if (tarteaucitron.services[key].cookies.length > 0 && status === false) {
  613. tarteaucitron.cookie.purge(tarteaucitron.services[key].cookies);
  614. }
  615. if (status === true) {
  616. if (document.getElementById('tacCL' + key) !== null) {
  617. document.getElementById('tacCL' + key).innerHTML = '...';
  618. }
  619. setTimeout(function () {
  620. tarteaucitron.cookie.checkCount(key);
  621. }, 2500);
  622. } else {
  623. tarteaucitron.cookie.checkCount(key);
  624. }
  625. },
  626. "openPanel": function () {
  627. "use strict";
  628. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'block');
  629. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
  630. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
  631. document.getElementById('tarteaucitronClosePanel').focus();
  632. document.getElementById('contentWrapper').setAttribute("aria-hidden", "true");
  633. document.getElementsByTagName('body')[0].classList.add('modal-open');
  634. tarteaucitron.userInterface.focusTrap();
  635. tarteaucitron.userInterface.jsSizing('main');
  636. },
  637. "closePanel": function () {
  638. "use strict";
  639. if (document.location.hash === tarteaucitron.hashtag) {
  640. document.location.hash = '';
  641. }
  642. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  643. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
  644. tarteaucitron.fallback(['tarteaucitronInfoBox'], function (elem) {
  645. elem.style.display = 'none';
  646. }, true);
  647. if (tarteaucitron.reloadThePage === true) {
  648. window.location.reload();
  649. } else {
  650. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
  651. }
  652. document.getElementById('tarteaucitronCloseAlert').focus();
  653. document.getElementById('contentWrapper').setAttribute("aria-hidden", "false");
  654. document.getElementsByTagName('body')[0].classList.remove('modal-open');
  655. },
  656. "focusTrap": function() {
  657. "use strict";
  658. var focusableEls,
  659. firstFocusableEl,
  660. lastFocusableEl,
  661. filtered;
  662. focusableEls = document.getElementById('tarteaucitron').querySelectorAll('a[href], button');
  663. filtered = [];
  664. // get only visible items
  665. for (var i = 0, max = focusableEls.length; i < max; i++) {
  666. if (focusableEls[i].offsetHeight > 0) {
  667. filtered.push(focusableEls[i]);
  668. }
  669. }
  670. firstFocusableEl = filtered[0];
  671. lastFocusableEl = filtered[filtered.length - 1];
  672. //loop focus inside tarteaucitron
  673. document.getElementById('tarteaucitron').addEventListener("keydown", function (evt) {
  674. if ( evt.key === 'Tab' || evt.keyCode === 9 ) {
  675. if ( evt.shiftKey ) /* shift + tab */ {
  676. if (document.activeElement === firstFocusableEl) {
  677. lastFocusableEl.focus();
  678. evt.preventDefault();
  679. }
  680. } else /* tab */ {
  681. if (document.activeElement === lastFocusableEl) {
  682. firstFocusableEl.focus();
  683. evt.preventDefault();
  684. }
  685. }
  686. }
  687. })
  688. },
  689. "openAlert": function () {
  690. "use strict";
  691. var c = 'tarteaucitron';
  692. tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'block');
  693. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'none');
  694. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'block');
  695. },
  696. "closeAlert": function () {
  697. "use strict";
  698. var c = 'tarteaucitron';
  699. tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'none');
  700. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'block');
  701. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'none');
  702. tarteaucitron.userInterface.jsSizing('box');
  703. },
  704. "toggleCookiesList": function () {
  705. "use strict";
  706. var div = document.getElementById('tarteaucitronCookiesListContainer');
  707. if (div === null) {
  708. return;
  709. }
  710. if (div.style.display !== 'block') {
  711. tarteaucitron.cookie.number();
  712. div.style.display = 'block';
  713. tarteaucitron.userInterface.jsSizing('cookie');
  714. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  715. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
  716. tarteaucitron.fallback(['tarteaucitronInfoBox'], function (elem) {
  717. elem.style.display = 'none';
  718. }, true);
  719. } else {
  720. div.style.display = 'none';
  721. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  722. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
  723. }
  724. },
  725. "toggle": function (id, closeClass) {
  726. "use strict";
  727. var div = document.getElementById(id);
  728. if (div === null) {
  729. return;
  730. }
  731. if (closeClass !== undefined) {
  732. tarteaucitron.fallback([closeClass], function (elem) {
  733. if (elem.id !== id) {
  734. elem.style.display = 'none';
  735. }
  736. }, true);
  737. }
  738. if (div.style.display !== 'block') {
  739. div.style.display = 'block';
  740. } else {
  741. div.style.display = 'none';
  742. }
  743. },
  744. "order": function (id) {
  745. "use strict";
  746. var main = document.getElementById('tarteaucitronServices_' + id),
  747. allDivs,
  748. store = [],
  749. i;
  750. if (main === null) {
  751. return;
  752. }
  753. allDivs = main.childNodes;
  754. if (typeof Array.prototype.map === 'function') {
  755. Array.prototype.map.call(main.children, Object).sort(function (a, b) {
  756. if (tarteaucitron.services[a.id.replace(/Line/g, '')].name > tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return 1; }
  757. if (tarteaucitron.services[a.id.replace(/Line/g, '')].name < tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return -1; }
  758. return 0;
  759. }).forEach(function (element) {
  760. main.appendChild(element);
  761. });
  762. }
  763. },
  764. "jsSizing": function (type) {
  765. "use strict";
  766. var scrollbarMarginRight = 10,
  767. scrollbarWidthParent,
  768. scrollbarWidthChild,
  769. servicesHeight,
  770. e = window,
  771. a = 'inner',
  772. windowInnerHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
  773. mainTop,
  774. mainHeight,
  775. closeButtonHeight,
  776. headerHeight,
  777. cookiesListHeight,
  778. cookiesCloseHeight,
  779. cookiesTitleHeight,
  780. paddingBox,
  781. alertSmallHeight,
  782. cookiesNumberHeight;
  783. if (type === 'box') {
  784. if (document.getElementById('tarteaucitronAlertSmall') !== null && document.getElementById('tarteaucitronCookiesNumber') !== null) {
  785. // reset
  786. tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', '0px 10px');
  787. // calculate
  788. alertSmallHeight = document.getElementById('tarteaucitronAlertSmall').offsetHeight;
  789. cookiesNumberHeight = document.getElementById('tarteaucitronCookiesNumber').offsetHeight;
  790. paddingBox = (alertSmallHeight - cookiesNumberHeight) / 2;
  791. // apply
  792. tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', paddingBox + 'px 10px');
  793. }
  794. } else if (type === 'main') {
  795. // get the real window width for media query
  796. if (window.innerWidth === undefined) {
  797. a = 'client';
  798. e = document.documentElement || document.body;
  799. }
  800. // height of the services list container
  801. if (document.getElementById('tarteaucitron') !== null && document.getElementById('tarteaucitronClosePanel') !== null && document.getElementById('tarteaucitronMainLineOffset') !== null) {
  802. // reset
  803. tarteaucitron.userInterface.css('tarteaucitronScrollbarParent', 'height', 'auto');
  804. // calculate
  805. mainHeight = document.getElementById('tarteaucitron').offsetHeight;
  806. closeButtonHeight = document.getElementById('tarteaucitronClosePanel').offsetHeight;
  807. headerHeight = document.getElementById('tarteaucitronMainLineOffset').offsetHeight;
  808. // apply
  809. servicesHeight = (mainHeight - closeButtonHeight - headerHeight + 1);
  810. tarteaucitron.userInterface.css('tarteaucitronScrollbarParent', 'height', servicesHeight + 'px');
  811. }
  812. // align the main allow/deny button depending on scrollbar width
  813. if (document.getElementById('tarteaucitronScrollbarParent') !== null && document.getElementById('tarteaucitronScrollbarChild') !== null) {
  814. // media query
  815. if (e[a + 'Width'] <= 479) {
  816. tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginLeft', '11px');
  817. } else if (e[a + 'Width'] <= 767) {
  818. scrollbarMarginRight = 12;
  819. }
  820. scrollbarWidthParent = document.getElementById('tarteaucitronScrollbarParent').offsetWidth;
  821. scrollbarWidthChild = document.getElementById('tarteaucitronScrollbarChild').offsetWidth;
  822. tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginRight', ((scrollbarWidthParent - scrollbarWidthChild) + scrollbarMarginRight) + 'px');
  823. }
  824. // center the main panel
  825. if (document.getElementById('tarteaucitron') !== null) {
  826. // media query
  827. if (e[a + 'Width'] <= 767) {
  828. mainTop = 0;
  829. } else {
  830. mainTop = ((windowInnerHeight - document.getElementById('tarteaucitron').offsetHeight) / 2) - 21;
  831. }
  832. // correct
  833. if (mainTop < 0) {
  834. mainTop = 0;
  835. }
  836. if (document.getElementById('tarteaucitronMainLineOffset') !== null) {
  837. if (document.getElementById('tarteaucitron').offsetHeight < (windowInnerHeight / 2)) {
  838. mainTop -= document.getElementById('tarteaucitronMainLineOffset').offsetHeight;
  839. }
  840. }
  841. // apply
  842. tarteaucitron.userInterface.css('tarteaucitron', 'top', mainTop + 'px');
  843. }
  844. } else if (type === 'cookie') {
  845. // put cookies list at bottom
  846. if (document.getElementById('tarteaucitronAlertSmall') !== null) {
  847. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'bottom', (document.getElementById('tarteaucitronAlertSmall').offsetHeight) + 'px');
  848. }
  849. // height of cookies list
  850. if (document.getElementById('tarteaucitronCookiesListContainer') !== null) {
  851. // reset
  852. tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', 'auto');
  853. // calculate
  854. cookiesListHeight = document.getElementById('tarteaucitronCookiesListContainer').offsetHeight;
  855. cookiesCloseHeight = document.getElementById('tarteaucitronClosePanelCookie').offsetHeight;
  856. cookiesTitleHeight = document.getElementById('tarteaucitronCookiesTitle').offsetHeight;
  857. // apply
  858. tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', (cookiesListHeight - cookiesCloseHeight - cookiesTitleHeight - 2) + 'px');
  859. }
  860. }
  861. }
  862. },
  863. "cookie": {
  864. "owner": {},
  865. "create": function (key, status) {
  866. "use strict";
  867. if (tarteaucitronForceExpire !== '') {
  868. // The number of day cann't be higher than 1 year
  869. timeExipre = (tarteaucitronForceExpire > 365) ? 31536000000 : tarteaucitronForceExpire * 86400000; // Multiplication to tranform the number of days to milliseconds
  870. }
  871. var d = new Date(),
  872. time = d.getTime(),
  873. expireTime = time + timeExipre, // 365 days
  874. regex = new RegExp("!" + key + "=(wait|true|false)", "g"),
  875. cookie = tarteaucitron.cookie.read().replace(regex, ""),
  876. value = tarteaucitron.parameters.cookieName + '=' + cookie + '!' + key + '=' + status,
  877. domain = (tarteaucitron.parameters.cookieDomain !== undefined && tarteaucitron.parameters.cookieDomain !== '') ? 'domain=' + tarteaucitron.parameters.cookieDomain + ';' : '';
  878. if (tarteaucitron.cookie.read().indexOf(key + '=' + status) === -1) {
  879. tarteaucitron.pro('!' + key + '=' + status);
  880. }
  881. d.setTime(expireTime);
  882. document.cookie = value + '; expires=' + d.toGMTString() + '; path=/;' + domain;
  883. },
  884. "read": function () {
  885. "use strict";
  886. var nameEQ = tarteaucitron.parameters.cookieName + "=",
  887. ca = document.cookie.split(';'),
  888. i,
  889. c;
  890. for (i = 0; i < ca.length; i += 1) {
  891. c = ca[i];
  892. while (c.charAt(0) === ' ') {
  893. c = c.substring(1, c.length);
  894. }
  895. if (c.indexOf(nameEQ) === 0) {
  896. return c.substring(nameEQ.length, c.length);
  897. }
  898. }
  899. return '';
  900. },
  901. "purge": function (arr) {
  902. "use strict";
  903. var i;
  904. for (i = 0; i < arr.length; i += 1) {
  905. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/;';
  906. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname + ';';
  907. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname.split('.').slice(-2).join('.') + ';';
  908. }
  909. },
  910. "checkCount": function (key) {
  911. "use strict";
  912. var arr = tarteaucitron.services[key].cookies,
  913. nb = arr.length,
  914. nbCurrent = 0,
  915. html = '',
  916. i,
  917. status = document.cookie.indexOf(key + '=true');
  918. if (status >= 0 && nb === 0) {
  919. html += tarteaucitron.lang.useNoCookie;
  920. } else if (status >= 0) {
  921. for (i = 0; i < nb; i += 1) {
  922. if (document.cookie.indexOf(arr[i] + '=') !== -1) {
  923. nbCurrent += 1;
  924. if (tarteaucitron.cookie.owner[arr[i]] === undefined) {
  925. tarteaucitron.cookie.owner[arr[i]] = [];
  926. }
  927. if (tarteaucitron.cookie.crossIndexOf(tarteaucitron.cookie.owner[arr[i]], tarteaucitron.services[key].name) === false) {
  928. tarteaucitron.cookie.owner[arr[i]].push(tarteaucitron.services[key].name);
  929. }
  930. }
  931. }
  932. if (nbCurrent > 0) {
  933. html += tarteaucitron.lang.useCookieCurrent + ' ' + nbCurrent + ' cookie';
  934. if (nbCurrent > 1) {
  935. html += 's';
  936. }
  937. html += '.';
  938. } else {
  939. html += tarteaucitron.lang.useNoCookie;
  940. }
  941. } else if (nb === 0) {
  942. html = tarteaucitron.lang.noCookie;
  943. } else {
  944. html += tarteaucitron.lang.useCookie + ' ' + nb + ' cookie';
  945. if (nb > 1) {
  946. html += 's';
  947. }
  948. html += '.';
  949. }
  950. if (document.getElementById('tacCL' + key) !== null) {
  951. document.getElementById('tacCL' + key).innerHTML = html;
  952. }
  953. },
  954. "crossIndexOf": function (arr, match) {
  955. "use strict";
  956. var i;
  957. for (i = 0; i < arr.length; i += 1) {
  958. if (arr[i] === match) {
  959. return true;
  960. }
  961. }
  962. return false;
  963. },
  964. "number": function () {
  965. "use strict";
  966. var cookies = document.cookie.split(';'),
  967. nb = (document.cookie !== '') ? cookies.length : 0,
  968. html = '',
  969. i,
  970. name,
  971. namea,
  972. nameb,
  973. c,
  974. d,
  975. s = (nb > 1) ? 's' : '',
  976. savedname,
  977. regex = /^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i,
  978. regexedDomain = (tarteaucitron.cdn.match(regex) !== null) ? tarteaucitron.cdn.match(regex)[1] : tarteaucitron.cdn,
  979. host = (tarteaucitron.domain !== undefined) ? tarteaucitron.domain : regexedDomain;
  980. cookies = cookies.sort(function (a, b) {
  981. namea = a.split('=', 1).toString().replace(/ /g, '');
  982. nameb = b.split('=', 1).toString().replace(/ /g, '');
  983. c = (tarteaucitron.cookie.owner[namea] !== undefined) ? tarteaucitron.cookie.owner[namea] : '0';
  984. d = (tarteaucitron.cookie.owner[nameb] !== undefined) ? tarteaucitron.cookie.owner[nameb] : '0';
  985. if (c + a > d + b) { return 1; }
  986. if (c + a < d + b) { return -1; }
  987. return 0;
  988. });
  989. if (document.cookie !== '') {
  990. for (i = 0; i < nb; i += 1) {
  991. name = cookies[i].split('=', 1).toString().replace(/ /g, '');
  992. if (tarteaucitron.cookie.owner[name] !== undefined && tarteaucitron.cookie.owner[name].join(' // ') !== savedname) {
  993. savedname = tarteaucitron.cookie.owner[name].join(' // ');
  994. html += '<div class="tarteaucitronHidden">';
  995. html += ' <h3 class="tarteaucitronTitle">';
  996. html += ' ' + tarteaucitron.cookie.owner[name].join(' // ');
  997. html += ' </h3>';
  998. html += '</div><ul class="cookie-list">';
  999. } else if (tarteaucitron.cookie.owner[name] === undefined && host !== savedname) {
  1000. savedname = host;
  1001. html += '<div class="tarteaucitronHidden">';
  1002. html += ' <h3 class="tarteaucitronTitle">';
  1003. html += ' ' + host;
  1004. html += ' </h3>';
  1005. html += '</div><ul class="cookie-list">';
  1006. }
  1007. html += '<li class="tarteaucitronCookiesListMain">';
  1008. html += ' <div class="tarteaucitronCookiesListLeft"><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>';
  1009. html += ' </div>';
  1010. html += ' <div class="tarteaucitronCookiesListRight">' + cookies[i].split('=').slice(1).join('=') + '</div>';
  1011. html += '</li>';
  1012. }
  1013. html += '</ul>';
  1014. } else {
  1015. html += '<div class="tarteaucitronCookiesListMain">';
  1016. html += ' <div class="tarteaucitronCookiesListLeft"><strong>-</strong></div>';
  1017. html += ' <div class="tarteaucitronCookiesListRight"></div>';
  1018. html += '</div>';
  1019. }
  1020. html += '<div class="tarteaucitronHidden" style="height:20px;display:block"></div>';
  1021. if (document.getElementById('tarteaucitronCookiesList') !== null) {
  1022. document.getElementById('tarteaucitronCookiesList').innerHTML = html;
  1023. }
  1024. if (document.getElementById('tarteaucitronCookiesNumber') !== null) {
  1025. document.getElementById('tarteaucitronCookiesNumber').innerHTML = nb;
  1026. }
  1027. if (document.getElementById('tarteaucitronCookiesNumberBis') !== null) {
  1028. document.getElementById('tarteaucitronCookiesNumberBis').innerHTML = nb + ' cookie' + s;
  1029. }
  1030. for (i = 0; i < tarteaucitron.job.length; i += 1) {
  1031. tarteaucitron.cookie.checkCount(tarteaucitron.job[i]);
  1032. }
  1033. }
  1034. },
  1035. "getLanguage": function () {
  1036. "use strict";
  1037. if (!navigator) { return 'en'; }
  1038. var availableLanguages = 'cs,en,fr,es,it,de,nl,pt,pl,ru',
  1039. defaultLanguage = 'en',
  1040. lang = navigator.language || navigator.browserLanguage ||
  1041. navigator.systemLanguage || navigator.userLang || null,
  1042. userLanguage = lang.substr(0, 2);
  1043. if (tarteaucitronForceLanguage !== '') {
  1044. if (availableLanguages.indexOf(tarteaucitronForceLanguage) !== -1) {
  1045. return tarteaucitronForceLanguage;
  1046. }
  1047. }
  1048. if (availableLanguages.indexOf(userLanguage) === -1) {
  1049. return defaultLanguage;
  1050. }
  1051. return userLanguage;
  1052. },
  1053. "getLocale": function () {
  1054. "use strict";
  1055. if (!navigator) { return 'en_US'; }
  1056. var lang = navigator.language || navigator.browserLanguage ||
  1057. navigator.systemLanguage || navigator.userLang || null,
  1058. userLanguage = lang.substr(0, 2);
  1059. if (userLanguage === 'fr') {
  1060. return 'fr_FR';
  1061. } else if (userLanguage === 'en') {
  1062. return 'en_US';
  1063. } else if (userLanguage === 'de') {
  1064. return 'de_DE';
  1065. } else if (userLanguage === 'es') {
  1066. return 'es_ES';
  1067. } else if (userLanguage === 'it') {
  1068. return 'it_IT';
  1069. } else if (userLanguage === 'pt') {
  1070. return 'pt_PT';
  1071. } else if (userLanguage === 'nl') {
  1072. return 'nl_NL';
  1073. } else {
  1074. return 'en_US';
  1075. }
  1076. },
  1077. "addScript": function (url, id, callback, execute, attrName, attrVal) {
  1078. "use strict";
  1079. var script,
  1080. done = false;
  1081. if (execute === false) {
  1082. if (typeof callback === 'function') {
  1083. callback();
  1084. }
  1085. } else {
  1086. script = document.createElement('script');
  1087. script.type = 'text/javascript';
  1088. script.id = (id !== undefined) ? id : '';
  1089. script.async = true;
  1090. script.src = url;
  1091. if (attrName !== undefined && attrVal !== undefined) {
  1092. script.setAttribute(attrName, attrVal);
  1093. }
  1094. if (typeof callback === 'function') {
  1095. script.onreadystatechange = script.onload = function () {
  1096. var state = script.readyState;
  1097. if (!done && (!state || /loaded|complete/.test(state))) {
  1098. done = true;
  1099. callback();
  1100. }
  1101. };
  1102. }
  1103. document.getElementsByTagName('head')[0].appendChild(script);
  1104. }
  1105. },
  1106. "makeAsync": {
  1107. "antiGhost": 0,
  1108. "buffer": '',
  1109. "init": function (url, id) {
  1110. "use strict";
  1111. var savedWrite = document.write,
  1112. savedWriteln = document.writeln;
  1113. document.write = function (content) {
  1114. tarteaucitron.makeAsync.buffer += content;
  1115. };
  1116. document.writeln = function (content) {
  1117. tarteaucitron.makeAsync.buffer += content.concat("\n");
  1118. };
  1119. setTimeout(function () {
  1120. document.write = savedWrite;
  1121. document.writeln = savedWriteln;
  1122. }, 20000);
  1123. tarteaucitron.makeAsync.getAndParse(url, id);
  1124. },
  1125. "getAndParse": function (url, id) {
  1126. "use strict";
  1127. if (tarteaucitron.makeAsync.antiGhost > 9) {
  1128. tarteaucitron.makeAsync.antiGhost = 0;
  1129. return;
  1130. }
  1131. tarteaucitron.makeAsync.antiGhost += 1;
  1132. tarteaucitron.addScript(url, '', function () {
  1133. if (document.getElementById(id) !== null) {
  1134. document.getElementById(id).innerHTML += "<span style='display:none'>&nbsp;</span>" + tarteaucitron.makeAsync.buffer;
  1135. tarteaucitron.makeAsync.buffer = '';
  1136. tarteaucitron.makeAsync.execJS(id);
  1137. }
  1138. });
  1139. },
  1140. "execJS": function (id) {
  1141. /* not strict because third party scripts may have errors */
  1142. var i,
  1143. scripts,
  1144. childId,
  1145. type;
  1146. if (document.getElementById(id) === null) {
  1147. return;
  1148. }
  1149. scripts = document.getElementById(id).getElementsByTagName('script');
  1150. for (i = 0; i < scripts.length; i += 1) {
  1151. type = (scripts[i].getAttribute('type') !== null) ? scripts[i].getAttribute('type') : '';
  1152. if (type === '') {
  1153. type = (scripts[i].getAttribute('language') !== null) ? scripts[i].getAttribute('language') : '';
  1154. }
  1155. if (scripts[i].getAttribute('src') !== null && scripts[i].getAttribute('src') !== '') {
  1156. childId = id + Math.floor(Math.random() * 99999999999);
  1157. document.getElementById(id).innerHTML += '<div id="' + childId + '"></div>';
  1158. tarteaucitron.makeAsync.getAndParse(scripts[i].getAttribute('src'), childId);
  1159. } else if (type.indexOf('javascript') !== -1 || type === '') {
  1160. eval(scripts[i].innerHTML);
  1161. }
  1162. }
  1163. }
  1164. },
  1165. "fallback": function (matchClass, content, noInner) {
  1166. "use strict";
  1167. var elems = document.getElementsByTagName('*'),
  1168. i,
  1169. index = 0;
  1170. for (i in elems) {
  1171. if (elems[i] !== undefined) {
  1172. for (index = 0; index < matchClass.length; index += 1) {
  1173. if ((' ' + elems[i].className + ' ')
  1174. .indexOf(' ' + matchClass[index] + ' ') > -1) {
  1175. if (typeof content === 'function') {
  1176. if (noInner === true) {
  1177. content(elems[i]);
  1178. } else {
  1179. elems[i].innerHTML = content(elems[i]);
  1180. }
  1181. } else {
  1182. elems[i].innerHTML = content;
  1183. }
  1184. }
  1185. }
  1186. }
  1187. }
  1188. },
  1189. "engage": function (id) {
  1190. "use strict";
  1191. var html = '',
  1192. r = Math.floor(Math.random() * 100000);
  1193. html += '<div class="tac_activate">';
  1194. html += ' <div class="tac_float">';
  1195. html += ' <strong>' + tarteaucitron.services[id].name + '</strong> ' + tarteaucitron.lang.fallback;
  1196. html += ' <button class="tarteaucitronAllow" id="Eng' + r + 'ed' + id + '" onclick="tarteaucitron.userInterface.respond(this, true);">';
  1197. html += ' &#10003; ' + tarteaucitron.lang.allow;
  1198. html += ' </button>';
  1199. html += ' </div>';
  1200. html += '</div>';
  1201. return html;
  1202. },
  1203. "extend": function (a, b) {
  1204. "use strict";
  1205. var prop;
  1206. for (prop in b) {
  1207. if (b.hasOwnProperty(prop)) {
  1208. a[prop] = b[prop];
  1209. }
  1210. }
  1211. },
  1212. "proTemp": '',
  1213. "proTimer": function () {
  1214. "use strict";
  1215. setTimeout(tarteaucitron.proPing, 1000);
  1216. },
  1217. "pro": function (list) {
  1218. "use strict";
  1219. tarteaucitron.proTemp += list;
  1220. clearTimeout(tarteaucitron.proTimer);
  1221. tarteaucitron.proTimer = setTimeout(tarteaucitron.proPing, 2500);
  1222. },
  1223. "proPing": function () {
  1224. "use strict";
  1225. if (tarteaucitron.uuid !== '' && tarteaucitron.uuid !== undefined && tarteaucitron.proTemp !== '') {
  1226. var div = document.getElementById('tarteaucitronPremium'),
  1227. timestamp = new Date().getTime(),
  1228. url = '//opt-out.ferank.eu/premium.php?';
  1229. if (div === null) {
  1230. return;
  1231. }
  1232. url += 'domain=' + tarteaucitron.domain + '&';
  1233. url += 'uuid=' + tarteaucitron.uuid + '&';
  1234. url += 'c=' + encodeURIComponent(tarteaucitron.proTemp) + '&';
  1235. url += '_' + timestamp;
  1236. div.innerHTML = '<img src="' + url + '" style="display:none" />';
  1237. tarteaucitron.proTemp = '';
  1238. }
  1239. tarteaucitron.cookie.number();
  1240. },
  1241. "AddOrUpdate" : function(source, custom){
  1242. /**
  1243. Utility function to Add or update the fields of obj1 with the ones in obj2
  1244. */
  1245. for(key in custom){
  1246. if(custom[key] instanceof Object){
  1247. source[key] = tarteaucitron.AddOrUpdate(source[key], custom[key]);
  1248. }else{
  1249. source[key] = custom[key];
  1250. }
  1251. }
  1252. return source;
  1253. }
  1254. };