tarteaucitron.js 61 KB

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