tarteaucitron.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. /*jslint browser: 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. var tarteaucitron = {
  8. "cdn": cdn,
  9. "user": {},
  10. "lang": {},
  11. "services": {},
  12. "state": [],
  13. "launch": [],
  14. "init": function (params) {
  15. "use strict";
  16. if (alreadyLaunch === 0) {
  17. alreadyLaunch = 1;
  18. if (window.addEventListener) {
  19. window.addEventListener("load", tarteaucitron.load(params), false);
  20. } else {
  21. window.attachEvent('onload', tarteaucitron.load(params));
  22. }
  23. }
  24. },
  25. "load": function (params) {
  26. "use strict";
  27. var cdn = tarteaucitron.cdn,
  28. language = tarteaucitron.getLanguage(),
  29. pathToLang = cdn + 'lang/tarteaucitron.' + language + '.js',
  30. pathToServices = cdn + 'tarteaucitron.services.js',
  31. linkElement = document.createElement('link'),
  32. defaults = {
  33. "hashtag": '#tarteaucitron',
  34. "highPrivacy": false,
  35. "orientation": "top",
  36. "removeCredit": false,
  37. "showAlertSmall": true
  38. };
  39. // Step 0: get params
  40. if (params !== undefined) {
  41. tarteaucitron.extend(defaults, params);
  42. }
  43. // the hashtag need to be global
  44. tarteaucitron.hashtag = defaults.hashtag;
  45. // Step 1: load css
  46. linkElement.rel = 'stylesheet';
  47. linkElement.type = 'text/css';
  48. linkElement.href = cdn + 'css/tarteaucitron.css';
  49. document.getElementsByTagName('head')[0].appendChild(linkElement);
  50. // Step 2: load language and services
  51. tarteaucitron.addScript(pathToLang, '', function () {
  52. tarteaucitron.addScript(pathToServices, '', function () {
  53. var body = document.body,
  54. div = document.createElement('div'),
  55. hostname = document.location.hostname,
  56. hostRef = document.referrer.split('/')[2],
  57. isNavigating = (hostRef === hostname) ? true : false,
  58. isAutostart,
  59. isDenied,
  60. isAllowed,
  61. isResponded,
  62. cookie = tarteaucitron.cookie.read(),
  63. s = tarteaucitron.services,
  64. service,
  65. html = '',
  66. lastTitle,
  67. alert = false,
  68. index,
  69. orientation = 'Top';
  70. // dedup, clean and sort job[]
  71. function cleanArray(arr) {
  72. var i,
  73. len = arr.length,
  74. out = [],
  75. obj = {};
  76. for (i = 0; i < len; i += 1) {
  77. if (!obj[arr[i]]) {
  78. obj[arr[i]] = {};
  79. if (tarteaucitron.services[arr[i]] !== undefined) {
  80. out.push(arr[i]);
  81. }
  82. }
  83. }
  84. return out;
  85. }
  86. tarteaucitron.job = cleanArray(tarteaucitron.job);
  87. tarteaucitron.job = tarteaucitron.job.sort(function (a, b) {
  88. if (s[a].type + s[a].key > s[b].type + s[b].key) { return 1; }
  89. if (s[a].type + s[a].key < s[b].type + s[b].key) { return -1; }
  90. return 0;
  91. });
  92. // Step 3: prepare the html
  93. html += '<div id="tarteaucitronPremium"></div>';
  94. html += '<div id="tarteaucitronBack" onclick="tarteaucitron.userInterface.closePanel();"></div>';
  95. html += '<div id="tarteaucitron">';
  96. html += ' <div id="tarteaucitronClosePanel" onclick="tarteaucitron.userInterface.closePanel();">';
  97. html += ' ' + tarteaucitron.lang.close;
  98. html += ' </div>';
  99. html += ' <div id="tarteaucitronInfo">';
  100. html += ' ' + tarteaucitron.lang.info;
  101. html += ' <div id="tarteaucitronDisclaimer">';
  102. html += ' ' + tarteaucitron.lang.disclaimer;
  103. html += ' </div>';
  104. html += ' </div>';
  105. html += ' <div id="tarteaucitronServices">';
  106. html += '<div class="tarteaucitronLine tarteaucitronMainLine">';
  107. html += ' <div class="tarteaucitronName">';
  108. html += ' <b>' + tarteaucitron.lang.all + '</b>';
  109. html += ' </div>';
  110. html += ' <div class="tarteaucitronAsk">';
  111. html += ' <div id="tarteaucitronAllAllowed" class="tarteaucitronAllow" onclick="tarteaucitron.userInterface.respondAll(true);">';
  112. html += ' ' + tarteaucitron.lang.allow;
  113. html += ' </div> ';
  114. html += ' <div id="tarteaucitronAllDenied" class="tarteaucitronDeny" onclick="tarteaucitron.userInterface.respondAll(false);">';
  115. html += ' ' + tarteaucitron.lang.deny;
  116. html += ' </div>';
  117. html += ' </div>';
  118. html += '</div>';
  119. html += '<div class="clear"></div>';
  120. for (index = 0; index < tarteaucitron.job.length; index += 1) {
  121. service = s[tarteaucitron.job[index]];
  122. if (lastTitle !== service.type) {
  123. html += '<div class="tarteaucitronTitle">';
  124. html += ' ' + tarteaucitron.lang[service.type].title;
  125. html += ' <div class="tarteaucitronDetails">';
  126. html += ' ' + tarteaucitron.lang[service.type].details;
  127. html += ' </div>';
  128. html += '</div>';
  129. lastTitle = service.type;
  130. }
  131. html += '<div id="' + service.key + 'Line" class="tarteaucitronLine">';
  132. html += ' <div class="tarteaucitronName">';
  133. html += ' <b>' + service.name + '</b><br/>';
  134. html += ' <span id="tacCL' + service.key + '" class="tarteaucitronListCookies"></span><br/>';
  135. html += ' <a href="https://opt-out.ferank.eu/service/' + service.key + '" target="_blank">';
  136. html += ' ' + tarteaucitron.lang.more;
  137. html += ' </a>';
  138. html += ' </div>';
  139. html += ' <div class="tarteaucitronAsk">';
  140. html += ' <div id="' + service.key + 'Allowed" class="tarteaucitronAllow" onclick="tarteaucitron.userInterface.respond(this, true);">';
  141. html += ' ' + tarteaucitron.lang.allow;
  142. html += ' </div> ';
  143. html += ' <div id="' + service.key + 'Denied" class="tarteaucitronDeny" onclick="tarteaucitron.userInterface.respond(this, false);">';
  144. html += ' ' + tarteaucitron.lang.deny;
  145. html += ' </div>';
  146. html += ' </div>';
  147. html += '</div>';
  148. html += '<div class="clear"></div>';
  149. }
  150. html += ' </div>';
  151. if (defaults.removeCredit === false) {
  152. html += ' <div id="tarteaucitronFooter">';
  153. html += ' <a href="https://opt-out.ferank.eu/" rel="nofollow" target="_blank">' + tarteaucitron.lang.credit + '</a>';
  154. html += ' </div>';
  155. }
  156. html += '</div>';
  157. // get the banner orientation
  158. if (defaults.orientation === 'bottom') {
  159. orientation = 'Bottom';
  160. }
  161. if (defaults.highPrivacy) {
  162. html += '<div id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + '">';
  163. html += ' <span id="tarteaucitronDisclaimerAlert">';
  164. html += ' ' + tarteaucitron.lang.alertBigPrivacy;
  165. html += ' </span>';
  166. html += ' <span id="tarteaucitronPersonalize" onclick="tarteaucitron.userInterface.openPanel();">';
  167. html += ' ' + tarteaucitron.lang.personalize;
  168. html += ' </span>';
  169. html += '</div>';
  170. } else {
  171. html += '<div id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + '">';
  172. html += ' <span id="tarteaucitronDisclaimerAlert">';
  173. html += ' ' + tarteaucitron.lang.alertBig;
  174. html += ' </span>';
  175. html += ' <span id="tarteaucitronPersonalize" onclick="tarteaucitron.userInterface.respondAll(true);">';
  176. html += ' ' + tarteaucitron.lang.acceptAll;
  177. html += ' </span>';
  178. html += ' <span id="tarteaucitronCloseAlert" onclick="tarteaucitron.userInterface.openPanel();">';
  179. html += ' ' + tarteaucitron.lang.personalize;
  180. html += ' </span>';
  181. html += '</div>';
  182. }
  183. if (defaults.showAlertSmall === true) {
  184. html += '<div id="tarteaucitronAlertSmall" onclick="tarteaucitron.userInterface.openPanel();">';
  185. html += ' ' + tarteaucitron.lang.alertSmall;
  186. html += ' <div id="tarteaucitronDot">';
  187. html += ' <span id="tarteaucitronDotGreen"></span>';
  188. html += ' <span id="tarteaucitronDotYellow"></span>';
  189. html += ' <span id="tarteaucitronDotRed"></span>';
  190. html += ' </div>';
  191. html += '</div>';
  192. }
  193. div.id = 'tarteaucitronRoot';
  194. body.appendChild(div, body);
  195. div.innerHTML = html;
  196. // Step 4: load services
  197. for (index = 0; index < tarteaucitron.job.length; index += 1) {
  198. service = s[tarteaucitron.job[index]];
  199. isAutostart = (!service.needConsent) ? true : false;
  200. isDenied = (cookie.indexOf(service.key + '=false') >= 0) ? true : false;
  201. isAllowed = (cookie.indexOf(service.key + '=true') >= 0) ? true : false;
  202. isResponded = (cookie.indexOf(service.key) >= 0) ? true : false;
  203. // allow by default for non EU
  204. if (isResponded === false && tarteaucitron.user.bypass === true) {
  205. isAllowed = true;
  206. tarteaucitron.cookie.create(service.key, true);
  207. }
  208. if ((!isResponded && (isAutostart || isNavigating) && !defaults.highPrivacy) || isAllowed) {
  209. if (!isAllowed) {
  210. tarteaucitron.cookie.create(service.key, true);
  211. }
  212. if (tarteaucitron.launch[service.key] !== true) {
  213. tarteaucitron.launch[service.key] = true;
  214. service.js();
  215. }
  216. tarteaucitron.state[service.key] = true;
  217. tarteaucitron.userInterface.color(service.key, true);
  218. } else if (isDenied) {
  219. if (typeof service.fallback === 'function') {
  220. service.fallback();
  221. }
  222. tarteaucitron.state[service.key] = false;
  223. tarteaucitron.userInterface.color(service.key, false);
  224. } else if (!isResponded) {
  225. if (typeof service.fallback === 'function') {
  226. service.fallback();
  227. }
  228. }
  229. if (tarteaucitron.state[service.key] === undefined && !alert) {
  230. alert = true;
  231. }
  232. tarteaucitron.cookie.checkCount(service.key);
  233. }
  234. // Step 5: display the alert
  235. if (alert) {
  236. tarteaucitron.userInterface.openAlert();
  237. } else {
  238. tarteaucitron.userInterface.closeAlert();
  239. }
  240. if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
  241. tarteaucitron.userInterface.openPanel();
  242. }
  243. });
  244. });
  245. },
  246. "userInterface": {
  247. "css": function (id, property, value) {
  248. "use strict";
  249. if (document.getElementById(id) !== null) {
  250. document.getElementById(id).style[property] = value;
  251. }
  252. },
  253. "respondAll": function (status) {
  254. "use strict";
  255. var s = tarteaucitron.services,
  256. service,
  257. key,
  258. index = 0;
  259. for (index = 0; index < tarteaucitron.job.length; index += 1) {
  260. service = s[tarteaucitron.job[index]];
  261. key = service.key;
  262. if (tarteaucitron.launch[key] !== true && status === true) {
  263. tarteaucitron.launch[key] = true;
  264. tarteaucitron.services[key].js();
  265. }
  266. tarteaucitron.state[key] = status;
  267. tarteaucitron.cookie.create(key, status);
  268. tarteaucitron.userInterface.color(key, status);
  269. }
  270. },
  271. "respond": function (el, status) {
  272. "use strict";
  273. var key = el.id.replace(new RegExp("(Eng[0-9]+|Allow|Deni)ed", "g"), '');
  274. // return if same state
  275. if (tarteaucitron.state[key] === status) {
  276. return;
  277. }
  278. // if not already launched... launch the service
  279. if (status === true) {
  280. if (tarteaucitron.launch[key] !== true) {
  281. tarteaucitron.launch[key] = true;
  282. tarteaucitron.services[key].js();
  283. }
  284. }
  285. tarteaucitron.state[key] = status;
  286. tarteaucitron.cookie.create(key, status);
  287. tarteaucitron.userInterface.color(key, status);
  288. },
  289. "color": function (key, status) {
  290. "use strict";
  291. var gray = '#808080',
  292. greenDark = '#1B870B',
  293. greenLight = '#E6FFE2',
  294. redDark = '#9C1A1A',
  295. redLight = '#FFE2E2',
  296. yellowDark = '#FBDA26',
  297. c = 'tarteaucitron',
  298. nbDenied = 0,
  299. nbPending = 0,
  300. nbAllowed = 0,
  301. sum = tarteaucitron.job.length,
  302. index;
  303. if (status === true) {
  304. tarteaucitron.userInterface.css(key + 'Line', 'borderLeft', '5px solid ' + greenDark);
  305. tarteaucitron.userInterface.css(key + 'Allowed', 'backgroundColor', greenDark);
  306. tarteaucitron.userInterface.css(key + 'Denied', 'backgroundColor', gray);
  307. } else if (status === false) {
  308. tarteaucitron.userInterface.css(key + 'Line', 'borderLeft', '5px solid ' + redDark);
  309. tarteaucitron.userInterface.css(key + 'Allowed', 'backgroundColor', gray);
  310. tarteaucitron.userInterface.css(key + 'Denied', 'backgroundColor', redDark);
  311. }
  312. // check if all services are allowed
  313. for (index = 0; index < sum; index += 1) {
  314. if (tarteaucitron.state[tarteaucitron.job[index]] === false) {
  315. nbDenied += 1;
  316. } else if (tarteaucitron.state[tarteaucitron.job[index]] === undefined) {
  317. nbPending += 1;
  318. } else if (tarteaucitron.state[tarteaucitron.job[index]] === true) {
  319. nbAllowed += 1;
  320. }
  321. }
  322. tarteaucitron.userInterface.css(c + 'DotGreen', 'width', ((100 / sum) * nbAllowed) + '%');
  323. tarteaucitron.userInterface.css(c + 'DotYellow', 'width', ((100 / sum) * nbPending) + '%');
  324. tarteaucitron.userInterface.css(c + 'DotRed', 'width', ((100 / sum) * nbDenied) + '%');
  325. if (nbDenied === 0 && nbPending === 0) {
  326. tarteaucitron.userInterface.css(c + 'AllAllowed', 'backgroundColor', greenDark);
  327. tarteaucitron.userInterface.css(c + 'AllDenied', 'backgroundColor', gray);
  328. } else if (nbAllowed === 0 && nbPending === 0) {
  329. tarteaucitron.userInterface.css(c + 'AllAllowed', 'backgroundColor', gray);
  330. tarteaucitron.userInterface.css(c + 'AllDenied', 'backgroundColor', redDark);
  331. } else {
  332. tarteaucitron.userInterface.css(c + 'AllAllowed', 'backgroundColor', gray);
  333. tarteaucitron.userInterface.css(c + 'AllDenied', 'backgroundColor', gray);
  334. }
  335. // close the alert if all service have been reviewed
  336. if (nbPending === 0) {
  337. tarteaucitron.userInterface.closeAlert();
  338. }
  339. if (tarteaucitron.services[key].cookies.length > 0 && status === false) {
  340. tarteaucitron.cookie.purge(tarteaucitron.services[key].cookies);
  341. }
  342. if (status === true) {
  343. document.getElementById('tacCL' + key).innerHTML = '...';
  344. setTimeout(function () {
  345. tarteaucitron.cookie.checkCount(key);
  346. }, 2500);
  347. } else {
  348. tarteaucitron.cookie.checkCount(key);
  349. }
  350. },
  351. "openPanel": function () {
  352. "use strict";
  353. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'block');
  354. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
  355. // setting hash tag
  356. if (tarteaucitron.hashtag !== '') {
  357. document.location.hash = tarteaucitron.hashtag;
  358. }
  359. },
  360. "closePanel": function () {
  361. "use strict";
  362. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  363. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
  364. },
  365. "openAlert": function () {
  366. "use strict";
  367. var c = 'tarteaucitron';
  368. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'none');
  369. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'block');
  370. },
  371. "closeAlert": function () {
  372. "use strict";
  373. var c = 'tarteaucitron';
  374. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'block');
  375. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'none');
  376. }
  377. },
  378. "cookie": {
  379. "create": function (key, status) {
  380. "use strict";
  381. var d = new Date(),
  382. time = d.getTime(),
  383. expireTime = time + 31536000000, // 365 days
  384. regex = new RegExp("!" + key + "=(true|false)", "g"),
  385. cookie = tarteaucitron.cookie.read().replace(regex, ""),
  386. value = 'tarteaucitron=' + cookie + '!' + key + '=' + status;
  387. if (tarteaucitron.cookie.read().indexOf(key + '=' + status) === -1) {
  388. tarteaucitron.pro('!' + key + '=' + status);
  389. }
  390. d.setTime(expireTime);
  391. document.cookie = value + '; expires=' + d.toGMTString() + '; path=/;';
  392. },
  393. "read": function () {
  394. "use strict";
  395. var nameEQ = "tarteaucitron=",
  396. ca = document.cookie.split(';'),
  397. i,
  398. c;
  399. for (i = 0; i < ca.length; i += 1) {
  400. c = ca[i];
  401. while (c.charAt(0) === ' ') {
  402. c = c.substring(1, c.length);
  403. }
  404. if (c.indexOf(nameEQ) === 0) {
  405. return c.substring(nameEQ.length, c.length);
  406. }
  407. }
  408. return '';
  409. },
  410. "purge": function (arr) {
  411. "use strict";
  412. var i;
  413. for (i = 0; i < arr.length; i += 1) {
  414. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/;';
  415. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname + ';';
  416. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname.split('.').slice(-2).join('.') + ';';
  417. }
  418. },
  419. "checkCount": function (key) {
  420. "use strict";
  421. var arr = tarteaucitron.services[key].cookies,
  422. nb = arr.length,
  423. nbCurrent = 0,
  424. html = '',
  425. i,
  426. status = document.cookie.indexOf(key + '=true');
  427. if (status >= 0 && nb === 0) {
  428. html += tarteaucitron.lang.useNoCookie;
  429. } else if (status >= 0) {
  430. for (i = 0; i < nb; i += 1) {
  431. if (document.cookie.indexOf(arr[i] + '=') !== -1) {
  432. nbCurrent += 1;
  433. }
  434. }
  435. if (nbCurrent > 0) {
  436. html += tarteaucitron.lang.useCookieCurrent + ' ' + nbCurrent + ' cookie';
  437. if (nbCurrent > 1) {
  438. html += 's';
  439. }
  440. html += '.';
  441. } else {
  442. html += tarteaucitron.lang.useNoCookie;
  443. }
  444. } else if (nb === 0) {
  445. html = tarteaucitron.lang.noCookie;
  446. } else {
  447. html += tarteaucitron.lang.useCookie + ' ' + nb + ' cookie';
  448. if (nb > 1) {
  449. html += 's';
  450. }
  451. html += '.';
  452. }
  453. document.getElementById('tacCL' + key).innerHTML = html;
  454. }
  455. },
  456. "getLanguage": function () {
  457. "use strict";
  458. if (!navigator) { return 'en'; }
  459. var availableLanguages = 'en,fr',
  460. defaultLanguage = 'en',
  461. lang = navigator.language || navigator.browserLanguage ||
  462. navigator.systemLanguage || navigator.userLang || null,
  463. userLanguage = lang.substr(0, 2);
  464. if (availableLanguages.indexOf(userLanguage) === -1) {
  465. return defaultLanguage;
  466. }
  467. return userLanguage;
  468. },
  469. "getLocale": function () {
  470. "use strict";
  471. if (!navigator) { return 'en_US'; }
  472. var lang = navigator.language || navigator.browserLanguage ||
  473. navigator.systemLanguage || navigator.userLang || null,
  474. userLanguage = lang.substr(0, 2);
  475. if (userLanguage === 'fr') {
  476. return 'fr_FR';
  477. } else if (userLanguage === 'en') {
  478. return 'en_US';
  479. } else if (userLanguage === 'de') {
  480. return 'de_DE';
  481. } else if (userLanguage === 'es') {
  482. return 'es_ES';
  483. } else if (userLanguage === 'it') {
  484. return 'it_IT';
  485. } else if (userLanguage === 'pt') {
  486. return 'pt_PT';
  487. } else {
  488. return 'en_US';
  489. }
  490. },
  491. "addScript": function (url, id, callback) {
  492. "use strict";
  493. var script = document.createElement('script'),
  494. done = false;
  495. script.type = 'text/javascript';
  496. script.id = (id !== undefined) ? id : '';
  497. script.async = true;
  498. script.src = url;
  499. if (typeof callback === 'function') {
  500. script.onreadystatechange = script.onload = function () {
  501. var state = script.readyState;
  502. if (!done && (!state || /loaded|complete/.test(state))) {
  503. done = true;
  504. callback();
  505. }
  506. };
  507. }
  508. document.getElementsByTagName('head')[0].appendChild(script);
  509. },
  510. "fallback": function (matchClass, content) {
  511. "use strict";
  512. var elems = document.getElementsByTagName('*'),
  513. i,
  514. index = 0;
  515. for (i in elems) {
  516. if (elems[i] !== undefined) {
  517. for (index = 0; index < matchClass.length; index += 1) {
  518. if ((' ' + elems[i].className + ' ')
  519. .indexOf(' ' + matchClass[index] + ' ') > -1) {
  520. if (typeof content === 'function') {
  521. elems[i].innerHTML = content(elems[i]);
  522. } else {
  523. elems[i].innerHTML = content;
  524. }
  525. }
  526. }
  527. }
  528. }
  529. },
  530. "engage": function (id) {
  531. "use strict";
  532. var html = '',
  533. r = Math.floor(Math.random() * 100000);
  534. html += '<div class="tac_activate">';
  535. html += ' <div class="tac_float">';
  536. html += ' <b>' + id + '</b> ' + tarteaucitron.lang.fallback + '<br/>';
  537. html += ' <div class="tarteaucitronAllow" id="Eng' + r + 'ed' + id + '" onclick="tarteaucitron.userInterface.respond(this, true);">';
  538. html += ' ' + tarteaucitron.lang.allow;
  539. html += ' </div>';
  540. html += ' </div>';
  541. html += '</div>';
  542. return html;
  543. },
  544. "extend": function (a, b) {
  545. "use strict";
  546. var prop;
  547. for (prop in b) {
  548. if (b.hasOwnProperty(prop)) {
  549. a[prop] = b[prop];
  550. }
  551. }
  552. },
  553. "proTemp": '',
  554. "proTimer": function () {
  555. "use strict";
  556. setTimeout(tarteaucitron.proPing, 1000);
  557. },
  558. "pro": function (list) {
  559. "use strict";
  560. tarteaucitron.proTemp += list;
  561. clearTimeout(tarteaucitron.proTimer);
  562. tarteaucitron.proTimer = setTimeout(tarteaucitron.proPing, 2500);
  563. },
  564. "proPing": function () {
  565. "use strict";
  566. if (tarteaucitron.uuid !== '' && tarteaucitron.uuid !== undefined && tarteaucitron.proTemp !== '') {
  567. var div = document.getElementById('tarteaucitronPremium'),
  568. timestamp = new Date().getTime(),
  569. url = '//opt-out.ferank.eu/premium.php?';
  570. url += 'domain=' + tarteaucitron.domain + '&';
  571. url += 'uuid=' + tarteaucitron.uuid + '&';
  572. url += 'c=' + encodeURIComponent(tarteaucitron.proTemp) + '&';
  573. url += '_' + timestamp;
  574. div.innerHTML = '<img src="' + url + '" style="display:none" />';
  575. tarteaucitron.proTemp = '';
  576. }
  577. }
  578. };