tarteaucitron.js 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276
  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. "handleBrowserDNTRequest": false
  177. },
  178. params = tarteaucitron.parameters;
  179. // Step 0: get params
  180. if (params !== undefined) {
  181. tarteaucitron.extend(defaults, params);
  182. }
  183. // global
  184. tarteaucitron.orientation = defaults.orientation;
  185. tarteaucitron.hashtag = defaults.hashtag;
  186. tarteaucitron.highPrivacy = defaults.highPrivacy;
  187. tarteaucitron.handleBrowserDNTRequest = defaults.handleBrowserDNTRequest;
  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. isDNTRequested = (navigator.doNotTrack === "1" || navigator.doNotTrack === "yes" || navigator.msDoNotTrack === "1" || window.doNotTrack === "1") ? true : false;
  382. if (tarteaucitron.added[service.key] !== true) {
  383. tarteaucitron.added[service.key] = true;
  384. html += '<div id="' + service.key + 'Line" class="tarteaucitronLine">';
  385. html += ' <div class="tarteaucitronName">';
  386. html += ' <b>' + service.name + '</b><br/>';
  387. html += ' <span id="tacCL' + service.key + '" class="tarteaucitronListCookies"></span><br/>';
  388. html += ' <a href="https://opt-out.ferank.eu/service/' + service.key + '/" target="_blank" rel="noopener">';
  389. html += ' ' + tarteaucitron.lang.more;
  390. html += ' </a>';
  391. html += ' - ';
  392. html += ' <a href="' + service.uri + '" target="_blank" rel="noopener">';
  393. html += ' ' + tarteaucitron.lang.source;
  394. html += ' </a>';
  395. html += ' </div>';
  396. html += ' <div class="tarteaucitronAsk">';
  397. html += ' <div id="' + service.key + 'Allowed" class="tarteaucitronAllow" onclick="tarteaucitron.userInterface.respond(this, true);">';
  398. html += ' &#10003; ' + tarteaucitron.lang.allow;
  399. html += ' </div> ';
  400. html += ' <div id="' + service.key + 'Denied" class="tarteaucitronDeny" onclick="tarteaucitron.userInterface.respond(this, false);">';
  401. html += ' &#10007; ' + tarteaucitron.lang.deny;
  402. html += ' </div>';
  403. html += ' </div>';
  404. html += '</div>';
  405. tarteaucitron.userInterface.css('tarteaucitronServicesTitle_' + service.type, 'display', 'block');
  406. if (document.getElementById('tarteaucitronServices_' + service.type) !== null) {
  407. document.getElementById('tarteaucitronServices_' + service.type).innerHTML += html;
  408. }
  409. tarteaucitron.userInterface.order(service.type);
  410. }
  411. // allow by default for non EU
  412. if (isResponded === false && tarteaucitron.user.bypass === true) {
  413. isAllowed = true;
  414. tarteaucitron.cookie.create(service.key, true);
  415. }
  416. if ((!isResponded && (isAutostart || (isNavigating && isWaiting)) && !tarteaucitron.highPrivacy) || isAllowed) {
  417. if (!isAllowed) {
  418. tarteaucitron.cookie.create(service.key, true);
  419. }
  420. if (tarteaucitron.launch[service.key] !== true) {
  421. tarteaucitron.launch[service.key] = true;
  422. service.js();
  423. }
  424. tarteaucitron.state[service.key] = true;
  425. tarteaucitron.userInterface.color(service.key, true);
  426. } else if (isDenied) {
  427. if (typeof service.fallback === 'function') {
  428. service.fallback();
  429. }
  430. tarteaucitron.state[service.key] = false;
  431. tarteaucitron.userInterface.color(service.key, false);
  432. } else if (!isResponded && isDNTRequested && tarteaucitron.handleBrowserDNTRequest) {
  433. tarteaucitron.cookie.create(service.key, 'false');
  434. if (typeof service.fallback === 'function') {
  435. service.fallback();
  436. }
  437. tarteaucitron.state[service.key] = false;
  438. tarteaucitron.userInterface.color(service.key, false);
  439. } else if (!isResponded) {
  440. tarteaucitron.cookie.create(service.key, 'wait');
  441. if (typeof service.fallback === 'function') {
  442. service.fallback();
  443. }
  444. tarteaucitron.userInterface.color(service.key, 'wait');
  445. tarteaucitron.userInterface.openAlert();
  446. }
  447. tarteaucitron.cookie.checkCount(service.key);
  448. },
  449. "cleanArray": function cleanArray(arr) {
  450. "use strict";
  451. var i,
  452. len = arr.length,
  453. out = [],
  454. obj = {},
  455. s = tarteaucitron.services;
  456. for (i = 0; i < len; i += 1) {
  457. if (!obj[arr[i]]) {
  458. obj[arr[i]] = {};
  459. if (tarteaucitron.services[arr[i]] !== undefined) {
  460. out.push(arr[i]);
  461. }
  462. }
  463. }
  464. out = out.sort(function (a, b) {
  465. if (s[a].type + s[a].key > s[b].type + s[b].key) { return 1; }
  466. if (s[a].type + s[a].key < s[b].type + s[b].key) { return -1; }
  467. return 0;
  468. });
  469. return out;
  470. },
  471. "userInterface": {
  472. "css": function (id, property, value) {
  473. "use strict";
  474. if (document.getElementById(id) !== null) {
  475. document.getElementById(id).style[property] = value;
  476. }
  477. },
  478. "respondAll": function (status) {
  479. "use strict";
  480. var s = tarteaucitron.services,
  481. service,
  482. key,
  483. index = 0;
  484. for (index = 0; index < tarteaucitron.job.length; index += 1) {
  485. service = s[tarteaucitron.job[index]];
  486. key = service.key;
  487. if (tarteaucitron.state[key] !== status) {
  488. if (status === false && tarteaucitron.launch[key] === true) {
  489. tarteaucitron.reloadThePage = true;
  490. }
  491. if (tarteaucitron.launch[key] !== true && status === true) {
  492. tarteaucitron.launch[key] = true;
  493. tarteaucitron.services[key].js();
  494. }
  495. tarteaucitron.state[key] = status;
  496. tarteaucitron.cookie.create(key, status);
  497. tarteaucitron.userInterface.color(key, status);
  498. }
  499. }
  500. },
  501. "respond": function (el, status) {
  502. "use strict";
  503. var key = el.id.replace(new RegExp("(Eng[0-9]+|Allow|Deni)ed", "g"), '');
  504. // return if same state
  505. if (tarteaucitron.state[key] === status) {
  506. return;
  507. }
  508. if (status === false && tarteaucitron.launch[key] === true) {
  509. tarteaucitron.reloadThePage = true;
  510. }
  511. // if not already launched... launch the service
  512. if (status === true) {
  513. if (tarteaucitron.launch[key] !== true) {
  514. tarteaucitron.launch[key] = true;
  515. tarteaucitron.services[key].js();
  516. }
  517. }
  518. tarteaucitron.state[key] = status;
  519. tarteaucitron.cookie.create(key, status);
  520. tarteaucitron.userInterface.color(key, status);
  521. },
  522. "color": function (key, status) {
  523. "use strict";
  524. var gray = '#808080',
  525. greenDark = '#1B870B',
  526. greenLight = '#E6FFE2',
  527. redDark = '#9C1A1A',
  528. redLight = '#FFE2E2',
  529. yellowDark = '#FBDA26',
  530. c = 'tarteaucitron',
  531. nbDenied = 0,
  532. nbPending = 0,
  533. nbAllowed = 0,
  534. sum = tarteaucitron.job.length,
  535. index;
  536. if (status === true) {
  537. tarteaucitron.userInterface.css(key + 'Line', 'borderLeft', '5px solid ' + greenDark);
  538. tarteaucitron.userInterface.css(key + 'Allowed', 'backgroundColor', greenDark);
  539. tarteaucitron.userInterface.css(key + 'Denied', 'backgroundColor', gray);
  540. } else if (status === false) {
  541. tarteaucitron.userInterface.css(key + 'Line', 'borderLeft', '5px solid ' + redDark);
  542. tarteaucitron.userInterface.css(key + 'Allowed', 'backgroundColor', gray);
  543. tarteaucitron.userInterface.css(key + 'Denied', 'backgroundColor', redDark);
  544. }
  545. // check if all services are allowed
  546. for (index = 0; index < sum; index += 1) {
  547. if (tarteaucitron.state[tarteaucitron.job[index]] === false) {
  548. nbDenied += 1;
  549. } else if (tarteaucitron.state[tarteaucitron.job[index]] === undefined) {
  550. nbPending += 1;
  551. } else if (tarteaucitron.state[tarteaucitron.job[index]] === true) {
  552. nbAllowed += 1;
  553. }
  554. }
  555. tarteaucitron.userInterface.css(c + 'DotGreen', 'width', ((100 / sum) * nbAllowed) + '%');
  556. tarteaucitron.userInterface.css(c + 'DotYellow', 'width', ((100 / sum) * nbPending) + '%');
  557. tarteaucitron.userInterface.css(c + 'DotRed', 'width', ((100 / sum) * nbDenied) + '%');
  558. if (nbDenied === 0 && nbPending === 0) {
  559. tarteaucitron.userInterface.css(c + 'AllAllowed', 'backgroundColor', greenDark);
  560. tarteaucitron.userInterface.css(c + 'AllDenied', 'backgroundColor', gray);
  561. } else if (nbAllowed === 0 && nbPending === 0) {
  562. tarteaucitron.userInterface.css(c + 'AllAllowed', 'backgroundColor', gray);
  563. tarteaucitron.userInterface.css(c + 'AllDenied', 'backgroundColor', redDark);
  564. } else {
  565. tarteaucitron.userInterface.css(c + 'AllAllowed', 'backgroundColor', gray);
  566. tarteaucitron.userInterface.css(c + 'AllDenied', 'backgroundColor', gray);
  567. }
  568. // close the alert if all service have been reviewed
  569. if (nbPending === 0) {
  570. tarteaucitron.userInterface.closeAlert();
  571. }
  572. if (tarteaucitron.services[key].cookies.length > 0 && status === false) {
  573. tarteaucitron.cookie.purge(tarteaucitron.services[key].cookies);
  574. }
  575. if (status === true) {
  576. if (document.getElementById('tacCL' + key) !== null) {
  577. document.getElementById('tacCL' + key).innerHTML = '...';
  578. }
  579. setTimeout(function () {
  580. tarteaucitron.cookie.checkCount(key);
  581. }, 2500);
  582. } else {
  583. tarteaucitron.cookie.checkCount(key);
  584. }
  585. },
  586. "openPanel": function () {
  587. "use strict";
  588. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'block');
  589. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
  590. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
  591. tarteaucitron.userInterface.jsSizing('main');
  592. },
  593. "closePanel": function () {
  594. "use strict";
  595. if (document.location.hash === tarteaucitron.hashtag) {
  596. document.location.hash = '';
  597. }
  598. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  599. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
  600. tarteaucitron.fallback(['tarteaucitronInfoBox'], function (elem) {
  601. elem.style.display = 'none';
  602. }, true);
  603. if (tarteaucitron.reloadThePage === true) {
  604. window.location.reload();
  605. } else {
  606. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
  607. }
  608. },
  609. "openAlert": function () {
  610. "use strict";
  611. var c = 'tarteaucitron';
  612. tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'block');
  613. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'none');
  614. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'block');
  615. },
  616. "closeAlert": function () {
  617. "use strict";
  618. var c = 'tarteaucitron';
  619. tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'none');
  620. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'block');
  621. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'none');
  622. tarteaucitron.userInterface.jsSizing('box');
  623. },
  624. "toggleCookiesList": function () {
  625. "use strict";
  626. var div = document.getElementById('tarteaucitronCookiesListContainer');
  627. if (div === null) {
  628. return;
  629. }
  630. if (div.style.display !== 'block') {
  631. tarteaucitron.cookie.number();
  632. div.style.display = 'block';
  633. tarteaucitron.userInterface.jsSizing('cookie');
  634. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  635. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
  636. tarteaucitron.fallback(['tarteaucitronInfoBox'], function (elem) {
  637. elem.style.display = 'none';
  638. }, true);
  639. } else {
  640. div.style.display = 'none';
  641. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  642. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
  643. }
  644. },
  645. "toggle": function (id, closeClass) {
  646. "use strict";
  647. var div = document.getElementById(id);
  648. if (div === null) {
  649. return;
  650. }
  651. if (closeClass !== undefined) {
  652. tarteaucitron.fallback([closeClass], function (elem) {
  653. if (elem.id !== id) {
  654. elem.style.display = 'none';
  655. }
  656. }, true);
  657. }
  658. if (div.style.display !== 'block') {
  659. div.style.display = 'block';
  660. } else {
  661. div.style.display = 'none';
  662. }
  663. },
  664. "order": function (id) {
  665. "use strict";
  666. var main = document.getElementById('tarteaucitronServices_' + id),
  667. allDivs,
  668. store = [],
  669. i;
  670. if (main === null) {
  671. return;
  672. }
  673. allDivs = main.childNodes;
  674. if (typeof Array.prototype.map === 'function') {
  675. Array.prototype.map.call(main.children, Object).sort(function (a, b) {
  676. if (tarteaucitron.services[a.id.replace(/Line/g, '')].name > tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return 1; }
  677. if (tarteaucitron.services[a.id.replace(/Line/g, '')].name < tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return -1; }
  678. return 0;
  679. }).forEach(function (element) {
  680. main.appendChild(element);
  681. });
  682. }
  683. },
  684. "jsSizing": function (type) {
  685. "use strict";
  686. var scrollbarMarginRight = 10,
  687. scrollbarWidthParent,
  688. scrollbarWidthChild,
  689. servicesHeight,
  690. e = window,
  691. a = 'inner',
  692. windowInnerHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
  693. mainTop,
  694. mainHeight,
  695. closeButtonHeight,
  696. headerHeight,
  697. cookiesListHeight,
  698. cookiesCloseHeight,
  699. cookiesTitleHeight,
  700. paddingBox,
  701. alertSmallHeight,
  702. cookiesNumberHeight;
  703. if (type === 'box') {
  704. if (document.getElementById('tarteaucitronAlertSmall') !== null && document.getElementById('tarteaucitronCookiesNumber') !== null) {
  705. // reset
  706. tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', '0px 10px');
  707. // calculate
  708. alertSmallHeight = document.getElementById('tarteaucitronAlertSmall').offsetHeight;
  709. cookiesNumberHeight = document.getElementById('tarteaucitronCookiesNumber').offsetHeight;
  710. paddingBox = (alertSmallHeight - cookiesNumberHeight) / 2;
  711. // apply
  712. tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', paddingBox + 'px 10px');
  713. }
  714. } else if (type === 'main') {
  715. // get the real window width for media query
  716. if (window.innerWidth === undefined) {
  717. a = 'client';
  718. e = document.documentElement || document.body;
  719. }
  720. // height of the services list container
  721. if (document.getElementById('tarteaucitron') !== null && document.getElementById('tarteaucitronClosePanel') !== null && document.getElementById('tarteaucitronMainLineOffset') !== null) {
  722. // reset
  723. tarteaucitron.userInterface.css('tarteaucitronScrollbarParent', 'height', 'auto');
  724. // calculate
  725. mainHeight = document.getElementById('tarteaucitron').offsetHeight;
  726. closeButtonHeight = document.getElementById('tarteaucitronClosePanel').offsetHeight;
  727. headerHeight = document.getElementById('tarteaucitronMainLineOffset').offsetHeight;
  728. // apply
  729. servicesHeight = (mainHeight - closeButtonHeight - headerHeight + 1);
  730. tarteaucitron.userInterface.css('tarteaucitronScrollbarParent', 'height', servicesHeight + 'px');
  731. }
  732. // align the main allow/deny button depending on scrollbar width
  733. if (document.getElementById('tarteaucitronScrollbarParent') !== null && document.getElementById('tarteaucitronScrollbarChild') !== null) {
  734. // media query
  735. if (e[a + 'Width'] <= 479) {
  736. tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginLeft', '11px');
  737. } else if (e[a + 'Width'] <= 767) {
  738. scrollbarMarginRight = 12;
  739. }
  740. scrollbarWidthParent = document.getElementById('tarteaucitronScrollbarParent').offsetWidth;
  741. scrollbarWidthChild = document.getElementById('tarteaucitronScrollbarChild').offsetWidth;
  742. tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginRight', ((scrollbarWidthParent - scrollbarWidthChild) + scrollbarMarginRight) + 'px');
  743. }
  744. // center the main panel
  745. if (document.getElementById('tarteaucitron') !== null) {
  746. // media query
  747. if (e[a + 'Width'] <= 767) {
  748. mainTop = 0;
  749. } else {
  750. mainTop = ((windowInnerHeight - document.getElementById('tarteaucitron').offsetHeight) / 2) - 21;
  751. }
  752. // correct
  753. if (mainTop < 0) {
  754. mainTop = 0;
  755. }
  756. if (document.getElementById('tarteaucitronMainLineOffset') !== null) {
  757. if (document.getElementById('tarteaucitron').offsetHeight < (windowInnerHeight / 2)) {
  758. mainTop -= document.getElementById('tarteaucitronMainLineOffset').offsetHeight;
  759. }
  760. }
  761. // apply
  762. tarteaucitron.userInterface.css('tarteaucitron', 'top', mainTop + 'px');
  763. }
  764. } else if (type === 'cookie') {
  765. // put cookies list at bottom
  766. if (document.getElementById('tarteaucitronAlertSmall') !== null) {
  767. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'bottom', (document.getElementById('tarteaucitronAlertSmall').offsetHeight) + 'px');
  768. }
  769. // height of cookies list
  770. if (document.getElementById('tarteaucitronCookiesListContainer') !== null) {
  771. // reset
  772. tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', 'auto');
  773. // calculate
  774. cookiesListHeight = document.getElementById('tarteaucitronCookiesListContainer').offsetHeight;
  775. cookiesCloseHeight = document.getElementById('tarteaucitronClosePanelCookie').offsetHeight;
  776. cookiesTitleHeight = document.getElementById('tarteaucitronCookiesTitle').offsetHeight;
  777. // apply
  778. tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', (cookiesListHeight - cookiesCloseHeight - cookiesTitleHeight - 2) + 'px');
  779. }
  780. }
  781. }
  782. },
  783. "cookie": {
  784. "owner": {},
  785. "create": function (key, status) {
  786. "use strict";
  787. var d = new Date(),
  788. time = d.getTime(),
  789. expireTime = time + 31536000000, // 365 days
  790. regex = new RegExp("!" + key + "=(wait|true|false)", "g"),
  791. cookie = tarteaucitron.cookie.read().replace(regex, ""),
  792. value = 'tarteaucitron=' + cookie + '!' + key + '=' + status,
  793. domain = (tarteaucitron.parameters.cookieDomain !== undefined && tarteaucitron.parameters.cookieDomain !== '') ? 'domain=' + tarteaucitron.parameters.cookieDomain + ';' : '';
  794. if (tarteaucitron.cookie.read().indexOf(key + '=' + status) === -1) {
  795. tarteaucitron.pro('!' + key + '=' + status);
  796. }
  797. d.setTime(expireTime);
  798. document.cookie = value + '; expires=' + d.toGMTString() + '; path=/;' + domain;
  799. },
  800. "read": function () {
  801. "use strict";
  802. var nameEQ = "tarteaucitron=",
  803. ca = document.cookie.split(';'),
  804. i,
  805. c;
  806. for (i = 0; i < ca.length; i += 1) {
  807. c = ca[i];
  808. while (c.charAt(0) === ' ') {
  809. c = c.substring(1, c.length);
  810. }
  811. if (c.indexOf(nameEQ) === 0) {
  812. return c.substring(nameEQ.length, c.length);
  813. }
  814. }
  815. return '';
  816. },
  817. "purge": function (arr) {
  818. "use strict";
  819. var i;
  820. for (i = 0; i < arr.length; i += 1) {
  821. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/;';
  822. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname + ';';
  823. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname.split('.').slice(-2).join('.') + ';';
  824. }
  825. },
  826. "checkCount": function (key) {
  827. "use strict";
  828. var arr = tarteaucitron.services[key].cookies,
  829. nb = arr.length,
  830. nbCurrent = 0,
  831. html = '',
  832. i,
  833. status = document.cookie.indexOf(key + '=true');
  834. if (status >= 0 && nb === 0) {
  835. html += tarteaucitron.lang.useNoCookie;
  836. } else if (status >= 0) {
  837. for (i = 0; i < nb; i += 1) {
  838. if (document.cookie.indexOf(arr[i] + '=') !== -1) {
  839. nbCurrent += 1;
  840. if (tarteaucitron.cookie.owner[arr[i]] === undefined) {
  841. tarteaucitron.cookie.owner[arr[i]] = [];
  842. }
  843. if (tarteaucitron.cookie.crossIndexOf(tarteaucitron.cookie.owner[arr[i]], tarteaucitron.services[key].name) === false) {
  844. tarteaucitron.cookie.owner[arr[i]].push(tarteaucitron.services[key].name);
  845. }
  846. }
  847. }
  848. if (nbCurrent > 0) {
  849. html += tarteaucitron.lang.useCookieCurrent + ' ' + nbCurrent + ' cookie';
  850. if (nbCurrent > 1) {
  851. html += 's';
  852. }
  853. html += '.';
  854. } else {
  855. html += tarteaucitron.lang.useNoCookie;
  856. }
  857. } else if (nb === 0) {
  858. html = tarteaucitron.lang.noCookie;
  859. } else {
  860. html += tarteaucitron.lang.useCookie + ' ' + nb + ' cookie';
  861. if (nb > 1) {
  862. html += 's';
  863. }
  864. html += '.';
  865. }
  866. if (document.getElementById('tacCL' + key) !== null) {
  867. document.getElementById('tacCL' + key).innerHTML = html;
  868. }
  869. },
  870. "crossIndexOf": function (arr, match) {
  871. "use strict";
  872. var i;
  873. for (i = 0; i < arr.length; i += 1) {
  874. if (arr[i] === match) {
  875. return true;
  876. }
  877. }
  878. return false;
  879. },
  880. "number": function () {
  881. "use strict";
  882. var cookies = document.cookie.split(';'),
  883. nb = (document.cookie !== '') ? cookies.length : 0,
  884. html = '',
  885. i,
  886. name,
  887. namea,
  888. nameb,
  889. c,
  890. d,
  891. s = (nb > 1) ? 's' : '',
  892. savedname,
  893. regex = /^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i,
  894. regexedDomain = (tarteaucitron.cdn.match(regex) !== null) ? tarteaucitron.cdn.match(regex)[1] : tarteaucitron.cdn,
  895. host = (tarteaucitron.domain !== undefined) ? tarteaucitron.domain : regexedDomain;
  896. cookies = cookies.sort(function (a, b) {
  897. namea = a.split('=', 1).toString().replace(/ /g, '');
  898. nameb = b.split('=', 1).toString().replace(/ /g, '');
  899. c = (tarteaucitron.cookie.owner[namea] !== undefined) ? tarteaucitron.cookie.owner[namea] : '0';
  900. d = (tarteaucitron.cookie.owner[nameb] !== undefined) ? tarteaucitron.cookie.owner[nameb] : '0';
  901. if (c + a > d + b) { return 1; }
  902. if (c + a < d + b) { return -1; }
  903. return 0;
  904. });
  905. if (document.cookie !== '') {
  906. for (i = 0; i < nb; i += 1) {
  907. name = cookies[i].split('=', 1).toString().replace(/ /g, '');
  908. if (tarteaucitron.cookie.owner[name] !== undefined && tarteaucitron.cookie.owner[name].join(' // ') !== savedname) {
  909. savedname = tarteaucitron.cookie.owner[name].join(' // ');
  910. html += '<div class="tarteaucitronHidden">';
  911. html += ' <div class="tarteaucitronTitle">';
  912. html += ' ' + tarteaucitron.cookie.owner[name].join(' // ');
  913. html += ' </div>';
  914. html += '</div>';
  915. } else if (tarteaucitron.cookie.owner[name] === undefined && host !== savedname) {
  916. savedname = host;
  917. html += '<div class="tarteaucitronHidden">';
  918. html += ' <div class="tarteaucitronTitle">';
  919. html += ' ' + host;
  920. html += ' </div>';
  921. html += '</div>';
  922. }
  923. html += '<div class="tarteaucitronCookiesListMain">';
  924. 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>';
  925. html += ' </div>';
  926. html += ' <div class="tarteaucitronCookiesListRight">' + cookies[i].split('=').slice(1).join('=') + '</div>';
  927. html += '</div>';
  928. }
  929. } else {
  930. html += '<div class="tarteaucitronCookiesListMain">';
  931. html += ' <div class="tarteaucitronCookiesListLeft"><b>-</b></div>';
  932. html += ' <div class="tarteaucitronCookiesListRight"></div>';
  933. html += '</div>';
  934. }
  935. html += '<div class="tarteaucitronHidden" style="height:20px;display:block"></div>';
  936. if (document.getElementById('tarteaucitronCookiesList') !== null) {
  937. document.getElementById('tarteaucitronCookiesList').innerHTML = html;
  938. }
  939. if (document.getElementById('tarteaucitronCookiesNumber') !== null) {
  940. document.getElementById('tarteaucitronCookiesNumber').innerHTML = nb;
  941. }
  942. if (document.getElementById('tarteaucitronCookiesNumberBis') !== null) {
  943. document.getElementById('tarteaucitronCookiesNumberBis').innerHTML = nb + ' cookie' + s;
  944. }
  945. for (i = 0; i < tarteaucitron.job.length; i += 1) {
  946. tarteaucitron.cookie.checkCount(tarteaucitron.job[i]);
  947. }
  948. }
  949. },
  950. "getLanguage": function () {
  951. "use strict";
  952. if (!navigator) { return 'en'; }
  953. var availableLanguages = 'cs,en,fr,es,it,de,pt,pl,ru',
  954. defaultLanguage = 'en',
  955. lang = navigator.language || navigator.browserLanguage ||
  956. navigator.systemLanguage || navigator.userLang || null,
  957. userLanguage = lang.substr(0, 2);
  958. if (tarteaucitronForceLanguage !== '') {
  959. if (availableLanguages.indexOf(tarteaucitronForceLanguage) !== -1) {
  960. return tarteaucitronForceLanguage;
  961. }
  962. }
  963. if (availableLanguages.indexOf(userLanguage) === -1) {
  964. return defaultLanguage;
  965. }
  966. return userLanguage;
  967. },
  968. "getLocale": function () {
  969. "use strict";
  970. if (!navigator) { return 'en_US'; }
  971. var lang = navigator.language || navigator.browserLanguage ||
  972. navigator.systemLanguage || navigator.userLang || null,
  973. userLanguage = lang.substr(0, 2);
  974. if (userLanguage === 'fr') {
  975. return 'fr_FR';
  976. } else if (userLanguage === 'en') {
  977. return 'en_US';
  978. } else if (userLanguage === 'de') {
  979. return 'de_DE';
  980. } else if (userLanguage === 'es') {
  981. return 'es_ES';
  982. } else if (userLanguage === 'it') {
  983. return 'it_IT';
  984. } else if (userLanguage === 'pt') {
  985. return 'pt_PT';
  986. } else {
  987. return 'en_US';
  988. }
  989. },
  990. "addScript": function (url, id, callback, execute, attrName, attrVal) {
  991. "use strict";
  992. var script,
  993. done = false;
  994. if (execute === false) {
  995. if (typeof callback === 'function') {
  996. callback();
  997. }
  998. } else {
  999. script = document.createElement('script');
  1000. script.type = 'text/javascript';
  1001. script.id = (id !== undefined) ? id : '';
  1002. script.async = true;
  1003. script.src = url;
  1004. if (attrName !== undefined && attrVal !== undefined) {
  1005. script.setAttribute(attrName, attrVal);
  1006. }
  1007. if (typeof callback === 'function') {
  1008. script.onreadystatechange = script.onload = function () {
  1009. var state = script.readyState;
  1010. if (!done && (!state || /loaded|complete/.test(state))) {
  1011. done = true;
  1012. callback();
  1013. }
  1014. };
  1015. }
  1016. document.getElementsByTagName('head')[0].appendChild(script);
  1017. }
  1018. },
  1019. "makeAsync": {
  1020. "antiGhost": 0,
  1021. "buffer": '',
  1022. "init": function (url, id) {
  1023. "use strict";
  1024. var savedWrite = document.write,
  1025. savedWriteln = document.writeln;
  1026. document.write = function (content) {
  1027. tarteaucitron.makeAsync.buffer += content;
  1028. };
  1029. document.writeln = function (content) {
  1030. tarteaucitron.makeAsync.buffer += content.concat("\n");
  1031. };
  1032. setTimeout(function () {
  1033. document.write = savedWrite;
  1034. document.writeln = savedWriteln;
  1035. }, 20000);
  1036. tarteaucitron.makeAsync.getAndParse(url, id);
  1037. },
  1038. "getAndParse": function (url, id) {
  1039. "use strict";
  1040. if (tarteaucitron.makeAsync.antiGhost > 9) {
  1041. tarteaucitron.makeAsync.antiGhost = 0;
  1042. return;
  1043. }
  1044. tarteaucitron.makeAsync.antiGhost += 1;
  1045. tarteaucitron.addScript(url, '', function () {
  1046. if (document.getElementById(id) !== null) {
  1047. document.getElementById(id).innerHTML += "<span style='display:none'>&nbsp;</span>" + tarteaucitron.makeAsync.buffer;
  1048. tarteaucitron.makeAsync.buffer = '';
  1049. tarteaucitron.makeAsync.execJS(id);
  1050. }
  1051. });
  1052. },
  1053. "execJS": function (id) {
  1054. /* not strict because third party scripts may have errors */
  1055. var i,
  1056. scripts,
  1057. childId,
  1058. type;
  1059. if (document.getElementById(id) === null) {
  1060. return;
  1061. }
  1062. scripts = document.getElementById(id).getElementsByTagName('script');
  1063. for (i = 0; i < scripts.length; i += 1) {
  1064. type = (scripts[i].getAttribute('type') !== null) ? scripts[i].getAttribute('type') : '';
  1065. if (type === '') {
  1066. type = (scripts[i].getAttribute('language') !== null) ? scripts[i].getAttribute('language') : '';
  1067. }
  1068. if (scripts[i].getAttribute('src') !== null && scripts[i].getAttribute('src') !== '') {
  1069. childId = id + Math.floor(Math.random() * 99999999999);
  1070. document.getElementById(id).innerHTML += '<div id="' + childId + '"></div>';
  1071. tarteaucitron.makeAsync.getAndParse(scripts[i].getAttribute('src'), childId);
  1072. } else if (type.indexOf('javascript') !== -1 || type === '') {
  1073. eval(scripts[i].innerHTML);
  1074. }
  1075. }
  1076. }
  1077. },
  1078. "fallback": function (matchClass, content, noInner) {
  1079. "use strict";
  1080. var elems = document.getElementsByTagName('*'),
  1081. i,
  1082. index = 0;
  1083. for (i in elems) {
  1084. if (elems[i] !== undefined) {
  1085. for (index = 0; index < matchClass.length; index += 1) {
  1086. if ((' ' + elems[i].className + ' ')
  1087. .indexOf(' ' + matchClass[index] + ' ') > -1) {
  1088. if (typeof content === 'function') {
  1089. if (noInner === true) {
  1090. content(elems[i]);
  1091. } else {
  1092. elems[i].innerHTML = content(elems[i]);
  1093. }
  1094. } else {
  1095. elems[i].innerHTML = content;
  1096. }
  1097. }
  1098. }
  1099. }
  1100. }
  1101. },
  1102. "engage": function (id) {
  1103. "use strict";
  1104. var html = '',
  1105. r = Math.floor(Math.random() * 100000);
  1106. html += '<div class="tac_activate">';
  1107. html += ' <div class="tac_float">';
  1108. html += ' <b>' + tarteaucitron.services[id].name + '</b> ' + tarteaucitron.lang.fallback;
  1109. html += ' <div class="tarteaucitronAllow" id="Eng' + r + 'ed' + id + '" onclick="tarteaucitron.userInterface.respond(this, true);">';
  1110. html += ' &#10003; ' + tarteaucitron.lang.allow;
  1111. html += ' </div>';
  1112. html += ' </div>';
  1113. html += '</div>';
  1114. return html;
  1115. },
  1116. "extend": function (a, b) {
  1117. "use strict";
  1118. var prop;
  1119. for (prop in b) {
  1120. if (b.hasOwnProperty(prop)) {
  1121. a[prop] = b[prop];
  1122. }
  1123. }
  1124. },
  1125. "proTemp": '',
  1126. "proTimer": function () {
  1127. "use strict";
  1128. setTimeout(tarteaucitron.proPing, 1000);
  1129. },
  1130. "pro": function (list) {
  1131. "use strict";
  1132. tarteaucitron.proTemp += list;
  1133. clearTimeout(tarteaucitron.proTimer);
  1134. tarteaucitron.proTimer = setTimeout(tarteaucitron.proPing, 2500);
  1135. },
  1136. "proPing": function () {
  1137. "use strict";
  1138. if (tarteaucitron.uuid !== '' && tarteaucitron.uuid !== undefined && tarteaucitron.proTemp !== '') {
  1139. var div = document.getElementById('tarteaucitronPremium'),
  1140. timestamp = new Date().getTime(),
  1141. url = '//opt-out.ferank.eu/premium.php?';
  1142. if (div === null) {
  1143. return;
  1144. }
  1145. url += 'domain=' + tarteaucitron.domain + '&';
  1146. url += 'uuid=' + tarteaucitron.uuid + '&';
  1147. url += 'c=' + encodeURIComponent(tarteaucitron.proTemp) + '&';
  1148. url += '_' + timestamp;
  1149. div.innerHTML = '<img src="' + url + '" style="display:none" />';
  1150. tarteaucitron.proTemp = '';
  1151. }
  1152. tarteaucitron.cookie.number();
  1153. }
  1154. };