tarteaucitron.js 61 KB

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