tarteaucitron.js 61 KB

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