diff options
author | Dirk Brenken <dev@brenken.org> | 2021-02-26 21:21:45 +0100 |
---|---|---|
committer | Dirk Brenken <dev@brenken.org> | 2021-02-26 21:21:45 +0100 |
commit | e7d87abcbca5ff5f1999cd1a3b496c31fbd6dca0 (patch) | |
tree | 09732399c906549d12bb5c3191d035fd5229b506 /applications/luci-app-adblock/htdocs/luci-static/resources/view | |
parent | 2b9fca81783feb192206e4b088f322dc0e9b3738 (diff) |
luci-app-adblock: sync with adblock 4.1.0
* made the blocklist selection/categories much more flexible
Signed-off-by: Dirk Brenken <dev@brenken.org>
Diffstat (limited to 'applications/luci-app-adblock/htdocs/luci-static/resources/view')
4 files changed, 250 insertions, 149 deletions
diff --git a/applications/luci-app-adblock/htdocs/luci-static/resources/view/adblock/blacklist.js b/applications/luci-app-adblock/htdocs/luci-static/resources/view/adblock/blacklist.js index 23e346ed7d..1f657651ba 100644 --- a/applications/luci-app-adblock/htdocs/luci-static/resources/view/adblock/blacklist.js +++ b/applications/luci-app-adblock/htdocs/luci-static/resources/view/adblock/blacklist.js @@ -8,7 +8,7 @@ return view.extend({ return L.resolveDefault(fs.read_direct('/etc/adblock/adblock.blacklist'), ''); }, handleSave: function(ev) { - var value = ((document.querySelector('textarea').value || '').trim().toLowerCase().replace(/\r\n/g, '\n').replace(/[^a-z0-9\.\-\#\n]/g, '')) + '\n'; + var value = ((document.querySelector('textarea').value || '').trim().toLowerCase().replace(/\r\n/g, '\n')) + '\n'; return fs.write('/etc/adblock/adblock.blacklist', value) .then(function(rc) { document.querySelector('textarea').value = value; diff --git a/applications/luci-app-adblock/htdocs/luci-static/resources/view/adblock/dnsreport.js b/applications/luci-app-adblock/htdocs/luci-static/resources/view/adblock/dnsreport.js index fdd358038c..1b245ecde6 100644 --- a/applications/luci-app-adblock/htdocs/luci-static/resources/view/adblock/dnsreport.js +++ b/applications/luci-app-adblock/htdocs/luci-static/resources/view/adblock/dnsreport.js @@ -17,7 +17,7 @@ function handleAction(ev) { ]), E('div', { 'class': 'right' }, [ E('button', { - 'class': 'btn', + 'class': 'btn cbi-button', 'click': L.hideModal }, _('Cancel')), ' ', @@ -52,7 +52,7 @@ function handleAction(ev) { ]), E('div', { 'class': 'right' }, [ E('button', { - 'class': 'btn', + 'class': 'btn cbi-button', 'click': L.hideModal }, _('Cancel')), ' ', @@ -104,7 +104,7 @@ function handleAction(ev) { ]), E('div', { 'class': 'right' }, [ E('button', { - 'class': 'btn', + 'class': 'btn cbi-button', 'click': L.hideModal }, _('Cancel')), ' ', @@ -158,7 +158,7 @@ function handleAction(ev) { ]), E('div', { 'class': 'right' }, [ E('button', { - 'class': 'btn', + 'class': 'btn cbi-button', 'click': L.hideModal }, _('Cancel')), ' ', @@ -195,7 +195,7 @@ return view.extend({ render: function(dnsreport) { if (!dnsreport) { - dnsreport = '{ "data": "" }'; + dnsreport = '{}'; }; var content; content = JSON.parse(dnsreport); @@ -213,32 +213,28 @@ return view.extend({ ]); var max = 0; - if (content.data.top_clients && content.data.top_domains && content.data.top_blocked) { - max = Math.max(content.data.top_clients.length, content.data.top_domains.length, content.data.top_blocked.length); + if (content.top_clients && content.top_domains && content.top_blocked) { + max = Math.max(content.top_clients.length, content.top_domains.length, content.top_blocked.length); } for (var i = 0; i < max; i++) { var a_cnt = '\xa0', a_addr = '\xa0', b_cnt = '\xa0', b_addr = '\xa0', c_cnt = '\xa0', c_addr = '\xa0'; - if (content.data.top_clients[i]) { - a_cnt = content.data.top_clients[i].count; + if (content.top_clients[i]) { + a_cnt = content.top_clients[i].count; } - if (content.data.top_clients[i]) { - a_addr = content.data.top_clients[i].address; + if (content.top_clients[i]) { + a_addr = content.top_clients[i].address; } - if (content.data.top_domains[i]) { - b_cnt = content.data.top_domains[i].count; + if (content.top_domains[i]) { + b_cnt = content.top_domains[i].count; } - if (content.data.top_domains[i]) { - //[!CDATA[ - b_addr = '<a href="https://duckduckgo.com/?q=' + encodeURIComponent(content.data.top_domains[i].address) + '&k1=-1&km=l&kh=1" target="_blank" title="Search this domain">' + content.data.top_domains[i].address + '</a>'; - //]]> + if (content.top_domains[i]) { + b_addr = '<a href="https://duckduckgo.com/?q=' + encodeURIComponent(content.top_domains[i].address) + '&k1=-1&km=l&kh=1" target="_blank" rel="noreferrer noopener" title="Domain Lookup">' + content.top_domains[i].address + '</a>'; } - if (content.data.top_blocked[i]) { - c_cnt = content.data.top_blocked[i].count; + if (content.top_blocked[i]) { + c_cnt = content.top_blocked[i].count; } - if (content.data.top_blocked[i]) { - //[!CDATA[ - c_addr = '<a href="https://duckduckgo.com/?q=' + encodeURIComponent(content.data.top_blocked[i].address) + '&k1=-1&km=l&kh=1" target="_blank" title="Search this domain">' + content.data.top_blocked[i].address + '</a>'; - //]]> + if (content.top_blocked[i]) { + c_addr = '<a href="https://duckduckgo.com/?q=' + encodeURIComponent(content.top_blocked[i].address) + '&k1=-1&km=l&kh=1" target="_blank" rel="noreferrer noopener" title="Domain Lookup">' + content.top_blocked[i].address + '</a>'; } rows_top.push([ a_cnt, @@ -264,35 +260,33 @@ return view.extend({ ]); max = 0; - if (content.data.requests) { + if (content.requests) { var button; - max = content.data.requests.length; + max = content.requests.length; for (var i = 0; i < max; i++) { - if (content.data.requests[i].rc === 'NX') { + if (content.requests[i].rc === 'NX') { button = E('button', { - 'class': 'cbi-button cbi-button-apply', + 'class': 'btn cbi-button cbi-button-positive', 'style': 'word-break: inherit', 'name': 'whitelist', - 'value': content.data.requests[i].domain, + 'value': content.requests[i].domain, 'click': handleAction }, [ _('Whitelist...') ]); } else { button = E('button', { - 'class': 'cbi-button cbi-button-apply', + 'class': 'btn cbi-button cbi-button-negative', 'style': 'word-break: inherit', 'name': 'blacklist', - 'value': content.data.requests[i].domain, + 'value': content.requests[i].domain, 'click': handleAction }, [ _('Blacklist...') ]); } rows_requests.push([ - content.data.requests[i].date, - content.data.requests[i].time, - content.data.requests[i].client, - //[!CDATA[ - '<a href="https://duckduckgo.com/?q=' + encodeURIComponent(content.data.requests[i].domain) + '&k1=-1&km=l&kh=1" target="_blank" title="Search this domain">' + content.data.requests[i].domain + '</a>', - //]]> - content.data.requests[i].rc, + content.requests[i].date, + content.requests[i].time, + content.requests[i].client, + '<a href="https://duckduckgo.com/?q=' + encodeURIComponent(content.requests[i].domain) + '&k1=-1&km=l&kh=1" target="_blank" rel="noreferrer noopener" title="Domain Lookup">' + content.requests[i].domain + '</a>', + content.requests[i].rc, button ]); } @@ -301,30 +295,34 @@ return view.extend({ return E('div', { 'class': 'cbi-map', 'id': 'map' }, [ E('div', { 'class': 'cbi-section' }, [ - E('p', _('This shows the last generated DNS Report, press the refresh button to get a current one.')), + E('p', _('This tab shows the last generated DNS Report, press the \'Refresh\' button to get a current one.')), E('p', '\xa0'), - E('div', { 'class': 'cbi-value', 'style': 'margin-bottom:5px' }, [ - E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Start Timestamp')), - E('div', { 'class': 'cbi-value-field', 'id': 'start', 'style': 'margin-bottom:5px;margin-left:200px;color:#37c' }, (content.data.start_date || '-') + ', ' + (content.data.start_time || '-'))]), - E('div', { 'class': 'cbi-value', 'style': 'margin-bottom:5px' }, [ - E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('End Timestamp')), - E('div', { 'class': 'cbi-value-field', 'id': 'end', 'style': 'margin-bottom:5px;margin-left:200px;color:#37c' }, (content.data.end_date || '-') + ', ' + (content.data.end_time || '-'))]), - E('div', { 'class': 'cbi-value', 'style': 'margin-bottom:5px' }, [ - E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Total DNS Requests')), - E('div', { 'class': 'cbi-value-field', 'id': 'total', 'style': 'margin-bottom:5px;margin-left:200px;color:#37c' }, content.data.total || '-')]), - E('div', { 'class': 'cbi-value', 'style': 'margin-bottom:5px' }, [ - E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Blocked DNS Requests')), - E('div', { 'class': 'cbi-value-field', 'id': 'blocked', 'style': 'margin-bottom:5px;margin-left:200px;color:#37c' }, (content.data.blocked || '-') + ' (' + (content.data.percent || '-') + ')')]), + E('div', { 'class': 'cbi-value' }, [ + E('div', { 'class': 'cbi-value-title', 'style': 'float:left;width:230px' }, _('Start Timestamp')), + E('div', { 'class': 'cbi-value-title', 'id': 'start', 'style': 'float:left;color:#37c' }, (content.start_date || '-') + ', ' + (content.start_time || '-')) + ]), + E('div', { 'class': 'cbi-value' }, [ + E('div', { 'class': 'cbi-value-title', 'style': 'float:left;width:230px' }, _('End Timestamp')), + E('div', { 'class': 'cbi-value-title', 'id': 'end', 'style': 'float:left;color:#37c' }, (content.end_date || '-') + ', ' + (content.end_time || '-')) + ]), + E('div', { 'class': 'cbi-value' }, [ + E('div', { 'class': 'cbi-value-title', 'style': 'float:left;width:230px' }, _('Total DNS Requests')), + E('div', { 'class': 'cbi-value-title', 'id': 'total', 'style': 'float:left;color:#37c' }, content.total || '-') + ]), + E('div', { 'class': 'cbi-value' }, [ + E('div', { 'class': 'cbi-value-title', 'style': 'float:left;width:230px' }, _('Blocked DNS Requests')), + E('div', { 'class': 'cbi-value-title', 'id': 'blocked', 'style': 'float:left;color:#37c' }, (content.blocked || '-') + ' (' + (content.percent || '-') + ')') + ]), E('div', { 'class': 'right' }, [ E('button', { - 'class': 'cbi-button cbi-button-apply', + 'class': 'btn cbi-button cbi-button-apply', 'click': ui.createHandlerFn(this, function() { return handleAction('query'); }) }, [ _('Blocklist Query...') ]), '\xa0\xa0\xa0', E('button', { - 'class': 'cbi-button cbi-button-apply', + 'class': 'btn cbi-button cbi-button-positive', 'click': ui.createHandlerFn(this, function() { return handleAction('refresh'); }) diff --git a/applications/luci-app-adblock/htdocs/luci-static/resources/view/adblock/overview.js b/applications/luci-app-adblock/htdocs/luci-static/resources/view/adblock/overview.js index 146f24a57c..5c6b833141 100644 --- a/applications/luci-app-adblock/htdocs/luci-static/resources/view/adblock/overview.js +++ b/applications/luci-app-adblock/htdocs/luci-static/resources/view/adblock/overview.js @@ -10,7 +10,7 @@ /* button handling */ -async function handleAction(ev) { +function handleAction(ev) { if (ev === 'timer') { L.ui.showModal(_('Refresh Timer'), [ E('p', _('To keep your adblock lists up-to-date, you should setup an automatic update job for these lists.')), @@ -26,7 +26,7 @@ async function handleAction(ev) { ]), E('div', { 'class': 'left', 'style': 'display:flex; flex-direction:column' }, [ E('label', { 'class': 'cbi-input-select', 'style': 'padding-top:.5em' }, [ - E('h5', _('Set/Replace a new adblock job')), + E('h5', _('Set a new adblock job')), E('select', { 'class': 'cbi-input-select', 'id': 'timerA' }, [ E('option', { 'value': 'start' }, 'Start'), E('option', { 'value': 'reload' }, 'Reload'), @@ -52,21 +52,40 @@ async function handleAction(ev) { _('The day of the week (opt., values: 1-7 possibly sep. by , or -)') ]) ]), + E('div', { 'class': 'left', 'style': 'display:flex; flex-direction:column' }, [ + E('label', { 'class': 'cbi-input-select', 'style': 'padding-top:.5em' }, [ + E('h5', _('Remove an existing job')), + E('input', { 'class': 'cbi-input-text', 'id': 'lineno', 'maxlength': '2' }, [ + ]), + '\xa0\xa0\xa0', + _('Line number to remove') + ]) + ]), E('div', { 'class': 'right' }, [ E('button', { - 'class': 'btn', + 'class': 'btn cbi-button', 'click': L.hideModal }, _('Cancel')), ' ', E('button', { 'class': 'btn cbi-button-action', 'click': ui.createHandlerFn(this, function(ev) { + var lineno = document.getElementById('lineno').value; var action = document.getElementById('timerA').value; var hours = document.getElementById('timerH').value; var minutes = document.getElementById('timerM').value || '0'; var days = document.getElementById('timerD').value || '*'; if (hours) { - L.resolveDefault(fs.exec_direct('/etc/init.d/adblock', ['timer', action, hours, minutes, days])) + L.resolveDefault(fs.exec_direct('/etc/init.d/adblock', ['timer', 'add', action, hours, minutes, days])) + .then(function(res) { + if (res) { + ui.addNotification(null, E('p', _('The Refresh Timer could not been updated.')), 'error'); + } else { + ui.addNotification(null, E('p', _('The Refresh Timer has been updated.')), 'info'); + } + }); + } else if (lineno) { + L.resolveDefault(fs.exec_direct('/etc/init.d/adblock', ['timer', 'remove', lineno])) .then(function(res) { if (res) { ui.addNotification(null, E('p', _('The Refresh Timer could not been updated.')), 'error'); @@ -83,7 +102,7 @@ async function handleAction(ev) { }, _('Save')) ]) ]); - L.resolveDefault(fs.read_direct('/etc/crontabs/root'), ' ') + L.resolveDefault(fs.exec_direct('/etc/init.d/adblock', ['timer', 'list'])) .then(function(res) { document.getElementById('cronView').value = res.trim(); }); @@ -91,33 +110,18 @@ async function handleAction(ev) { return } - if (ev === 'suspend') { - if (document.getElementById('status') && document.getElementById('btn_suspend') && document.getElementById('status').textContent.substr(0,6) === 'paused') { - document.querySelector('#btn_suspend').textContent = 'Suspend'; - ev = 'resume'; - } else if (document.getElementById('status') && document.getElementById('btn_suspend')) { - document.querySelector('#btn_suspend').textContent = 'Resume'; - } + if (document.getElementById('status') && document.getElementById('status').textContent.substr(0,6) === 'paused') { + ev = 'resume'; } - poll.start(); fs.exec_direct('/etc/init.d/adblock', [ev]) - var running = 1; - while (running === 1) { - await new Promise(r => setTimeout(r, 1000)); - L.resolveDefault(fs.read_direct('/var/run/adblock.pid')).then(function(res) { - if (!res) { - running = 0; - } - }) - } - poll.stop(); } return view.extend({ load: function() { return Promise.all([ L.resolveDefault(fs.exec_direct('/etc/init.d/adblock', ['list']), {}), + L.resolveDefault(fs.read_direct('/etc/adblock/adblock.categories'), ''), uci.load('adblock') ]); }, @@ -136,15 +140,22 @@ return view.extend({ var info = JSON.parse(res); var status = document.getElementById('status'); if (status && info) { - status.textContent = (info.data.adblock_status || '-') + ' / ' + (info.data.adblock_version || '-'); - if (info.data.adblock_status === "running") { + status.textContent = (info.adblock_status || '-') + ' / ' + (info.adblock_version || '-'); + if (info.adblock_status === "running") { if (!status.classList.contains("spinning")) { status.classList.add("spinning"); } } else { if (status.classList.contains("spinning")) { status.classList.remove("spinning"); - poll.stop(); + if (document.getElementById('btn_suspend')) { + if (status.textContent.substr(0,6) === 'paused') { + document.querySelector('#btn_suspend').textContent = 'Resume'; + } + if (document.getElementById('status').textContent.substr(0,7) === 'enabled') { + document.querySelector('#btn_suspend').textContent = 'Suspend'; + } + } } } if (status.textContent.substr(0,6) === 'paused' && document.getElementById('btn_suspend')) { @@ -158,43 +169,43 @@ return view.extend({ } var domains = document.getElementById('domains'); if (domains && info) { - domains.textContent = parseInt(info.data.blocked_domains, 10).toLocaleString() || '-'; + domains.textContent = parseInt(info.blocked_domains, 10).toLocaleString() || '-'; } var sources = document.getElementById('sources'); var src_array = []; if (sources && info) { - for (var i = 0; i < info.data.active_sources.length; i++) { - if (i < info.data.active_sources.length-1) { - src_array += info.data.active_sources[i].source + ', '; + for (var i = 0; i < info.active_sources.length; i++) { + if (i < info.active_sources.length-1) { + src_array += info.active_sources[i].source + ', '; } else { - src_array += info.data.active_sources[i].source + src_array += info.active_sources[i].source } } sources.textContent = src_array || '-'; } var backend = document.getElementById('backend'); if (backend && info) { - backend.textContent = info.data.dns_backend || '-'; + backend.textContent = info.dns_backend || '-'; } var utils = document.getElementById('utils'); if (utils && info) { - utils.textContent = info.data.run_utils || '-'; + utils.textContent = info.run_utils || '-'; } var ifaces = document.getElementById('ifaces'); if (ifaces && info) { - ifaces.textContent = info.data.run_ifaces || '-'; + ifaces.textContent = info.run_ifaces || '-'; } var dirs = document.getElementById('dirs'); if (dirs && info) { - dirs.textContent = info.data.run_directories || '-'; + dirs.textContent = info.run_directories || '-'; } var flags = document.getElementById('flags'); if (flags && info) { - flags.textContent = info.data.run_flags || '-'; + flags.textContent = info.run_flags || '-'; } var run = document.getElementById('run'); if (run && info) { - run.textContent = info.data.last_run || '-'; + run.textContent = info.last_run || '-'; } }); }, 1); @@ -206,43 +217,52 @@ return view.extend({ s.render = L.bind(function(view, section_id) { return E('div', { 'class': 'cbi-section' }, [ E('h3', _('Information')), - E('div', { 'class': 'cbi-value', 'style': 'margin-bottom:5px' }, [ - E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Status / Version')), - E('div', { 'class': 'cbi-value-field spinning', 'id': 'status', 'style': 'font-weight: bold;margin-bottom:5px;color:#37c' },'\xa0')]), - E('div', { 'class': 'cbi-value', 'style': 'margin-bottom:5px' }, [ - E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Blocked Domains')), - E('div', { 'class': 'cbi-value-field', 'id': 'domains', 'style': 'font-weight: bold;margin-bottom:5px;color:#37c' },'-')]), - E('div', { 'class': 'cbi-value', 'style': 'margin-bottom:5px' }, [ - E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Active Sources')), - E('div', { 'class': 'cbi-value-field', 'id': 'sources', 'style': 'font-weight: bold;margin-bottom:5px;color:#37c' },'-')]), - E('div', { 'class': 'cbi-value', 'style': 'margin-bottom:5px' }, [ - E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('DNS Backend')), - E('div', { 'class': 'cbi-value-field', 'id': 'backend', 'style': 'font-weight: bold;margin-bottom:5px;color:#37c' },'-')]), - E('div', { 'class': 'cbi-value', 'style': 'margin-bottom:5px' }, [ - E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Run Utils')), - E('div', { 'class': 'cbi-value-field', 'id': 'utils', 'style': 'font-weight: bold;margin-bottom:5px;color:#37c' },'-')]), - E('div', { 'class': 'cbi-value', 'style': 'margin-bottom:5px' }, [ - E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Run Interfaces')), - E('div', { 'class': 'cbi-value-field', 'id': 'ifaces', 'style': 'font-weight: bold;margin-bottom:5px;color:#37c' },'-')]), - E('div', { 'class': 'cbi-value', 'style': 'margin-bottom:5px' }, [ - E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Run Directories')), - E('div', { 'class': 'cbi-value-field', 'id': 'dirs', 'style': 'font-weight: bold;margin-bottom:5px;color:#37c' },'-')]), - E('div', { 'class': 'cbi-value', 'style': 'margin-bottom:5px' }, [ - E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Run Flags')), - E('div', { 'class': 'cbi-value-field', 'id': 'flags', 'style': 'font-weight: bold;margin-bottom:5px;color:#37c' },'-')]), - E('div', { 'class': 'cbi-value', 'style': 'margin-bottom:5px' }, [ - E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Last Run')), - E('div', { 'class': 'cbi-value-field', 'id': 'run', 'style': 'font-weight: bold;margin-bottom:5px;color:#37c' },'-')]), + E('div', { 'class': 'cbi-value' }, [ + E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Status / Version')), + E('div', { 'class': 'cbi-value-field spinning', 'id': 'status', 'style': 'color:#37c' },'\xa0') + ]), + E('div', { 'class': 'cbi-value' }, [ + E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Blocked Domains')), + E('div', { 'class': 'cbi-value-field', 'id': 'domains', 'style': 'color:#37c' },'-') + ]), + E('div', { 'class': 'cbi-value' }, [ + E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Active Sources')), + E('div', { 'class': 'cbi-value-field', 'id': 'sources', 'style': 'color:#37c' },'-') + ]), + E('div', { 'class': 'cbi-value' }, [ + E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('DNS Backend')), + E('div', { 'class': 'cbi-value-field', 'id': 'backend', 'style': 'color:#37c' },'-') + ]), + E('div', { 'class': 'cbi-value' }, [ + E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Run Utils')), + E('div', { 'class': 'cbi-value-field', 'id': 'utils', 'style': 'color:#37c' },'-') + ]), + E('div', { 'class': 'cbi-value' }, [ + E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Run Interfaces')), + E('div', { 'class': 'cbi-value-field', 'id': 'ifaces', 'style': 'color:#37c' },'-') + ]), + E('div', { 'class': 'cbi-value' }, [ + E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Run Directories')), + E('div', { 'class': 'cbi-value-field', 'id': 'dirs', 'style': 'color:#37c' },'-') + ]), + E('div', { 'class': 'cbi-value' }, [ + E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Run Flags')), + E('div', { 'class': 'cbi-value-field', 'id': 'flags', 'style': 'color:#37c' },'-') + ]), + E('div', { 'class': 'cbi-value' }, [ + E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Last Run')), + E('div', { 'class': 'cbi-value-field', 'id': 'run', 'style': 'color:#37c' },'-') + ]), E('div', { class: 'right' }, [ E('button', { - 'class': 'cbi-button cbi-button-apply', + 'class': 'btn cbi-button cbi-button-apply', 'click': ui.createHandlerFn(this, function() { return handleAction('timer'); }) }, [ _('Refresh Timer...') ]), '\xa0\xa0\xa0', E('button', { - 'class': 'cbi-button cbi-button-apply', + 'class': 'btn cbi-button cbi-button-apply', 'id': 'btn_suspend', 'click': ui.createHandlerFn(this, function() { return handleAction('suspend'); @@ -250,11 +270,18 @@ return view.extend({ }, [ _('Suspend') ]), '\xa0\xa0\xa0', E('button', { - 'class': 'cbi-button cbi-button-apply', + 'class': 'btn cbi-button cbi-button-positive', 'click': ui.createHandlerFn(this, function() { return handleAction('reload'); }) - }, [ _('Refresh') ]) + }, [ _('Reload') ]), + '\xa0\xa0\xa0', + E('button', { + 'class': 'btn cbi-button cbi-button-negative', + 'click': ui.createHandlerFn(this, function() { + return handleAction('restart'); + }) + }, [ _('Restart') ]) ]) ]); }, o, this); @@ -268,15 +295,9 @@ return view.extend({ s.tab('general', _('General Settings')); s.tab('additional', _('Additional Settings')); s.tab('adv_dns', _('Advanced DNS Settings')); - s.tab('adv_report', _('Advanced Report Settings'), _('Changes on this tab needs a full adblock service restart to take effect.<br /><p> </p>')); + s.tab('adv_report', _('Advanced Report Settings')); s.tab('adv_email', _('Advanced E-Mail Settings')); - s.tab('sources', _('Blocklist Sources'), _('List of supported and fully pre-configured adblock sources, already active sources are pre-selected.<br /> \ - <b><em>To avoid OOM errors, please do not select too many lists!</em></b><br /> \ - List size information with the respective domain ranges as follows:<br /> \ - • <b>S</b> (-10k), <b>M</b> (10k-30k) and <b>L</b> (30k-80k) should work for 128 MByte devices,<br /> \ - • <b>XL</b> (80k-200k) should work for 256-512 MByte devices,<br /> \ - • <b>XXL</b> (200k-) needs more RAM and Multicore support, e.g. x86 or raspberry devices.<br /> \ - <p> </p>')); + s.tab('sources', _('Blocklist Sources')); /* general settings tab @@ -374,10 +395,9 @@ return view.extend({ o.default = 1 o.rmempty = false; - o = s.taboption('additional', form.Value, 'adb_backupdir', _('Backup Directory'), _('Target directory for blocklist backups. \ - Default is \'/tmp\', please use preferably an usb stick or another local disk.')); + o = s.taboption('additional', form.Value, 'adb_backupdir', _('Backup Directory'), _('Target directory for blocklist backups.')); o.depends('adb_backup', '1'); - o.placeholder = '/tmp'; + o.placeholder = '/tmp/adblock-Backup'; o.rmempty = true; o = s.taboption('additional', form.ListValue, 'adb_fetchutil', _('Download Utility'), _('List of supported and fully pre-configured download utilities.')); @@ -388,7 +408,7 @@ return view.extend({ o.value('aria2c'); o.rmempty = true; - o = s.taboption('additional', form.Value, 'adb_fetchparm', _('Download Parameters'), _('Special config options for the selected download utility.')) + o = s.taboption('additional', form.Value, 'adb_fetchparm', _('Download Parameters'), _('Special config options for the selected download utility.')); o.rmempty = true; /* @@ -418,10 +438,6 @@ return view.extend({ o.placeholder = 'example.com'; o.rmempty = true; - o = s.taboption('adv_dns', form.Flag, 'adb_dnsfilereset', _('DNS File Reset'), _('Resets the final DNS blocklist \'adb_list.overall\' after DNS backend loading. \ - Please note: This option starts a small ubus/adblock monitor in the background.')); - o.rmempty = false; - o = s.taboption('adv_dns', form.Flag, 'adb_dnsflush', _('Flush DNS Cache'), _('Flush the DNS Cache before adblock processing as well.')); o.rmempty = true; @@ -444,14 +460,17 @@ return view.extend({ /* advanced report settings tab */ + o = s.taboption('adv_report', form.DummyValue, '_sub'); + o.rawhtml = true; + o.default = '<em><b>Changes on this tab needs a full adblock service restart to take effect.</b></em>'; + o = s.taboption('adv_report', widgets.DeviceSelect, 'adb_repiface', _('Report Interface'), _('List of available network devices used by tcpdump.')); o.unspecified = true; o.nocreate = false; o.rmempty = true; - o = s.taboption('adv_report', form.Value, 'adb_reportdir', _('Report Directory'), _('Target directory for DNS related report files. \ - Default is \'/tmp\', please use preferably an usb stick or another local disk.')); - o.placeholder = '/tmp'; + o = s.taboption('adv_report', form.Value, 'adb_reportdir', _('Report Directory'), _('Target directory for DNS related report files.')); + o.placeholder = '/tmp/adblock-Report'; o.rmempty = true; o = s.taboption('adv_report', form.Value, 'adb_repchunkcnt', _('Report Chunk Count'), _('Report chunk count used by tcpdump.')); @@ -491,18 +510,102 @@ return view.extend({ /* blocklist sources tab */ + o = s.taboption('sources', form.DummyValue, '_sub'); + o.rawhtml = true; + o.default = '<em><b>List of supported and fully pre-configured adblock sources.</b></em><br /> \ + List size information with the respective domain ranges as follows:<br /> \ + • <b>S</b> (-10k), <b>M</b> (10k-30k) and <b>L</b> (30k-80k) should work for 128 MByte devices,<br /> \ + • <b>XL</b> (80k-200k) should work for 256-512 MByte devices,<br /> \ + • <b>XXL</b> (200k-) needs more RAM and Multicore support, e.g. x86 or raspberry devices.<br /> \ + • <b>VAR</b> (50k-500k) variable size depending on the selection.<br />'; + + var name, size, focus, sources = []; + if (result[0]) { + sources = result[0].trim().split('\n'); + } + o = s.taboption('sources', form.MultiValue, 'adb_sources', _('Sources (Size, Focus)')); - var lines, name, size, focus; - lines = result[0].trim().split('\n'); - for (var i = 0; i < lines.length; i++) { - if (lines[i].match(/^\s+\+/)) { - name = lines[i].match(/^\s+\+\s(\w+)\s/)[1] || '-'; - size = lines[i].match(/^\s+\+\s\w+[\sx]+(\w+)/)[1] || '-'; - focus = lines[i].match(/^\s+\+\s\w+[\sx]+\w+\s+([\w\+]+)/)[1] || '-'; + for (var i = 0; i < sources.length; i++) { + if (sources[i].match(/^\s+\+/)) { + name = sources[i].match(/^\s+\+\s(\w+)\s/)[1] || '-'; + size = sources[i].match(/^\s+\+\s\w+[\sx]+(\w+)/)[1] || '-'; + focus = sources[i].match(/^\s+\+\s\w+[\sx]+\w+\s+([\w\+]+)/)[1] || '-'; o.value(name, name + ' (' + size + ', ' + focus + ')'); } } - o.rmempty = false; + o.optional = true; + o.rmempty = true; + + /* + prepare category data + */ + var code, category, list, path, categories = []; + if (result[1]) { + categories = result[1].trim().split('\n'); + } + + o = s.taboption('sources', form.DummyValue, '_sub'); + o.rawhtml = true; + o.default = '<em><b>Shallalist Archive Selection</b></em>'; + + o = s.taboption('sources', form.DynamicList, 'adb_sha_sources', _('Categories')); + for (var i = 0; i < categories.length; i++) { + code = categories[i].match(/^(\w+);/)[1].trim(); + if (code === 'sha') { + category = categories[i].match(/^\w+;(.*$)/)[1].trim(); + o.value(category); + } + } + o.optional = true; + o.rmempty = true; + + o = s.taboption('sources', form.DummyValue, '_sub'); + o.rawhtml = true; + o.default = '<em><b>UTCapitole Archive Selection</b></em>'; + + o = s.taboption('sources', form.DynamicList, 'adb_utc_sources', _('Categories')); + for (var i = 0; i < categories.length; i++) { + code = categories[i].match(/^(\w+);/)[1].trim(); + if (code === 'utc') { + category = categories[i].match(/^\w+;(.*$)/)[1].trim(); + o.value(category); + } + } + o.optional = true; + o.rmempty = true; + + o = s.taboption('sources', form.DummyValue, '_sub'); + o.rawhtml = true; + o.default = '<em><b>Energized List Selection</b></em>'; + + o = s.taboption('sources', form.DynamicList, 'adb_eng_sources', _('Variants')); + for (var i = 0; i < categories.length; i++) { + code = categories[i].match(/^(\w+);/)[1].trim(); + if (code === 'eng') { + list = categories[i].match(/^\w+;(.*);/)[1].trim(); + path = categories[i].match(/^.*;(.*$)/)[1].trim(); + o.value(path, list); + } + } + o.optional = true; + o.rmempty = true; + + o = s.taboption('sources', form.DummyValue, '_sub'); + o.rawhtml = true; + o.default = '<em><b>StevenBlack List Selection</b></em>'; + + o = s.taboption('sources', form.DynamicList, 'adb_stb_sources', _('Variants')); + for (var i = 0; i < categories.length; i++) { + code = categories[i].match(/^(\w+);/)[1].trim(); + if (code === 'stb') { + list = categories[i].match(/^\w+;(.*);/)[1].trim(); + path = categories[i].match(/^.*;(.*$)/)[1].trim(); + o.value(path, list); + } + } + o.optional = true; + o.rmempty = true; + return m.render(); }, handleReset: null diff --git a/applications/luci-app-adblock/htdocs/luci-static/resources/view/adblock/whitelist.js b/applications/luci-app-adblock/htdocs/luci-static/resources/view/adblock/whitelist.js index 68c6644fb3..31e58d3c74 100644 --- a/applications/luci-app-adblock/htdocs/luci-static/resources/view/adblock/whitelist.js +++ b/applications/luci-app-adblock/htdocs/luci-static/resources/view/adblock/whitelist.js @@ -8,7 +8,7 @@ return view.extend({ return L.resolveDefault(fs.read_direct('/etc/adblock/adblock.whitelist'), ''); }, handleSave: function(ev) { - var value = ((document.querySelector('textarea').value || '').trim().toLowerCase().replace(/\r\n/g, '\n').replace(/[^a-z0-9\.\-\#\n]/g, '')) + '\n'; + var value = ((document.querySelector('textarea').value || '').trim().toLowerCase().replace(/\r\n/g, '\n')) + '\n'; return fs.write('/etc/adblock/adblock.whitelist', value) .then(function(rc) { document.querySelector('textarea').value = value; |