tarteaucitron.js 61 KB

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