tarteaucitron.js 60 KB

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