tarteaucitron.js 60 KB

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