tarteaucitron.js 55 KB

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