tarteaucitron.js 54 KB

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