legal.js 1.1 KB

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