tarteaucitron.js 66 KB

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