blacklist.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. 'use strict';
  2. 'require view';
  3. 'require fs';
  4. 'require ui';
  5. return view.extend({
  6. load: function() {
  7. return L.resolveDefault(fs.read_direct('/etc/adblock/adblock.blacklist'), '');
  8. },
  9. handleSave: function(ev) {
  10. var value = ((document.querySelector('textarea').value || '').trim().toLowerCase().replace(/\r\n/g, '\n')) + '\n';
  11. return fs.write('/etc/adblock/adblock.blacklist', value)
  12. .then(function(rc) {
  13. document.querySelector('textarea').value = value;
  14. ui.addNotification(null, E('p', _('Blacklist changes have been saved. Refresh your adblock lists that changes take effect.')), 'info');
  15. }).catch(function(e) {
  16. ui.addNotification(null, E('p', _('Unable to save changes: %s').format(e.message)));
  17. });
  18. },
  19. render: function(blacklist) {
  20. return E([
  21. E('p', {},
  22. _('This is the local adblock blacklist to always-deny certain (sub) domains.<br /> \
  23. Please note: add only one domain per line. Comments introduced with \'#\' are allowed - ip addresses, wildcards and regex are not.')),
  24. E('p', {},
  25. E('textarea', {
  26. 'style': 'width: 100% !important; padding: 5px; font-family: monospace',
  27. 'spellcheck': 'false',
  28. 'wrap': 'off',
  29. 'rows': 25
  30. }, [ blacklist != null ? blacklist : '' ])
  31. )
  32. ]);
  33. },
  34. handleSaveApply: null,
  35. handleReset: null
  36. });