tarteaucitron.js 68 KB

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