tarteaucitron.js 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199
  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": 204.5,
  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. if (tarteaucitron.reloadThePage === true) {
  547. window.location.reload();
  548. } else {
  549. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
  550. }
  551. },
  552. "openAlert": function () {
  553. "use strict";
  554. var c = 'tarteaucitron';
  555. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'none');
  556. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'block');
  557. },
  558. "closeAlert": function () {
  559. "use strict";
  560. var c = 'tarteaucitron';
  561. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'block');
  562. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'none');
  563. tarteaucitron.userInterface.jsSizing('box');
  564. },
  565. "toggleCookiesList": function () {
  566. "use strict";
  567. var div = document.getElementById('tarteaucitronCookiesListContainer');
  568. if (div === null) {
  569. return;
  570. }
  571. if (div.style.display !== 'block') {
  572. tarteaucitron.cookie.number();
  573. div.style.display = 'block';
  574. tarteaucitron.userInterface.jsSizing('cookie');
  575. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  576. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
  577. } else {
  578. div.style.display = 'none';
  579. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  580. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
  581. }
  582. },
  583. "toggle": function (id, closeClass) {
  584. "use strict";
  585. var div = document.getElementById(id);
  586. if (div === null) {
  587. return;
  588. }
  589. if (closeClass !== undefined) {
  590. tarteaucitron.fallback([closeClass], function (elem) {
  591. if (elem.id !== id) {
  592. elem.style.display = 'none';
  593. }
  594. }, true);
  595. }
  596. if (div.style.display !== 'block') {
  597. div.style.display = 'block';
  598. } else {
  599. div.style.display = 'none';
  600. }
  601. },
  602. "order": function (id) {
  603. "use strict";
  604. var main = document.getElementById('tarteaucitronServices_' + id),
  605. allDivs = main.childNodes,
  606. store = [],
  607. i;
  608. if (main === null) {
  609. return;
  610. }
  611. if (typeof Array.prototype.map === 'function') {
  612. Array.prototype.map.call(main.children, Object).sort(function (a, b) {
  613. if (tarteaucitron.services[a.id.replace(/Line/g, '')].name > tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return 1; }
  614. if (tarteaucitron.services[a.id.replace(/Line/g, '')].name < tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return -1; }
  615. return 0;
  616. }).forEach(function (element) {
  617. main.appendChild(element);
  618. });
  619. }
  620. },
  621. "jsSizing": function (type) {
  622. "use strict";
  623. var scrollbarMarginRight = 10,
  624. scrollbarWidthParent,
  625. scrollbarWidthChild,
  626. servicesHeight,
  627. e = window,
  628. a = 'inner',
  629. windowInnerHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
  630. mainTop,
  631. mainHeight,
  632. closeButtonHeight,
  633. headerHeight,
  634. cookiesListHeight,
  635. cookiesCloseHeight,
  636. cookiesTitleHeight,
  637. paddingBox,
  638. alertSmallHeight,
  639. cookiesNumberHeight;
  640. if (type === 'box') {
  641. if (document.getElementById('tarteaucitronAlertSmall') !== null && document.getElementById('tarteaucitronCookiesNumber') !== null) {
  642. // reset
  643. tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', '0px 10px');
  644. // calculate
  645. alertSmallHeight = document.getElementById('tarteaucitronAlertSmall').offsetHeight;
  646. cookiesNumberHeight = document.getElementById('tarteaucitronCookiesNumber').offsetHeight;
  647. paddingBox = (alertSmallHeight - cookiesNumberHeight) / 2;
  648. // apply
  649. tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', paddingBox + 'px 10px');
  650. }
  651. } else if (type === 'main') {
  652. // get the real window width for media query
  653. if (window.innerWidth === undefined) {
  654. a = 'client';
  655. e = document.documentElement || document.body;
  656. }
  657. // height of the services list container
  658. if (document.getElementById('tarteaucitron') !== null && document.getElementById('tarteaucitronClosePanel') !== null && document.getElementById('tarteaucitronMainLineOffset') !== null) {
  659. // reset
  660. tarteaucitron.userInterface.css('tarteaucitronScrollbarParent', 'height', 'auto');
  661. // calculate
  662. mainHeight = document.getElementById('tarteaucitron').offsetHeight;
  663. closeButtonHeight = document.getElementById('tarteaucitronClosePanel').offsetHeight;
  664. headerHeight = document.getElementById('tarteaucitronMainLineOffset').offsetHeight;
  665. // apply
  666. servicesHeight = (mainHeight - closeButtonHeight - headerHeight + 1);
  667. tarteaucitron.userInterface.css('tarteaucitronScrollbarParent', 'height', servicesHeight + 'px');
  668. }
  669. // align the main allow/deny button depending on scrollbar width
  670. if (document.getElementById('tarteaucitronScrollbarParent') !== null && document.getElementById('tarteaucitronScrollbarChild') !== null) {
  671. // media query
  672. if (e[a + 'Width'] <= 479) {
  673. tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginLeft', '11px');
  674. } else if (e[a + 'Width'] <= 767) {
  675. scrollbarMarginRight = 12;
  676. }
  677. scrollbarWidthParent = document.getElementById('tarteaucitronScrollbarParent').offsetWidth;
  678. scrollbarWidthChild = document.getElementById('tarteaucitronScrollbarChild').offsetWidth;
  679. tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginRight', ((scrollbarWidthParent - scrollbarWidthChild) + scrollbarMarginRight) + 'px');
  680. }
  681. // center the main panel
  682. if (document.getElementById('tarteaucitron') !== null) {
  683. // media query
  684. if (e[a + 'Width'] <= 767) {
  685. mainTop = 0;
  686. } else {
  687. mainTop = ((windowInnerHeight - document.getElementById('tarteaucitron').offsetHeight) / 2) - 21;
  688. }
  689. // correct
  690. if (mainTop < 0) {
  691. mainTop = 0;
  692. }
  693. if (document.getElementById('tarteaucitronMainLineOffset') !== null) {
  694. if (document.getElementById('tarteaucitron').offsetHeight < (windowInnerHeight / 2)) {
  695. mainTop -= document.getElementById('tarteaucitronMainLineOffset').offsetHeight;
  696. }
  697. }
  698. // apply
  699. tarteaucitron.userInterface.css('tarteaucitron', 'top', mainTop + 'px');
  700. }
  701. } else if (type === 'cookie') {
  702. // put cookies list at bottom
  703. if (document.getElementById('tarteaucitronAlertSmall') !== null) {
  704. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'bottom', (document.getElementById('tarteaucitronAlertSmall').offsetHeight) + 'px');
  705. }
  706. // height of cookies list
  707. if (document.getElementById('tarteaucitronCookiesListContainer') !== null) {
  708. // reset
  709. tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', 'auto');
  710. // calculate
  711. cookiesListHeight = document.getElementById('tarteaucitronCookiesListContainer').offsetHeight;
  712. cookiesCloseHeight = document.getElementById('tarteaucitronClosePanelCookie').offsetHeight;
  713. cookiesTitleHeight = document.getElementById('tarteaucitronCookiesTitle').offsetHeight;
  714. // apply
  715. tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', (cookiesListHeight - cookiesCloseHeight - cookiesTitleHeight - 2) + 'px');
  716. }
  717. }
  718. }
  719. },
  720. "cookie": {
  721. "owner": {},
  722. "create": function (key, status) {
  723. "use strict";
  724. var d = new Date(),
  725. time = d.getTime(),
  726. expireTime = time + 31536000000, // 365 days
  727. regex = new RegExp("!" + key + "=(wait|true|false)", "g"),
  728. cookie = tarteaucitron.cookie.read().replace(regex, ""),
  729. value = 'tarteaucitron=' + cookie + '!' + key + '=' + status;
  730. if (tarteaucitron.cookie.read().indexOf(key + '=' + status) === -1) {
  731. tarteaucitron.pro('!' + key + '=' + status);
  732. }
  733. d.setTime(expireTime);
  734. document.cookie = value + '; expires=' + d.toGMTString() + '; path=/;';
  735. },
  736. "read": function () {
  737. "use strict";
  738. var nameEQ = "tarteaucitron=",
  739. ca = document.cookie.split(';'),
  740. i,
  741. c;
  742. for (i = 0; i < ca.length; i += 1) {
  743. c = ca[i];
  744. while (c.charAt(0) === ' ') {
  745. c = c.substring(1, c.length);
  746. }
  747. if (c.indexOf(nameEQ) === 0) {
  748. return c.substring(nameEQ.length, c.length);
  749. }
  750. }
  751. return '';
  752. },
  753. "purge": function (arr) {
  754. "use strict";
  755. var i;
  756. for (i = 0; i < arr.length; i += 1) {
  757. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/;';
  758. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname + ';';
  759. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname.split('.').slice(-2).join('.') + ';';
  760. }
  761. },
  762. "checkCount": function (key) {
  763. "use strict";
  764. var arr = tarteaucitron.services[key].cookies,
  765. nb = arr.length,
  766. nbCurrent = 0,
  767. html = '',
  768. i,
  769. status = document.cookie.indexOf(key + '=true');
  770. if (status >= 0 && nb === 0) {
  771. html += tarteaucitron.lang.useNoCookie;
  772. } else if (status >= 0) {
  773. for (i = 0; i < nb; i += 1) {
  774. if (document.cookie.indexOf(arr[i] + '=') !== -1) {
  775. nbCurrent += 1;
  776. if (tarteaucitron.cookie.owner[arr[i]] === undefined) {
  777. tarteaucitron.cookie.owner[arr[i]] = [];
  778. }
  779. if (tarteaucitron.cookie.crossIndexOf(tarteaucitron.cookie.owner[arr[i]], tarteaucitron.services[key].name) === false) {
  780. tarteaucitron.cookie.owner[arr[i]].push(tarteaucitron.services[key].name);
  781. }
  782. }
  783. }
  784. if (nbCurrent > 0) {
  785. html += tarteaucitron.lang.useCookieCurrent + ' ' + nbCurrent + ' cookie';
  786. if (nbCurrent > 1) {
  787. html += 's';
  788. }
  789. html += '.';
  790. } else {
  791. html += tarteaucitron.lang.useNoCookie;
  792. }
  793. } else if (nb === 0) {
  794. html = tarteaucitron.lang.noCookie;
  795. } else {
  796. html += tarteaucitron.lang.useCookie + ' ' + nb + ' cookie';
  797. if (nb > 1) {
  798. html += 's';
  799. }
  800. html += '.';
  801. }
  802. if (document.getElementById('tacCL' + key) !== null) {
  803. document.getElementById('tacCL' + key).innerHTML = html;
  804. }
  805. },
  806. "crossIndexOf": function (arr, match) {
  807. "use strict";
  808. var i;
  809. for (i = 0; i < arr.length; i += 1) {
  810. if (arr[i] === match) {
  811. return true;
  812. }
  813. }
  814. return false;
  815. },
  816. "number": function () {
  817. "use strict";
  818. var cookies = document.cookie.split(';'),
  819. nb = (document.cookie !== '') ? cookies.length : 0,
  820. html = '',
  821. i,
  822. name,
  823. namea,
  824. nameb,
  825. c,
  826. d,
  827. s = (nb > 1) ? 's' : '',
  828. savedname,
  829. regex = /^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i,
  830. regexedDomain = (tarteaucitron.cdn.match(regex) !== null) ? tarteaucitron.cdn.match(regex)[1] : tarteaucitron.cdn,
  831. host = (tarteaucitron.domain !== undefined) ? tarteaucitron.domain : regexedDomain;
  832. cookies = cookies.sort(function (a, b) {
  833. namea = a.split('=', 1).toString().replace(/ /g, '');
  834. nameb = b.split('=', 1).toString().replace(/ /g, '');
  835. c = (tarteaucitron.cookie.owner[namea] !== undefined) ? tarteaucitron.cookie.owner[namea] : '0';
  836. d = (tarteaucitron.cookie.owner[nameb] !== undefined) ? tarteaucitron.cookie.owner[nameb] : '0';
  837. if (c + a > d + b) { return 1; }
  838. if (c + a < d + b) { return -1; }
  839. return 0;
  840. });
  841. if (document.cookie !== '') {
  842. for (i = 0; i < nb; i += 1) {
  843. name = cookies[i].split('=', 1).toString().replace(/ /g, '');
  844. if (tarteaucitron.cookie.owner[name] !== undefined && tarteaucitron.cookie.owner[name].join(' // ') !== savedname) {
  845. savedname = tarteaucitron.cookie.owner[name].join(' // ');
  846. html += '<div class="tarteaucitronHidden">';
  847. html += ' <div class="tarteaucitronTitle">';
  848. html += ' ' + tarteaucitron.cookie.owner[name].join(' // ');
  849. html += ' </div>';
  850. html += '</div>';
  851. } else if (tarteaucitron.cookie.owner[name] === undefined && host !== savedname) {
  852. savedname = host;
  853. html += '<div class="tarteaucitronHidden">';
  854. html += ' <div class="tarteaucitronTitle">';
  855. html += ' ' + host;
  856. html += ' </div>';
  857. html += '</div>';
  858. }
  859. html += '<div class="tarteaucitronCookiesListMain">';
  860. 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>';
  861. html += ' </div>';
  862. html += ' <div class="tarteaucitronCookiesListRight">' + cookies[i].split('=').slice(1).join('=') + '</div>';
  863. html += '</div>';
  864. }
  865. } else {
  866. html += '<div class="tarteaucitronCookiesListMain">';
  867. html += ' <div class="tarteaucitronCookiesListLeft"><b>-</b></div>';
  868. html += ' <div class="tarteaucitronCookiesListRight"></div>';
  869. html += '</div>';
  870. }
  871. html += '<div class="tarteaucitronHidden" style="height:20px;display:block"></div>';
  872. if (document.getElementById('tarteaucitronCookiesList') !== null) {
  873. document.getElementById('tarteaucitronCookiesList').innerHTML = html;
  874. }
  875. if (document.getElementById('tarteaucitronCookiesNumber') !== null) {
  876. document.getElementById('tarteaucitronCookiesNumber').innerHTML = nb;
  877. }
  878. if (document.getElementById('tarteaucitronCookiesNumberBis') !== null) {
  879. document.getElementById('tarteaucitronCookiesNumberBis').innerHTML = nb + ' cookie' + s;
  880. }
  881. }
  882. },
  883. "getLanguage": function () {
  884. "use strict";
  885. if (!navigator) { return 'en'; }
  886. var availableLanguages = 'en,fr,es,it,de,pt,pl',
  887. defaultLanguage = 'en',
  888. lang = navigator.language || navigator.browserLanguage ||
  889. navigator.systemLanguage || navigator.userLang || null,
  890. userLanguage = lang.substr(0, 2);
  891. if (tarteaucitronForceLanguage !== '') {
  892. if (availableLanguages.indexOf(tarteaucitronForceLanguage) !== -1) {
  893. return tarteaucitronForceLanguage;
  894. }
  895. }
  896. if (availableLanguages.indexOf(userLanguage) === -1) {
  897. return defaultLanguage;
  898. }
  899. return userLanguage;
  900. },
  901. "getLocale": function () {
  902. "use strict";
  903. if (!navigator) { return 'en_US'; }
  904. var lang = navigator.language || navigator.browserLanguage ||
  905. navigator.systemLanguage || navigator.userLang || null,
  906. userLanguage = lang.substr(0, 2);
  907. if (userLanguage === 'fr') {
  908. return 'fr_FR';
  909. } else if (userLanguage === 'en') {
  910. return 'en_US';
  911. } else if (userLanguage === 'de') {
  912. return 'de_DE';
  913. } else if (userLanguage === 'es') {
  914. return 'es_ES';
  915. } else if (userLanguage === 'it') {
  916. return 'it_IT';
  917. } else if (userLanguage === 'pt') {
  918. return 'pt_PT';
  919. } else {
  920. return 'en_US';
  921. }
  922. },
  923. "addScript": function (url, id, callback, execute) {
  924. "use strict";
  925. var script,
  926. done = false;
  927. if (execute === false) {
  928. if (typeof callback === 'function') {
  929. callback();
  930. }
  931. } else {
  932. script = document.createElement('script');
  933. script.type = 'text/javascript';
  934. script.id = (id !== undefined) ? id : '';
  935. script.async = true;
  936. script.src = url;
  937. if (typeof callback === 'function') {
  938. script.onreadystatechange = script.onload = function () {
  939. var state = script.readyState;
  940. if (!done && (!state || /loaded|complete/.test(state))) {
  941. done = true;
  942. callback();
  943. }
  944. };
  945. }
  946. document.getElementsByTagName('head')[0].appendChild(script);
  947. }
  948. },
  949. "makeAsync": {
  950. "antiGhost": 0,
  951. "buffer": '',
  952. "init": function (url, id) {
  953. "use strict";
  954. var savedWrite = document.write,
  955. savedWriteln = document.writeln;
  956. document.write = function (content) {
  957. tarteaucitron.makeAsync.buffer += content;
  958. };
  959. document.writeln = function (content) {
  960. tarteaucitron.makeAsync.buffer += content.concat("\n");
  961. };
  962. setTimeout(function () {
  963. document.write = savedWrite;
  964. document.writeln = savedWriteln;
  965. }, 20000);
  966. tarteaucitron.makeAsync.getAndParse(url, id);
  967. },
  968. "getAndParse": function (url, id) {
  969. "use strict";
  970. if (tarteaucitron.makeAsync.antiGhost > 9) {
  971. tarteaucitron.makeAsync.antiGhost = 0;
  972. return;
  973. }
  974. tarteaucitron.makeAsync.antiGhost += 1;
  975. tarteaucitron.addScript(url, '', function () {
  976. if (document.getElementById(id) !== null) {
  977. document.getElementById(id).innerHTML += "<span style='display:none'>&nbsp;</span>" + tarteaucitron.makeAsync.buffer;
  978. tarteaucitron.makeAsync.buffer = '';
  979. tarteaucitron.makeAsync.execJS(id);
  980. }
  981. });
  982. },
  983. "execJS": function (id) {
  984. /* not strict because third party scripts may have errors */
  985. var i,
  986. scripts,
  987. childId,
  988. type;
  989. if (document.getElementById(id) === null) {
  990. return;
  991. }
  992. scripts = document.getElementById(id).getElementsByTagName('script');
  993. for (i = 0; i < scripts.length; i += 1) {
  994. type = (scripts[i].getAttribute('type') !== null) ? scripts[i].getAttribute('type') : '';
  995. if (type === '') {
  996. type = (scripts[i].getAttribute('language') !== null) ? scripts[i].getAttribute('language') : '';
  997. }
  998. if (scripts[i].getAttribute('src') !== null && scripts[i].getAttribute('src') !== '') {
  999. childId = id + Math.floor(Math.random() * 99999999999);
  1000. document.getElementById(id).innerHTML += '<div id="' + childId + '"></div>';
  1001. tarteaucitron.makeAsync.getAndParse(scripts[i].getAttribute('src'), childId);
  1002. } else if (type.indexOf('javascript') !== -1 || type === '') {
  1003. eval(scripts[i].innerHTML);
  1004. }
  1005. }
  1006. }
  1007. },
  1008. "fallback": function (matchClass, content, noInner) {
  1009. "use strict";
  1010. var elems = document.getElementsByTagName('*'),
  1011. i,
  1012. index = 0;
  1013. for (i in elems) {
  1014. if (elems[i] !== undefined) {
  1015. for (index = 0; index < matchClass.length; index += 1) {
  1016. if ((' ' + elems[i].className + ' ')
  1017. .indexOf(' ' + matchClass[index] + ' ') > -1) {
  1018. if (typeof content === 'function') {
  1019. if (noInner === true) {
  1020. content(elems[i]);
  1021. } else {
  1022. elems[i].innerHTML = content(elems[i]);
  1023. }
  1024. } else {
  1025. elems[i].innerHTML = content;
  1026. }
  1027. }
  1028. }
  1029. }
  1030. }
  1031. },
  1032. "engage": function (id) {
  1033. "use strict";
  1034. var html = '',
  1035. r = Math.floor(Math.random() * 100000);
  1036. html += '<div class="tac_activate">';
  1037. html += ' <div class="tac_float">';
  1038. html += ' <b>' + tarteaucitron.services[id].name + '</b> ' + tarteaucitron.lang.fallback;
  1039. html += ' <div class="tarteaucitronAllow" id="Eng' + r + 'ed' + id + '" onclick="tarteaucitron.userInterface.respond(this, true);">';
  1040. html += ' &#10003; ' + tarteaucitron.lang.allow;
  1041. html += ' </div>';
  1042. html += ' </div>';
  1043. html += '</div>';
  1044. return html;
  1045. },
  1046. "extend": function (a, b) {
  1047. "use strict";
  1048. var prop;
  1049. for (prop in b) {
  1050. if (b.hasOwnProperty(prop)) {
  1051. a[prop] = b[prop];
  1052. }
  1053. }
  1054. },
  1055. "proTemp": '',
  1056. "proTimer": function () {
  1057. "use strict";
  1058. setTimeout(tarteaucitron.proPing, 1000);
  1059. },
  1060. "pro": function (list) {
  1061. "use strict";
  1062. tarteaucitron.proTemp += list;
  1063. clearTimeout(tarteaucitron.proTimer);
  1064. tarteaucitron.proTimer = setTimeout(tarteaucitron.proPing, 2500);
  1065. },
  1066. "proPing": function () {
  1067. "use strict";
  1068. if (tarteaucitron.uuid !== '' && tarteaucitron.uuid !== undefined && tarteaucitron.proTemp !== '') {
  1069. var div = document.getElementById('tarteaucitronPremium'),
  1070. timestamp = new Date().getTime(),
  1071. url = '//opt-out.ferank.eu/premium.php?';
  1072. if (div === null) {
  1073. return;
  1074. }
  1075. url += 'domain=' + tarteaucitron.domain + '&';
  1076. url += 'uuid=' + tarteaucitron.uuid + '&';
  1077. url += 'c=' + encodeURIComponent(tarteaucitron.proTemp) + '&';
  1078. url += '_' + timestamp;
  1079. div.innerHTML = '<img src="' + url + '" style="display:none" />';
  1080. tarteaucitron.proTemp = '';
  1081. }
  1082. tarteaucitron.cookie.number();
  1083. }
  1084. };