tarteaucitron.js 61 KB

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