tarteaucitron.js 68 KB

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