tarteaucitron.js 67 KB

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