tarteaucitron.js 74 KB

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