tarteaucitron.js 60 KB

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