legal.js 1001 B

12345678910111213141516171819202122232425262728293031323334
  1. const html = require('choo/html');
  2. const raw = require('choo/html/raw');
  3. const title = require('../templates/title');
  4. module.exports = function(state) {
  5. return html`
  6. <main class="main page">
  7. ${title(state)}
  8. <div class="title">${state.translate('legalHeader')}</div>
  9. ${raw(
  10. replaceLinks(state.translate('legalNoticeTestPilot'), [
  11. 'https://testpilot.firefox.com/terms',
  12. 'https://testpilot.firefox.com/privacy',
  13. 'https://testpilot.firefox.com/experiments/send'
  14. ])
  15. )}
  16. ${raw(
  17. replaceLinks(state.translate('legalNoticeMozilla'), [
  18. 'https://www.mozilla.org/privacy/websites/',
  19. 'https://www.mozilla.org/about/legal/terms/mozilla/'
  20. ])
  21. )}
  22. </main>
  23. `;
  24. };
  25. function replaceLinks(str, urls) {
  26. let i = 0;
  27. const s = str.replace(
  28. /<a>([^<]+)<\/a>/g,
  29. (m, v) => `<a href="${urls[i++]}">${v}</a>`
  30. );
  31. return `<div class="description">${s}</div>`;
  32. }