tarteaucitron.js 61 KB

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