tarteaucitron.js 69 KB

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