tarteaucitron.js 68 KB

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