tarteaucitron.js 61 KB

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