tarteaucitron.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  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="' + service.uri + '" target="_blank">';
  136. html += ' ' + tarteaucitron.lang.more + ' : ' + service.uri.split('/')[2];
  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. }
  233. // Step 5: display the alert
  234. if (alert) {
  235. tarteaucitron.userInterface.openAlert();
  236. } else {
  237. tarteaucitron.userInterface.closeAlert();
  238. }
  239. if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
  240. tarteaucitron.userInterface.openPanel();
  241. }
  242. });
  243. });
  244. },
  245. "userInterface": {
  246. "css": function (id, property, value) {
  247. "use strict";
  248. if (document.getElementById(id) !== null) {
  249. document.getElementById(id).style[property] = value;
  250. }
  251. },
  252. "respondAll": function (status) {
  253. "use strict";
  254. var s = tarteaucitron.services,
  255. service,
  256. key,
  257. index = 0;
  258. for (index = 0; index < tarteaucitron.job.length; index += 1) {
  259. service = s[tarteaucitron.job[index]];
  260. key = service.key;
  261. if (tarteaucitron.launch[key] !== true && status === true) {
  262. tarteaucitron.launch[key] = true;
  263. tarteaucitron.services[key].js();
  264. }
  265. tarteaucitron.state[key] = status;
  266. tarteaucitron.cookie.create(key, status);
  267. tarteaucitron.userInterface.color(key, status);
  268. }
  269. },
  270. "respond": function (el, status) {
  271. "use strict";
  272. var key = el.id.replace(new RegExp("(Eng[0-9]+|Allow|Deni)ed", "g"), '');
  273. // return if same state
  274. if (tarteaucitron.state[key] === status) {
  275. return;
  276. }
  277. // if not already launched... launch the service
  278. if (status === true) {
  279. if (tarteaucitron.launch[key] !== true) {
  280. tarteaucitron.launch[key] = true;
  281. tarteaucitron.services[key].js();
  282. }
  283. }
  284. tarteaucitron.state[key] = status;
  285. tarteaucitron.cookie.create(key, status);
  286. tarteaucitron.userInterface.color(key, status);
  287. },
  288. "color": function (key, status) {
  289. "use strict";
  290. var gray = '#808080',
  291. greenDark = '#1B870B',
  292. greenLight = '#E6FFE2',
  293. redDark = '#9C1A1A',
  294. redLight = '#FFE2E2',
  295. yellowDark = '#FBDA26',
  296. c = 'tarteaucitron',
  297. nbDenied = 0,
  298. nbPending = 0,
  299. nbAllowed = 0,
  300. sum = tarteaucitron.job.length,
  301. index;
  302. if (status === true) {
  303. tarteaucitron.userInterface.css(key + 'Line', 'borderLeft', '5px solid ' + greenDark);
  304. tarteaucitron.userInterface.css(key + 'Allowed', 'backgroundColor', greenDark);
  305. tarteaucitron.userInterface.css(key + 'Denied', 'backgroundColor', gray);
  306. } else if (status === false) {
  307. tarteaucitron.userInterface.css(key + 'Line', 'borderLeft', '5px solid ' + redDark);
  308. tarteaucitron.userInterface.css(key + 'Allowed', 'backgroundColor', gray);
  309. tarteaucitron.userInterface.css(key + 'Denied', 'backgroundColor', redDark);
  310. }
  311. // check if all services are allowed
  312. for (index = 0; index < sum; index += 1) {
  313. if (tarteaucitron.state[tarteaucitron.job[index]] === false) {
  314. nbDenied += 1;
  315. } else if (tarteaucitron.state[tarteaucitron.job[index]] === undefined) {
  316. nbPending += 1;
  317. } else if (tarteaucitron.state[tarteaucitron.job[index]] === true) {
  318. nbAllowed += 1;
  319. }
  320. }
  321. tarteaucitron.userInterface.css(c + 'DotGreen', 'width', ((100 / sum) * nbAllowed) + '%');
  322. tarteaucitron.userInterface.css(c + 'DotYellow', 'width', ((100 / sum) * nbPending) + '%');
  323. tarteaucitron.userInterface.css(c + 'DotRed', 'width', ((100 / sum) * nbDenied) + '%');
  324. if (nbDenied === 0 && nbPending === 0) {
  325. tarteaucitron.userInterface.css(c + 'AllAllowed', 'backgroundColor', greenDark);
  326. tarteaucitron.userInterface.css(c + 'AllDenied', 'backgroundColor', gray);
  327. } else if (nbAllowed === 0 && nbPending === 0) {
  328. tarteaucitron.userInterface.css(c + 'AllAllowed', 'backgroundColor', gray);
  329. tarteaucitron.userInterface.css(c + 'AllDenied', 'backgroundColor', redDark);
  330. } else {
  331. tarteaucitron.userInterface.css(c + 'AllAllowed', 'backgroundColor', gray);
  332. tarteaucitron.userInterface.css(c + 'AllDenied', 'backgroundColor', gray);
  333. }
  334. // close the alert if all service have been reviewed
  335. if (nbPending === 0) {
  336. tarteaucitron.userInterface.closeAlert();
  337. }
  338. if (tarteaucitron.services[key].cookies.length > 0 && status === false) {
  339. tarteaucitron.cookie.purge(tarteaucitron.services[key].cookies);
  340. }
  341. if (status === true) {
  342. document.getElementById('tacCL' + key).innerHTML = '...';
  343. setTimeout(function () {
  344. tarteaucitron.cookie.checkCount(key);
  345. }, 2500);
  346. } else {
  347. tarteaucitron.cookie.checkCount(key);
  348. }
  349. },
  350. "openPanel": function () {
  351. "use strict";
  352. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'block');
  353. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
  354. // setting hash tag
  355. if (tarteaucitron.hashtag !== '') {
  356. document.location.hash = tarteaucitron.hashtag;
  357. }
  358. },
  359. "closePanel": function () {
  360. "use strict";
  361. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  362. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
  363. },
  364. "openAlert": function () {
  365. "use strict";
  366. var c = 'tarteaucitron';
  367. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'none');
  368. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'block');
  369. },
  370. "closeAlert": function () {
  371. "use strict";
  372. var c = 'tarteaucitron';
  373. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'block');
  374. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'none');
  375. }
  376. },
  377. "cookie": {
  378. "create": function (key, status) {
  379. "use strict";
  380. var d = new Date(),
  381. time = d.getTime(),
  382. expireTime = time + 31536000000, // 365 days
  383. regex = new RegExp("!" + key + "=(true|false)", "g"),
  384. cookie = tarteaucitron.cookie.read().replace(regex, ""),
  385. value = 'tarteaucitron=' + cookie + '!' + key + '=' + status;
  386. if (tarteaucitron.cookie.read().indexOf(key + '=' + status) === -1) {
  387. tarteaucitron.pro('!' + key + '=' + status);
  388. }
  389. d.setTime(expireTime);
  390. document.cookie = value + '; expires=' + d.toGMTString() + '; path=/;';
  391. },
  392. "read": function () {
  393. "use strict";
  394. var nameEQ = "tarteaucitron=",
  395. ca = document.cookie.split(';'),
  396. i,
  397. c;
  398. for (i = 0; i < ca.length; i += 1) {
  399. c = ca[i];
  400. while (c.charAt(0) === ' ') {
  401. c = c.substring(1, c.length);
  402. }
  403. if (c.indexOf(nameEQ) === 0) {
  404. return c.substring(nameEQ.length, c.length);
  405. }
  406. }
  407. return '';
  408. },
  409. "purge": function (arr) {
  410. "use strict";
  411. var i;
  412. for (i = 0; i < arr.length; i += 1) {
  413. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/;';
  414. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname + ';';
  415. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname.split('.').slice(-2).join('.') + ';';
  416. }
  417. },
  418. "checkCount": function (key) {
  419. "use strict";
  420. var arr = tarteaucitron.services[key].cookies,
  421. nb = arr.length,
  422. nbCurrent = 0,
  423. html = '',
  424. i,
  425. status = document.cookie.indexOf(key + '=true');
  426. if (status >= 0 && nb === 0) {
  427. html += tarteaucitron.lang.useNoCookie;
  428. } else if (status >= 0) {
  429. for (i = 0; i < nb; i += 1) {
  430. if (document.cookie.indexOf(arr[i] + '=') !== -1) {
  431. nbCurrent += 1;
  432. }
  433. }
  434. if (nbCurrent > 0) {
  435. html += tarteaucitron.lang.useCookieCurrent + ' ' + nbCurrent + ' cookie';
  436. if (nbCurrent > 1) {
  437. html += 's';
  438. }
  439. html += '.';
  440. } else {
  441. html += tarteaucitron.lang.useNoCookie;
  442. }
  443. } else if (nb === 0) {
  444. html = tarteaucitron.lang.noCookie;
  445. } else {
  446. html += tarteaucitron.lang.useCookie + ' ' + nb + ' cookie';
  447. if (nb > 1) {
  448. html += 's';
  449. }
  450. html += '.';
  451. }
  452. document.getElementById('tacCL' + key).innerHTML = html;
  453. }
  454. },
  455. "getLanguage": function () {
  456. "use strict";
  457. if (!navigator) { return 'en'; }
  458. var availableLanguages = 'en,fr',
  459. defaultLanguage = 'en',
  460. lang = navigator.language || navigator.browserLanguage ||
  461. navigator.systemLanguage || navigator.userLang || null,
  462. userLanguage = lang.substr(0, 2);
  463. if (availableLanguages.indexOf(userLanguage) === -1) {
  464. return defaultLanguage;
  465. }
  466. return userLanguage;
  467. },
  468. "getLocale": function () {
  469. "use strict";
  470. if (!navigator) { return 'en_US'; }
  471. var lang = navigator.language || navigator.browserLanguage ||
  472. navigator.systemLanguage || navigator.userLang || null,
  473. userLanguage = lang.substr(0, 2);
  474. if (userLanguage === 'fr') {
  475. return 'fr_FR';
  476. } else if (userLanguage === 'en') {
  477. return 'en_US';
  478. } else if (userLanguage === 'de') {
  479. return 'de_DE';
  480. } else if (userLanguage === 'es') {
  481. return 'es_ES';
  482. } else if (userLanguage === 'it') {
  483. return 'it_IT';
  484. } else if (userLanguage === 'pt') {
  485. return 'pt_PT';
  486. } else {
  487. return 'en_US';
  488. }
  489. },
  490. "addScript": function (url, id, callback) {
  491. "use strict";
  492. var script = document.createElement('script'),
  493. done = false;
  494. script.type = 'text/javascript';
  495. script.id = (id !== undefined) ? id : '';
  496. script.async = true;
  497. script.src = url;
  498. if (typeof callback === 'function') {
  499. script.onreadystatechange = script.onload = function () {
  500. var state = script.readyState;
  501. if (!done && (!state || /loaded|complete/.test(state))) {
  502. done = true;
  503. callback();
  504. }
  505. };
  506. }
  507. document.getElementsByTagName('head')[0].appendChild(script);
  508. },
  509. "fallback": function (matchClass, content) {
  510. "use strict";
  511. var elems = document.getElementsByTagName('*'),
  512. i,
  513. index = 0;
  514. for (i in elems) {
  515. if (elems[i] !== undefined) {
  516. for (index = 0; index < matchClass.length; index += 1) {
  517. if ((' ' + elems[i].className + ' ')
  518. .indexOf(' ' + matchClass[index] + ' ') > -1) {
  519. if (typeof content === 'function') {
  520. elems[i].innerHTML = content(elems[i]);
  521. } else {
  522. elems[i].innerHTML = content;
  523. }
  524. }
  525. }
  526. }
  527. }
  528. },
  529. "engage": function (id) {
  530. "use strict";
  531. var html = '',
  532. r = Math.floor(Math.random() * 100000);
  533. html += '<div class="tac_activate">';
  534. html += ' <div class="tac_float">';
  535. html += ' <b>' + id + '</b> ' + tarteaucitron.lang.fallback + '<br/>';
  536. html += ' <div class="tarteaucitronAllow" id="Eng' + r + 'ed' + id + '" onclick="tarteaucitron.userInterface.respond(this, true);">';
  537. html += ' ' + tarteaucitron.lang.allow;
  538. html += ' </div>';
  539. html += ' </div>';
  540. html += '</div>';
  541. return html;
  542. },
  543. "extend": function (a, b) {
  544. "use strict";
  545. var prop;
  546. for (prop in b) {
  547. if (b.hasOwnProperty(prop)) {
  548. a[prop] = b[prop];
  549. }
  550. }
  551. },
  552. "proTemp": '',
  553. "proTimer": function () {
  554. "use strict";
  555. setTimeout(tarteaucitron.proPing, 1000);
  556. },
  557. "pro": function (list) {
  558. "use strict";
  559. tarteaucitron.proTemp += list;
  560. clearTimeout(tarteaucitron.proTimer);
  561. tarteaucitron.proTimer = setTimeout(tarteaucitron.proPing, 2500);
  562. },
  563. "proPing": function () {
  564. "use strict";
  565. if (tarteaucitron.uuid !== '' && tarteaucitron.uuid !== undefined && tarteaucitron.proTemp !== '') {
  566. var div = document.getElementById('tarteaucitronPremium'),
  567. timestamp = new Date().getTime(),
  568. url = '//opt-out.ferank.eu/premium.php?';
  569. url += 'domain=' + tarteaucitron.domain + '&';
  570. url += 'uuid=' + tarteaucitron.uuid + '&';
  571. url += 'c=' + encodeURIComponent(tarteaucitron.proTemp) + '&';
  572. url += '_' + timestamp;
  573. div.innerHTML = '<img src="' + url + '" style="display:none" />';
  574. tarteaucitron.proTemp = '';
  575. }
  576. }
  577. };