tarteaucitron.js 67 KB

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