tarteaucitron.js 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447
  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', 'opacity', '0.4');
  631. tarteaucitron.userInterface.css(c + 'AllAllowed', 'opacity', '1');
  632. } else if (nbAllowed === 0 && nbPending === 0) {
  633. tarteaucitron.userInterface.css(c + 'AllAllowed', 'opacity', '0.4');
  634. tarteaucitron.userInterface.css(c + 'AllDenied', 'opacity', '1');
  635. tarteaucitron.userInterface.css(c + 'AllDenied', 'backgroundColor', redDark);
  636. } else {
  637. tarteaucitron.userInterface.css(c + 'AllAllowed', 'opacity', '1');
  638. tarteaucitron.userInterface.css(c + 'AllDenied', 'opacity', '1');
  639. }
  640. // close the alert if all service have been reviewed
  641. if (nbPending === 0) {
  642. tarteaucitron.userInterface.closeAlert();
  643. }
  644. if (tarteaucitron.services[key].cookies.length > 0 && status === false) {
  645. tarteaucitron.cookie.purge(tarteaucitron.services[key].cookies);
  646. }
  647. if (status === true) {
  648. if (document.getElementById('tacCL' + key) !== null) {
  649. document.getElementById('tacCL' + key).innerHTML = '...';
  650. }
  651. setTimeout(function () {
  652. tarteaucitron.cookie.checkCount(key);
  653. }, 2500);
  654. } else {
  655. tarteaucitron.cookie.checkCount(key);
  656. }
  657. },
  658. "openPanel": function () {
  659. "use strict";
  660. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'block');
  661. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
  662. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
  663. document.getElementById('tarteaucitronClosePanel').focus();
  664. document.getElementById('contentWrapper').setAttribute("aria-hidden", "true");
  665. document.getElementsByTagName('body')[0].classList.add('modal-open');
  666. tarteaucitron.userInterface.focusTrap();
  667. tarteaucitron.userInterface.jsSizing('main');
  668. },
  669. "closePanel": function () {
  670. "use strict";
  671. if (document.location.hash === tarteaucitron.hashtag) {
  672. document.location.hash = '';
  673. }
  674. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  675. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
  676. tarteaucitron.fallback(['tarteaucitronInfoBox'], function (elem) {
  677. elem.style.display = 'none';
  678. }, true);
  679. if (tarteaucitron.reloadThePage === true) {
  680. window.location.reload();
  681. } else {
  682. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
  683. }
  684. if (document.getElementById('tarteaucitronCloseAlert') !== null) {
  685. document.getElementById('tarteaucitronCloseAlert').focus();
  686. }
  687. document.getElementById('contentWrapper').setAttribute("aria-hidden", "false");
  688. document.getElementsByTagName('body')[0].classList.remove('modal-open');
  689. },
  690. "focusTrap": function() {
  691. "use strict";
  692. var focusableEls,
  693. firstFocusableEl,
  694. lastFocusableEl,
  695. filtered;
  696. focusableEls = document.getElementById('tarteaucitron').querySelectorAll('a[href], button');
  697. filtered = [];
  698. // get only visible items
  699. for (var i = 0, max = focusableEls.length; i < max; i++) {
  700. if (focusableEls[i].offsetHeight > 0) {
  701. filtered.push(focusableEls[i]);
  702. }
  703. }
  704. firstFocusableEl = filtered[0];
  705. lastFocusableEl = filtered[filtered.length - 1];
  706. //loop focus inside tarteaucitron
  707. document.getElementById('tarteaucitron').addEventListener("keydown", function (evt) {
  708. if ( evt.key === 'Tab' || evt.keyCode === 9 ) {
  709. if ( evt.shiftKey ) /* shift + tab */ {
  710. if (document.activeElement === firstFocusableEl) {
  711. lastFocusableEl.focus();
  712. evt.preventDefault();
  713. }
  714. } else /* tab */ {
  715. if (document.activeElement === lastFocusableEl) {
  716. firstFocusableEl.focus();
  717. evt.preventDefault();
  718. }
  719. }
  720. }
  721. })
  722. },
  723. "openAlert": function () {
  724. "use strict";
  725. var c = 'tarteaucitron';
  726. tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'block');
  727. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'none');
  728. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'block');
  729. },
  730. "closeAlert": function () {
  731. "use strict";
  732. var c = 'tarteaucitron';
  733. tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'none');
  734. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'block');
  735. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'none');
  736. tarteaucitron.userInterface.jsSizing('box');
  737. },
  738. "toggleCookiesList": function () {
  739. "use strict";
  740. var div = document.getElementById('tarteaucitronCookiesListContainer');
  741. if (div === null) {
  742. return;
  743. }
  744. if (div.style.display !== 'block') {
  745. tarteaucitron.cookie.number();
  746. div.style.display = 'block';
  747. tarteaucitron.userInterface.jsSizing('cookie');
  748. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  749. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
  750. tarteaucitron.fallback(['tarteaucitronInfoBox'], function (elem) {
  751. elem.style.display = 'none';
  752. }, true);
  753. } else {
  754. div.style.display = 'none';
  755. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  756. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
  757. }
  758. },
  759. "toggle": function (id, closeClass) {
  760. "use strict";
  761. var div = document.getElementById(id);
  762. if (div === null) {
  763. return;
  764. }
  765. if (closeClass !== undefined) {
  766. tarteaucitron.fallback([closeClass], function (elem) {
  767. if (elem.id !== id) {
  768. elem.style.display = 'none';
  769. }
  770. }, true);
  771. }
  772. if (div.style.display !== 'block') {
  773. div.style.display = 'block';
  774. } else {
  775. div.style.display = 'none';
  776. }
  777. },
  778. "order": function (id) {
  779. "use strict";
  780. var main = document.getElementById('tarteaucitronServices_' + id),
  781. allDivs,
  782. store = [],
  783. i;
  784. if (main === null) {
  785. return;
  786. }
  787. allDivs = main.childNodes;
  788. if (typeof Array.prototype.map === 'function') {
  789. Array.prototype.map.call(main.children, Object).sort(function (a, b) {
  790. //var mainChildren = Array.from(main.children);
  791. //mainChildren.sort(function (a, b) {
  792. if (tarteaucitron.services[a.id.replace(/Line/g, '')].name > tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return 1; }
  793. if (tarteaucitron.services[a.id.replace(/Line/g, '')].name < tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return -1; }
  794. return 0;
  795. }).forEach(function (element) {
  796. main.appendChild(element);
  797. });
  798. }
  799. },
  800. "jsSizing": function (type) {
  801. "use strict";
  802. var scrollbarMarginRight = 10,
  803. scrollbarWidthParent,
  804. scrollbarWidthChild,
  805. servicesHeight,
  806. e = window,
  807. a = 'inner',
  808. windowInnerHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
  809. mainTop,
  810. mainHeight,
  811. closeButtonHeight,
  812. headerHeight,
  813. cookiesListHeight,
  814. cookiesCloseHeight,
  815. cookiesTitleHeight,
  816. paddingBox,
  817. alertSmallHeight,
  818. cookiesNumberHeight;
  819. if (type === 'box') {
  820. if (document.getElementById('tarteaucitronAlertSmall') !== null && document.getElementById('tarteaucitronCookiesNumber') !== null) {
  821. // reset
  822. tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', '0px 10px');
  823. // calculate
  824. alertSmallHeight = document.getElementById('tarteaucitronAlertSmall').offsetHeight;
  825. cookiesNumberHeight = document.getElementById('tarteaucitronCookiesNumber').offsetHeight;
  826. paddingBox = (alertSmallHeight - cookiesNumberHeight) / 2;
  827. // apply
  828. tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', paddingBox + 'px 10px');
  829. }
  830. } else if (type === 'main') {
  831. // get the real window width for media query
  832. if (window.innerWidth === undefined) {
  833. a = 'client';
  834. e = document.documentElement || document.body;
  835. }
  836. // height of the services list container
  837. if (document.getElementById('tarteaucitron') !== null && document.getElementById('tarteaucitronClosePanel') !== null && document.getElementById('tarteaucitronMainLineOffset') !== null) {
  838. // reset
  839. tarteaucitron.userInterface.css('tarteaucitronServices', 'height', 'auto');
  840. // calculate
  841. mainHeight = document.getElementById('tarteaucitron').offsetHeight;
  842. closeButtonHeight = document.getElementById('tarteaucitronClosePanel').offsetHeight;
  843. // apply
  844. servicesHeight = (mainHeight - closeButtonHeight + 2);
  845. tarteaucitron.userInterface.css('tarteaucitronServices', 'height', servicesHeight + 'px');
  846. tarteaucitron.userInterface.css('tarteaucitronServices', 'overflow-x', 'auto');
  847. }
  848. // align the main allow/deny button depending on scrollbar width
  849. if (document.getElementById('tarteaucitronServices') !== null && document.getElementById('tarteaucitronScrollbarChild') !== null) {
  850. // media query
  851. if (e[a + 'Width'] <= 479) {
  852. tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginLeft', '11px');
  853. } else if (e[a + 'Width'] <= 767) {
  854. scrollbarMarginRight = 12;
  855. }
  856. scrollbarWidthParent = document.getElementById('tarteaucitronServices').offsetWidth;
  857. scrollbarWidthChild = document.getElementById('tarteaucitronScrollbarChild').offsetWidth;
  858. tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginRight', ((scrollbarWidthParent - scrollbarWidthChild) + scrollbarMarginRight) + 'px');
  859. }
  860. // center the main panel
  861. if (document.getElementById('tarteaucitron') !== null) {
  862. // media query
  863. if (e[a + 'Width'] <= 767) {
  864. mainTop = 0;
  865. } else {
  866. mainTop = ((windowInnerHeight - document.getElementById('tarteaucitron').offsetHeight) / 2) - 21;
  867. }
  868. // correct
  869. if (mainTop < 0) {
  870. mainTop = 0;
  871. }
  872. if (document.getElementById('tarteaucitronMainLineOffset') !== null) {
  873. if (document.getElementById('tarteaucitron').offsetHeight < (windowInnerHeight / 2)) {
  874. mainTop -= document.getElementById('tarteaucitronMainLineOffset').offsetHeight;
  875. }
  876. }
  877. // apply
  878. tarteaucitron.userInterface.css('tarteaucitron', 'top', mainTop + 'px');
  879. }
  880. } else if (type === 'cookie') {
  881. // put cookies list at bottom
  882. if (document.getElementById('tarteaucitronAlertSmall') !== null) {
  883. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'bottom', (document.getElementById('tarteaucitronAlertSmall').offsetHeight) + 'px');
  884. }
  885. // height of cookies list
  886. if (document.getElementById('tarteaucitronCookiesListContainer') !== null) {
  887. // reset
  888. tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', 'auto');
  889. // calculate
  890. cookiesListHeight = document.getElementById('tarteaucitronCookiesListContainer').offsetHeight;
  891. cookiesCloseHeight = document.getElementById('tarteaucitronClosePanelCookie').offsetHeight;
  892. cookiesTitleHeight = document.getElementById('tarteaucitronCookiesTitle').offsetHeight;
  893. // apply
  894. tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', (cookiesListHeight - cookiesCloseHeight - cookiesTitleHeight - 2) + 'px');
  895. }
  896. }
  897. }
  898. },
  899. "cookie": {
  900. "owner": {},
  901. "create": function (key, status) {
  902. "use strict";
  903. if (tarteaucitronForceExpire !== '') {
  904. // The number of day cann't be higher than 1 year
  905. timeExipre = (tarteaucitronForceExpire > 365) ? 31536000000 : tarteaucitronForceExpire * 86400000; // Multiplication to tranform the number of days to milliseconds
  906. }
  907. var d = new Date(),
  908. time = d.getTime(),
  909. expireTime = time + timeExipre, // 365 days
  910. regex = new RegExp("!" + key + "=(wait|true|false)", "g"),
  911. cookie = tarteaucitron.cookie.read().replace(regex, ""),
  912. value = tarteaucitron.parameters.cookieName + '=' + cookie + '!' + key + '=' + status,
  913. domain = (tarteaucitron.parameters.cookieDomain !== undefined && tarteaucitron.parameters.cookieDomain !== '') ? 'domain=' + tarteaucitron.parameters.cookieDomain + ';' : '';
  914. if (tarteaucitron.cookie.read().indexOf(key + '=' + status) === -1) {
  915. tarteaucitron.pro('!' + key + '=' + status);
  916. }
  917. d.setTime(expireTime);
  918. document.cookie = value + '; expires=' + d.toGMTString() + '; path=/;' + domain;
  919. },
  920. "read": function () {
  921. "use strict";
  922. var nameEQ = tarteaucitron.parameters.cookieName + "=",
  923. ca = document.cookie.split(';'),
  924. i,
  925. c;
  926. for (i = 0; i < ca.length; i += 1) {
  927. c = ca[i];
  928. while (c.charAt(0) === ' ') {
  929. c = c.substring(1, c.length);
  930. }
  931. if (c.indexOf(nameEQ) === 0) {
  932. return c.substring(nameEQ.length, c.length);
  933. }
  934. }
  935. return '';
  936. },
  937. "purge": function (arr) {
  938. "use strict";
  939. var i;
  940. for (i = 0; i < arr.length; i += 1) {
  941. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/;';
  942. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname + ';';
  943. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname.split('.').slice(-2).join('.') + ';';
  944. }
  945. },
  946. "checkCount": function (key) {
  947. "use strict";
  948. var arr = tarteaucitron.services[key].cookies,
  949. nb = arr.length,
  950. nbCurrent = 0,
  951. html = '',
  952. i,
  953. status = document.cookie.indexOf(key + '=true');
  954. if (status >= 0 && nb === 0) {
  955. html += tarteaucitron.lang.useNoCookie;
  956. } else if (status >= 0) {
  957. for (i = 0; i < nb; i += 1) {
  958. if (document.cookie.indexOf(arr[i] + '=') !== -1) {
  959. nbCurrent += 1;
  960. if (tarteaucitron.cookie.owner[arr[i]] === undefined) {
  961. tarteaucitron.cookie.owner[arr[i]] = [];
  962. }
  963. if (tarteaucitron.cookie.crossIndexOf(tarteaucitron.cookie.owner[arr[i]], tarteaucitron.services[key].name) === false) {
  964. tarteaucitron.cookie.owner[arr[i]].push(tarteaucitron.services[key].name);
  965. }
  966. }
  967. }
  968. if (nbCurrent > 0) {
  969. html += tarteaucitron.lang.useCookieCurrent + ' ' + nbCurrent + ' cookie';
  970. if (nbCurrent > 1) {
  971. html += 's';
  972. }
  973. html += '.';
  974. } else {
  975. html += tarteaucitron.lang.useNoCookie;
  976. }
  977. } else if (nb === 0) {
  978. html = tarteaucitron.lang.noCookie;
  979. } else {
  980. html += tarteaucitron.lang.useCookie + ' ' + nb + ' cookie';
  981. if (nb > 1) {
  982. html += 's';
  983. }
  984. html += '.';
  985. }
  986. if (document.getElementById('tacCL' + key) !== null) {
  987. document.getElementById('tacCL' + key).innerHTML = html;
  988. }
  989. },
  990. "crossIndexOf": function (arr, match) {
  991. "use strict";
  992. var i;
  993. for (i = 0; i < arr.length; i += 1) {
  994. if (arr[i] === match) {
  995. return true;
  996. }
  997. }
  998. return false;
  999. },
  1000. "number": function () {
  1001. "use strict";
  1002. var cookies = document.cookie.split(';'),
  1003. nb = (document.cookie !== '') ? cookies.length : 0,
  1004. html = '',
  1005. i,
  1006. name,
  1007. namea,
  1008. nameb,
  1009. c,
  1010. d,
  1011. s = (nb > 1) ? 's' : '',
  1012. savedname,
  1013. regex = /^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i,
  1014. regexedDomain = (tarteaucitron.cdn.match(regex) !== null) ? tarteaucitron.cdn.match(regex)[1] : tarteaucitron.cdn,
  1015. host = (tarteaucitron.domain !== undefined) ? tarteaucitron.domain : regexedDomain;
  1016. cookies = cookies.sort(function (a, b) {
  1017. namea = a.split('=', 1).toString().replace(/ /g, '');
  1018. nameb = b.split('=', 1).toString().replace(/ /g, '');
  1019. c = (tarteaucitron.cookie.owner[namea] !== undefined) ? tarteaucitron.cookie.owner[namea] : '0';
  1020. d = (tarteaucitron.cookie.owner[nameb] !== undefined) ? tarteaucitron.cookie.owner[nameb] : '0';
  1021. if (c + a > d + b) { return 1; }
  1022. if (c + a < d + b) { return -1; }
  1023. return 0;
  1024. });
  1025. if (document.cookie !== '') {
  1026. for (i = 0; i < nb; i += 1) {
  1027. name = cookies[i].split('=', 1).toString().replace(/ /g, '');
  1028. if (tarteaucitron.cookie.owner[name] !== undefined && tarteaucitron.cookie.owner[name].join(' // ') !== savedname) {
  1029. savedname = tarteaucitron.cookie.owner[name].join(' // ');
  1030. html += '<div class="tarteaucitronHidden">';
  1031. html += ' <h3 class="tarteaucitronTitle">';
  1032. html += ' ' + tarteaucitron.cookie.owner[name].join(' // ');
  1033. html += ' </h3>';
  1034. html += '</div><ul class="cookie-list">';
  1035. } else if (tarteaucitron.cookie.owner[name] === undefined && host !== savedname) {
  1036. savedname = host;
  1037. html += '<div class="tarteaucitronHidden">';
  1038. html += ' <h3 class="tarteaucitronTitle">';
  1039. html += ' ' + host;
  1040. html += ' </h3>';
  1041. html += '</div><ul class="cookie-list">';
  1042. }
  1043. html += '<li class="tarteaucitronCookiesListMain">';
  1044. 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>';
  1045. html += ' </div>';
  1046. html += ' <div class="tarteaucitronCookiesListRight">' + cookies[i].split('=').slice(1).join('=') + '</div>';
  1047. html += '</li>';
  1048. }
  1049. html += '</ul>';
  1050. } else {
  1051. html += '<div class="tarteaucitronCookiesListMain">';
  1052. html += ' <div class="tarteaucitronCookiesListLeft"><strong>-</strong></div>';
  1053. html += ' <div class="tarteaucitronCookiesListRight"></div>';
  1054. html += '</div>';
  1055. }
  1056. html += '<div class="tarteaucitronHidden" style="height:20px;display:block"></div>';
  1057. if (document.getElementById('tarteaucitronCookiesList') !== null) {
  1058. document.getElementById('tarteaucitronCookiesList').innerHTML = html;
  1059. }
  1060. if (document.getElementById('tarteaucitronCookiesNumber') !== null) {
  1061. document.getElementById('tarteaucitronCookiesNumber').innerHTML = nb;
  1062. }
  1063. if (document.getElementById('tarteaucitronCookiesNumberBis') !== null) {
  1064. document.getElementById('tarteaucitronCookiesNumberBis').innerHTML = nb + ' cookie' + s;
  1065. }
  1066. for (i = 0; i < tarteaucitron.job.length; i += 1) {
  1067. tarteaucitron.cookie.checkCount(tarteaucitron.job[i]);
  1068. }
  1069. }
  1070. },
  1071. "getLanguage": function () {
  1072. "use strict";
  1073. if (!navigator) { return 'en'; }
  1074. var availableLanguages = 'cs,en,fr,es,it,de,nl,pt,pl,ru',
  1075. defaultLanguage = 'en',
  1076. lang = navigator.language || navigator.browserLanguage ||
  1077. navigator.systemLanguage || navigator.userLang || null,
  1078. userLanguage = lang.substr(0, 2);
  1079. if (tarteaucitronForceLanguage !== '') {
  1080. if (availableLanguages.indexOf(tarteaucitronForceLanguage) !== -1) {
  1081. return tarteaucitronForceLanguage;
  1082. }
  1083. }
  1084. if (availableLanguages.indexOf(userLanguage) === -1) {
  1085. return defaultLanguage;
  1086. }
  1087. return userLanguage;
  1088. },
  1089. "getLocale": function () {
  1090. "use strict";
  1091. if (!navigator) { return 'en_US'; }
  1092. var lang = navigator.language || navigator.browserLanguage ||
  1093. navigator.systemLanguage || navigator.userLang || null,
  1094. userLanguage = lang.substr(0, 2);
  1095. if (userLanguage === 'fr') {
  1096. return 'fr_FR';
  1097. } else if (userLanguage === 'en') {
  1098. return 'en_US';
  1099. } else if (userLanguage === 'de') {
  1100. return 'de_DE';
  1101. } else if (userLanguage === 'es') {
  1102. return 'es_ES';
  1103. } else if (userLanguage === 'it') {
  1104. return 'it_IT';
  1105. } else if (userLanguage === 'pt') {
  1106. return 'pt_PT';
  1107. } else if (userLanguage === 'nl') {
  1108. return 'nl_NL';
  1109. } else {
  1110. return 'en_US';
  1111. }
  1112. },
  1113. "addScript": function (url, id, callback, execute, attrName, attrVal) {
  1114. "use strict";
  1115. var script,
  1116. done = false;
  1117. if (execute === false) {
  1118. if (typeof callback === 'function') {
  1119. callback();
  1120. }
  1121. } else {
  1122. script = document.createElement('script');
  1123. script.type = 'text/javascript';
  1124. script.id = (id !== undefined) ? id : '';
  1125. script.async = true;
  1126. script.src = url;
  1127. if (attrName !== undefined && attrVal !== undefined) {
  1128. script.setAttribute(attrName, attrVal);
  1129. }
  1130. if (typeof callback === 'function') {
  1131. script.onreadystatechange = script.onload = function () {
  1132. var state = script.readyState;
  1133. if (!done && (!state || /loaded|complete/.test(state))) {
  1134. done = true;
  1135. callback();
  1136. }
  1137. };
  1138. }
  1139. document.getElementsByTagName('head')[0].appendChild(script);
  1140. }
  1141. },
  1142. "makeAsync": {
  1143. "antiGhost": 0,
  1144. "buffer": '',
  1145. "init": function (url, id) {
  1146. "use strict";
  1147. var savedWrite = document.write,
  1148. savedWriteln = document.writeln;
  1149. document.write = function (content) {
  1150. tarteaucitron.makeAsync.buffer += content;
  1151. };
  1152. document.writeln = function (content) {
  1153. tarteaucitron.makeAsync.buffer += content.concat("\n");
  1154. };
  1155. setTimeout(function () {
  1156. document.write = savedWrite;
  1157. document.writeln = savedWriteln;
  1158. }, 20000);
  1159. tarteaucitron.makeAsync.getAndParse(url, id);
  1160. },
  1161. "getAndParse": function (url, id) {
  1162. "use strict";
  1163. if (tarteaucitron.makeAsync.antiGhost > 9) {
  1164. tarteaucitron.makeAsync.antiGhost = 0;
  1165. return;
  1166. }
  1167. tarteaucitron.makeAsync.antiGhost += 1;
  1168. tarteaucitron.addScript(url, '', function () {
  1169. if (document.getElementById(id) !== null) {
  1170. document.getElementById(id).innerHTML += "<span style='display:none'>&nbsp;</span>" + tarteaucitron.makeAsync.buffer;
  1171. tarteaucitron.makeAsync.buffer = '';
  1172. tarteaucitron.makeAsync.execJS(id);
  1173. }
  1174. });
  1175. },
  1176. "execJS": function (id) {
  1177. /* not strict because third party scripts may have errors */
  1178. var i,
  1179. scripts,
  1180. childId,
  1181. type;
  1182. if (document.getElementById(id) === null) {
  1183. return;
  1184. }
  1185. scripts = document.getElementById(id).getElementsByTagName('script');
  1186. for (i = 0; i < scripts.length; i += 1) {
  1187. type = (scripts[i].getAttribute('type') !== null) ? scripts[i].getAttribute('type') : '';
  1188. if (type === '') {
  1189. type = (scripts[i].getAttribute('language') !== null) ? scripts[i].getAttribute('language') : '';
  1190. }
  1191. if (scripts[i].getAttribute('src') !== null && scripts[i].getAttribute('src') !== '') {
  1192. childId = id + Math.floor(Math.random() * 99999999999);
  1193. document.getElementById(id).innerHTML += '<div id="' + childId + '"></div>';
  1194. tarteaucitron.makeAsync.getAndParse(scripts[i].getAttribute('src'), childId);
  1195. } else if (type.indexOf('javascript') !== -1 || type === '') {
  1196. eval(scripts[i].innerHTML);
  1197. }
  1198. }
  1199. }
  1200. },
  1201. "fallback": function (matchClass, content, noInner) {
  1202. "use strict";
  1203. var elems = document.getElementsByTagName('*'),
  1204. i,
  1205. index = 0;
  1206. for (i in elems) {
  1207. if (elems[i] !== undefined) {
  1208. for (index = 0; index < matchClass.length; index += 1) {
  1209. if ((' ' + elems[i].className + ' ')
  1210. .indexOf(' ' + matchClass[index] + ' ') > -1) {
  1211. if (typeof content === 'function') {
  1212. if (noInner === true) {
  1213. content(elems[i]);
  1214. } else {
  1215. elems[i].innerHTML = content(elems[i]);
  1216. }
  1217. } else {
  1218. elems[i].innerHTML = content;
  1219. }
  1220. }
  1221. }
  1222. }
  1223. }
  1224. },
  1225. "engage": function (id) {
  1226. "use strict";
  1227. var html = '',
  1228. r = Math.floor(Math.random() * 100000);
  1229. html += '<div class="tac_activate">';
  1230. html += ' <div class="tac_float">';
  1231. html += ' <strong>' + tarteaucitron.services[id].name + '</strong> ' + tarteaucitron.lang.fallback;
  1232. html += ' <button class="tarteaucitronAllow" id="Eng' + r + 'ed' + id + '" onclick="tarteaucitron.userInterface.respond(this, true);">';
  1233. html += ' &#10003; ' + tarteaucitron.lang.allow;
  1234. html += ' </button>';
  1235. html += ' </div>';
  1236. html += '</div>';
  1237. return html;
  1238. },
  1239. "extend": function (a, b) {
  1240. "use strict";
  1241. var prop;
  1242. for (prop in b) {
  1243. if (b.hasOwnProperty(prop)) {
  1244. a[prop] = b[prop];
  1245. }
  1246. }
  1247. },
  1248. "proTemp": '',
  1249. "proTimer": function () {
  1250. "use strict";
  1251. setTimeout(tarteaucitron.proPing, 1000);
  1252. },
  1253. "pro": function (list) {
  1254. "use strict";
  1255. tarteaucitron.proTemp += list;
  1256. clearTimeout(tarteaucitron.proTimer);
  1257. tarteaucitron.proTimer = setTimeout(tarteaucitron.proPing, 2500);
  1258. },
  1259. "proPing": function () {
  1260. "use strict";
  1261. if (tarteaucitron.uuid !== '' && tarteaucitron.uuid !== undefined && tarteaucitron.proTemp !== '') {
  1262. var div = document.getElementById('tarteaucitronPremium'),
  1263. timestamp = new Date().getTime(),
  1264. url = '//opt-out.ferank.eu/premium.php?';
  1265. if (div === null) {
  1266. return;
  1267. }
  1268. url += 'domain=' + tarteaucitron.domain + '&';
  1269. url += 'uuid=' + tarteaucitron.uuid + '&';
  1270. url += 'c=' + encodeURIComponent(tarteaucitron.proTemp) + '&';
  1271. url += '_' + timestamp;
  1272. div.innerHTML = '<img src="' + url + '" style="display:none" />';
  1273. tarteaucitron.proTemp = '';
  1274. }
  1275. tarteaucitron.cookie.number();
  1276. },
  1277. "AddOrUpdate" : function(source, custom){
  1278. /**
  1279. Utility function to Add or update the fields of obj1 with the ones in obj2
  1280. */
  1281. for(key in custom){
  1282. if(custom[key] instanceof Object){
  1283. source[key] = tarteaucitron.AddOrUpdate(source[key], custom[key]);
  1284. }else{
  1285. source[key] = custom[key];
  1286. }
  1287. }
  1288. return source;
  1289. }
  1290. };