tarteaucitron.js 59 KB

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