tarteaucitron.js 60 KB

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