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