tarteaucitron.js 67 KB

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