884f9dddbea33088c5d280f81b2e788b018fb8c5
[project/luci.git] / applications / luci-app-adblock / htdocs / luci-static / resources / view / adblock / overview.js
1 'use strict';
2 'require view';
3 'require poll';
4 'require fs';
5 'require ui';
6 'require uci';
7 'require form';
8 'require tools.widgets as widgets';
9
10 /*
11 button handling
12 */
13 function handleAction(ev) {
14 if (ev === 'timer') {
15 L.ui.showModal(_('Refresh Timer'), [
16 E('p', _('To keep your adblock lists up-to-date, you should setup an automatic update job for these lists.')),
17 E('div', { 'class': 'left', 'style': 'display:flex; flex-direction:column' }, [
18 E('h5', _('Existing job(s)')),
19 E('textarea', {
20 'id': 'cronView',
21 'style': 'width: 100% !important; padding: 5px; font-family: monospace',
22 'readonly': 'readonly',
23 'wrap': 'off',
24 'rows': 5
25 })
26 ]),
27 E('div', { 'class': 'left', 'style': 'display:flex; flex-direction:column' }, [
28 E('label', { 'class': 'cbi-input-select', 'style': 'padding-top:.5em' }, [
29 E('h5', _('Set a new adblock job')),
30 E('select', { 'class': 'cbi-input-select', 'id': 'timerA' }, [
31 E('option', { 'value': 'start' }, 'Start'),
32 E('option', { 'value': 'reload' }, 'Reload'),
33 E('option', { 'value': 'restart' }, 'Restart'),
34 E('option', { 'value': 'suspend' }, 'Suspend'),
35 E('option', { 'value': 'resume' }, 'Resume'),
36 E('option', { 'value': 'report gen' }, 'Report'),
37 E('option', { 'value': 'report mail' }, 'Report & Mail')
38 ]),
39 '\xa0\xa0\xa0',
40 _('Adblock action')
41 ]),
42 E('label', { 'class': 'cbi-input-text', 'style': 'padding-top:.5em' }, [
43 E('input', { 'class': 'cbi-input-text', 'id': 'timerH', 'maxlength': '2' }, [
44 ]),
45 '\xa0\xa0\xa0',
46 _('The hours portition (req., range: 0-23)')
47 ]),
48 E('label', { 'class': 'cbi-input-text', 'style': 'padding-top:.5em' }, [
49 E('input', { 'class': 'cbi-input-text', 'id': 'timerM', 'maxlength': '2' }),
50 '\xa0\xa0\xa0',
51 _('The minutes portion (opt., range: 0-59)')
52 ]),
53 E('label', { 'class': 'cbi-input-text', 'style': 'padding-top:.5em' }, [
54 E('input', { 'class': 'cbi-input-text', 'id': 'timerD', 'maxlength': '13' }),
55 '\xa0\xa0\xa0',
56 _('The day of the week (opt., values: 1-7 possibly sep. by , or -)')
57 ])
58 ]),
59 E('div', { 'class': 'left', 'style': 'display:flex; flex-direction:column' }, [
60 E('label', { 'class': 'cbi-input-select', 'style': 'padding-top:.5em' }, [
61 E('h5', _('Remove an existing job')),
62 E('input', { 'class': 'cbi-input-text', 'id': 'lineno', 'maxlength': '2' }, [
63 ]),
64 '\xa0\xa0\xa0',
65 _('Line number to remove')
66 ])
67 ]),
68 E('div', { 'class': 'right' }, [
69 E('button', {
70 'class': 'btn cbi-button',
71 'click': L.hideModal
72 }, _('Cancel')),
73 ' ',
74 E('button', {
75 'class': 'btn cbi-button-action',
76 'click': ui.createHandlerFn(this, function(ev) {
77 var lineno = document.getElementById('lineno').value;
78 var action = document.getElementById('timerA').value;
79 var hours = document.getElementById('timerH').value;
80 var minutes = document.getElementById('timerM').value || '0';
81 var days = document.getElementById('timerD').value || '*';
82 if (hours) {
83 L.resolveDefault(fs.exec_direct('/etc/init.d/adblock', ['timer', 'add', action, hours, minutes, days]))
84 .then(function(res) {
85 if (res) {
86 ui.addNotification(null, E('p', _('The Refresh Timer could not been updated.')), 'error');
87 } else {
88 ui.addNotification(null, E('p', _('The Refresh Timer has been updated.')), 'info');
89 }
90 });
91 } else if (lineno) {
92 L.resolveDefault(fs.exec_direct('/etc/init.d/adblock', ['timer', 'remove', lineno]))
93 .then(function(res) {
94 if (res) {
95 ui.addNotification(null, E('p', _('The Refresh Timer could not been updated.')), 'error');
96 } else {
97 ui.addNotification(null, E('p', _('The Refresh Timer has been updated.')), 'info');
98 }
99 });
100 } else {
101 document.getElementById('timerH').focus();
102 return
103 }
104 L.hideModal();
105 })
106 }, _('Save'))
107 ])
108 ]);
109 L.resolveDefault(fs.exec_direct('/etc/init.d/adblock', ['timer', 'list']))
110 .then(function(res) {
111 document.getElementById('cronView').value = res.trim();
112 });
113 document.getElementById('timerH').focus();
114 return
115 }
116
117 if (document.getElementById('status') && document.getElementById('status').textContent.substr(0,6) === 'paused') {
118 ev = 'resume';
119 }
120
121 fs.exec_direct('/etc/init.d/adblock', [ev])
122 }
123
124 return view.extend({
125 load: function() {
126 return Promise.all([
127 L.resolveDefault(fs.exec_direct('/etc/init.d/adblock', ['list']), {}),
128 L.resolveDefault(fs.read_direct('/etc/adblock/adblock.categories'), ''),
129 uci.load('adblock')
130 ]);
131 },
132
133 render: function(result) {
134 var m, s, o;
135
136 m = new form.Map('adblock', 'Adblock', _('Configuration of the adblock package to block ad/abuse domains by using DNS. \
137 For further information <a href="https://github.com/openwrt/packages/blob/master/net/adblock/files/README.md" target="_blank" rel="noreferrer noopener" >check the online documentation</a>'));
138
139 /*
140 poll runtime information
141 */
142 pollData: poll.add(function() {
143 return L.resolveDefault(fs.read_direct('/tmp/adb_runtime.json'), 'null').then(function(res) {
144 var info = JSON.parse(res);
145 var status = document.getElementById('status');
146 if (status && info) {
147 status.textContent = (info.adblock_status || '-') + ' / ' + (info.adblock_version || '-');
148 if (info.adblock_status === "running") {
149 if (!status.classList.contains("spinning")) {
150 status.classList.add("spinning");
151 }
152 } else {
153 if (status.classList.contains("spinning")) {
154 status.classList.remove("spinning");
155 if (document.getElementById('btn_suspend')) {
156 if (status.textContent.substr(0,6) === 'paused') {
157 document.querySelector('#btn_suspend').textContent = 'Resume';
158 }
159 if (document.getElementById('status').textContent.substr(0,7) === 'enabled') {
160 document.querySelector('#btn_suspend').textContent = 'Suspend';
161 }
162 }
163 }
164 }
165 if (status.textContent.substr(0,6) === 'paused' && document.getElementById('btn_suspend')) {
166 document.querySelector('#btn_suspend').textContent = 'Resume';
167 }
168 } else if (status) {
169 status.textContent = '-';
170 if (status.classList.contains("spinning")) {
171 status.classList.remove("spinning");
172 }
173 }
174 var domains = document.getElementById('domains');
175 if (domains && info) {
176 domains.textContent = parseInt(info.blocked_domains, 10).toLocaleString() || '-';
177 }
178 var sources = document.getElementById('sources');
179 var src_array = [];
180 if (sources && info) {
181 for (var i = 0; i < info.active_sources.length; i++) {
182 if (i < info.active_sources.length-1) {
183 src_array += info.active_sources[i].source + ', ';
184 } else {
185 src_array += info.active_sources[i].source
186 }
187 }
188 sources.textContent = src_array || '-';
189 }
190 var backend = document.getElementById('backend');
191 if (backend && info) {
192 backend.textContent = info.dns_backend || '-';
193 }
194 var utils = document.getElementById('utils');
195 if (utils && info) {
196 utils.textContent = info.run_utils || '-';
197 }
198 var ifaces = document.getElementById('ifaces');
199 if (ifaces && info) {
200 ifaces.textContent = info.run_ifaces || '-';
201 }
202 var dirs = document.getElementById('dirs');
203 if (dirs && info) {
204 dirs.textContent = info.run_directories || '-';
205 }
206 var flags = document.getElementById('flags');
207 if (flags && info) {
208 flags.textContent = info.run_flags || '-';
209 }
210 var run = document.getElementById('run');
211 if (run && info) {
212 run.textContent = info.last_run || '-';
213 }
214 });
215 }, 1);
216
217 /*
218 runtime information and buttons
219 */
220 s = m.section(form.NamedSection, 'global');
221 s.render = L.bind(function(view, section_id) {
222 return E('div', { 'class': 'cbi-section' }, [
223 E('h3', _('Information')),
224 E('div', { 'class': 'cbi-value' }, [
225 E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Status / Version')),
226 E('div', { 'class': 'cbi-value-field spinning', 'id': 'status', 'style': 'color:#37c' },'\xa0')
227 ]),
228 E('div', { 'class': 'cbi-value' }, [
229 E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Blocked Domains')),
230 E('div', { 'class': 'cbi-value-field', 'id': 'domains', 'style': 'color:#37c' },'-')
231 ]),
232 E('div', { 'class': 'cbi-value' }, [
233 E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Active Sources')),
234 E('div', { 'class': 'cbi-value-field', 'id': 'sources', 'style': 'color:#37c' },'-')
235 ]),
236 E('div', { 'class': 'cbi-value' }, [
237 E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('DNS Backend')),
238 E('div', { 'class': 'cbi-value-field', 'id': 'backend', 'style': 'color:#37c' },'-')
239 ]),
240 E('div', { 'class': 'cbi-value' }, [
241 E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Run Utils')),
242 E('div', { 'class': 'cbi-value-field', 'id': 'utils', 'style': 'color:#37c' },'-')
243 ]),
244 E('div', { 'class': 'cbi-value' }, [
245 E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Run Interfaces')),
246 E('div', { 'class': 'cbi-value-field', 'id': 'ifaces', 'style': 'color:#37c' },'-')
247 ]),
248 E('div', { 'class': 'cbi-value' }, [
249 E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Run Directories')),
250 E('div', { 'class': 'cbi-value-field', 'id': 'dirs', 'style': 'color:#37c' },'-')
251 ]),
252 E('div', { 'class': 'cbi-value' }, [
253 E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Run Flags')),
254 E('div', { 'class': 'cbi-value-field', 'id': 'flags', 'style': 'color:#37c' },'-')
255 ]),
256 E('div', { 'class': 'cbi-value' }, [
257 E('label', { 'class': 'cbi-value-title', 'style': 'padding-top:0rem' }, _('Last Run')),
258 E('div', { 'class': 'cbi-value-field', 'id': 'run', 'style': 'color:#37c' },'-')
259 ]),
260 E('div', { class: 'right' }, [
261 E('button', {
262 'class': 'btn cbi-button cbi-button-apply',
263 'click': ui.createHandlerFn(this, function() {
264 return handleAction('timer');
265 })
266 }, [ _('Refresh Timer...') ]),
267 '\xa0\xa0\xa0',
268 E('button', {
269 'class': 'btn cbi-button cbi-button-apply',
270 'id': 'btn_suspend',
271 'click': ui.createHandlerFn(this, function() {
272 return handleAction('suspend');
273 })
274 }, [ _('Suspend') ]),
275 '\xa0\xa0\xa0',
276 E('button', {
277 'class': 'btn cbi-button cbi-button-positive',
278 'click': ui.createHandlerFn(this, function() {
279 return handleAction('reload');
280 })
281 }, [ _('Reload') ]),
282 '\xa0\xa0\xa0',
283 E('button', {
284 'class': 'btn cbi-button cbi-button-negative',
285 'click': ui.createHandlerFn(this, function() {
286 return handleAction('restart');
287 })
288 }, [ _('Restart') ])
289 ])
290 ]);
291 }, o, this);
292 this.pollData;
293
294 /*
295 tabbed config section
296 */
297 s = m.section(form.NamedSection, 'global', 'adblock', _('Settings'));
298 s.addremove = false;
299 s.tab('general', _('General Settings'));
300 s.tab('additional', _('Additional Settings'));
301 s.tab('adv_dns', _('Advanced DNS Settings'));
302 s.tab('adv_report', _('Advanced Report Settings'));
303 s.tab('adv_email', _('Advanced E-Mail Settings'));
304 s.tab('sources', _('Blocklist Sources'));
305
306 /*
307 general settings tab
308 */
309 o = s.taboption('general', form.Flag, 'adb_enabled', _('Enabled'), _('Enable the adblock service.'));
310 o.rmempty = false;
311
312 o = s.taboption('general', widgets.NetworkSelect, 'adb_trigger', _('Startup Trigger Interface'), _('List of available network interfaces to trigger the adblock start. \
313 Choose \'unspecified\' to use a classic startup timeout instead of a network trigger.'));
314 o.unspecified = true;
315 o.nocreate = true;
316 o.rmempty = true;
317
318 o = s.taboption('general', form.Flag, 'adb_forcedns', _('Force Local DNS'), _('Redirect all DNS queries from specified zones to the local DNS resolver, applies to UDP and TCP protocol.'));
319 o.rmempty = false;
320
321 o = s.taboption('general', widgets.ZoneSelect, 'adb_zonelist', _('Forced Zones'), _('Firewall source zones that should be forced locally.'));
322 o.depends('adb_forcedns', '1');
323 o.unspecified = true;
324 o.multiple = true;
325 o.nocreate = true;
326 o.rmempty = true;
327
328 o = s.taboption('general', form.DynamicList, 'adb_portlist', _('Forced Ports'), _('Firewall ports that should be forced locally.'));
329 o.depends('adb_forcedns', '1');
330 o.unspecified = true;
331 o.multiple = true;
332 o.nocreate = false;
333 o.datatype = 'port';
334 o.value('53');
335 o.value('853');
336 o.value('5353');
337 o.rmempty = true;
338
339 o = s.taboption('general', form.Flag, 'adb_safesearch', _('Enable SafeSearch'), _('Enforcing SafeSearch for google, bing, duckduckgo, yandex, youtube and pixabay.'));
340 o.rmempty = false;
341
342 o = s.taboption('general', form.MultiValue, 'adb_safesearchlist', _('Limit SafeSearch'), _('Limit SafeSearch to certain providers.'));
343 o.depends('adb_safesearch', '1');
344 o.value('google');
345 o.value('bing');
346 o.value('yandex');
347 o.value('youtube');
348 o.value('pixabay');
349 o.rmempty = true;
350
351 o = s.taboption('general', form.Flag, 'adb_safesearchmod', _('Relax SafeSearch'), _('Enable moderate SafeSearch filters for youtube.'));
352 o.depends('adb_safesearch', '1');
353 o.rmempty = true;
354
355 o = s.taboption('general', form.Flag, 'adb_report', _('DNS Report'), _('Gather DNS related network traffic via tcpdump and provide a DNS Report on demand. \
356 Please note: this needs additional \'tcpdump-mini\' package installation and a full adblock service restart to take effect.'));
357 o.rmempty = false;
358
359 o = s.taboption('general', form.Flag, 'adb_mail', _('E-Mail Notification'), _('Send adblock related notification e-mails. \
360 Please note: this needs additional \'msmtp\' package installation.'));
361 o.rmempty = false;
362
363 o = s.taboption('general', form.Value, 'adb_mailreceiver', _('E-Mail Receiver Address'), _('Receiver address for adblock notification e-mails.'));
364 o.depends('adb_mail', '1');
365 o.placeholder = 'name@example.com';
366 o.rmempty = true;
367
368 /*
369 additional settings tab
370 */
371 o = s.taboption('additional', form.Flag, 'adb_debug', _('Verbose Debug Logging'), _('Enable verbose debug logging in case of any processing errors.'));
372 o.rmempty = false;
373
374 o = s.taboption('additional', form.Flag, 'adb_nice', _('Low Priority Service'), _('Reduce the priority of the adblock background processing to take fewer resources from the system. \
375 Please note: This change requires a full adblock service restart to take effect.'));
376 o.enabled = '10';
377 o.rmempty = true;
378
379 o = s.taboption('additional', form.Value, 'adb_triggerdelay', _('Trigger Delay'), _('Additional trigger delay in seconds before adblock processing begins.'));
380 o.placeholder = '2';
381 o.datatype = 'range(1,300)';
382 o.rmempty = true;
383
384 o = s.taboption('additional', form.ListValue, 'adb_maxqueue', _('Download Queue'), _('Size of the download queue for download processing (incl. sorting, merging etc.) in parallel.'));
385 o.value('1');
386 o.value('2');
387 o.value('4');
388 o.value('8');
389 o.value('16');
390 o.value('32');
391 o.rmempty = false;
392
393 o = s.taboption('additional', form.Value, 'adb_tmpbase', _('Base Temp Directory'), _('Base Temp Directory for all adblock related runtime operations, \
394 e.g. downloading, sorting, merging etc.'));
395 o.placeholder = '/tmp';
396 o.rmempty = true;
397
398 o = s.taboption('additional', form.Flag, 'adb_backup', _('Blocklist Backup'), _('Create compressed blocklist backups, they will be used in case of download errors or during startup.'));
399 o.default = 1
400 o.rmempty = false;
401
402 o = s.taboption('additional', form.Value, 'adb_backupdir', _('Backup Directory'), _('Target directory for blocklist backups.'));
403 o.depends('adb_backup', '1');
404 o.placeholder = '/tmp/adblock-Backup';
405 o.rmempty = true;
406
407 o = s.taboption('additional', form.ListValue, 'adb_fetchutil', _('Download Utility'), _('List of supported and fully pre-configured download utilities.'));
408 o.value('uclient-fetch');
409 o.value('wget');
410 o.value('curl');
411 o.value('aria2c');
412 o.optional = true;
413 o.rmempty = true;
414
415 o = s.taboption('additional', form.Flag, 'adb_fetchinsecure', _('Download Insecure'), _('Don\'t check SSL server certificates during download.'));
416 o.default = 0
417 o.rmempty = true;
418
419 o = s.taboption('additional', form.Value, 'adb_fetchparm', _('Download Parameters'), _('Manually override the pre-configured download options for the selected download utility.'));
420 o.optional = true;
421 o.rmempty = true;
422
423 /*
424 advanced dns settings tab
425 */
426 o = s.taboption('adv_dns', form.ListValue, 'adb_dns', _('DNS Backend'), _('List of supported DNS backends with their default list directory. \
427 To overwrite the default path use the \'DNS Directory\' option.'));
428 o.value('dnsmasq', _('dnsmasq (/tmp/dnsmasq.d)'));
429 o.value('unbound', _('unbound (/var/lib/unbound)'));
430 o.value('named', _('bind (/var/lib/bind)'));
431 o.value('kresd', _('kresd (/etc/kresd)'));
432 o.value('raw', _('raw (/tmp)'));
433 o.optional = true;
434 o.rmempty = true;
435
436 o = s.taboption('adv_dns', form.Value, 'adb_dnsdir', _('DNS Directory'), _('Target directory for the generated blocklist \'adb_list.overall\'.'));
437 o.placeholder = '/tmp';
438 o.rmempty = true;
439
440 o = s.taboption('adv_dns', form.ListValue, 'adb_dnsinstance', _('DNS Instance'), _('Set the dns backend instance used by adblock.'));
441 o.value('0', _('First instance (default)'));
442 o.value('1', _('Second instance'));
443 o.value('2', _('Third instance'));
444 o.value('3', _('Fourth instance'));
445 o.value('4', _('Fifth instance'));
446 o.depends('adb_dns', 'dnsmasq');
447 o.optional = true;
448 o.rmempty = true;
449
450 o = s.taboption('adv_dns', form.Value, 'adb_dnstimeout', _('DNS Restart Timeout'), _('Timeout to wait for a successful DNS backend restart.'));
451 o.placeholder = '20';
452 o.datatype = 'range(1,60)';
453 o.rmempty = true;
454
455 o = s.taboption('adv_dns', form.Value, 'adb_lookupdomain', _('External DNS Lookup Domain'), _('External domain to check for a successful DNS backend restart. \
456 Please note: To disable this check set this option to \'false\'.'));
457 o.placeholder = 'example.com';
458 o.rmempty = true;
459
460 o = s.taboption('adv_dns', form.Flag, 'adb_dnsflush', _('Flush DNS Cache'), _('Flush the DNS Cache before adblock processing as well.'));
461 o.rmempty = true;
462
463 o = s.taboption('adv_dns', form.Flag, 'adb_dnsallow', _('Disable DNS Allow'), _('Disable selective DNS whitelisting (RPZ-PASSTHRU).'));
464 o.rmempty = true;
465
466 o = s.taboption('adv_dns', form.DynamicList, 'adb_denyip', _('Block Local Client IPs'), _('Block all requests of certain DNS clients based on their IP address (RPZ-CLIENT-IP). \
467 Please note: This feature is currently only supported by bind DNS backend.'));
468 o.datatype = 'or(ip4addr("nomask"),ip6addr("nomask"))';
469 o.optional = true;
470 o.rmempty = true;
471
472 o = s.taboption('adv_dns', form.DynamicList, 'adb_allowip', _('Allow Local Client IPs'), _('Allow all requests of certain DNS clients based on their IP address (RPZ-CLIENT-IP). \
473 Please note: This feature is currently only supported by bind DNS backend.'));
474 o.datatype = 'or(ip4addr("nomask"),ip6addr("nomask"))';
475 o.optional = true;
476 o.rmempty = true;
477
478 o = s.taboption('adv_dns', form.Flag, 'adb_jail', _('Additional Jail Blocklist'), _('Builds an additional DNS blocklist to block access to all domains except those listed in the whitelist. \
479 Please note: You can use this restrictive blocklist e.g. for guest wifi or kidsafe configurations.'));
480 o.rmempty = true;
481
482 o = s.taboption('adv_dns', form.Value, 'adb_jaildir', _('Jail Directory'), _('Target directory for the generated jail blocklist \'adb_list.jail\'.'));
483 o.depends('adb_jail', '1');
484 o.placeholder = '/tmp';
485 o.rmempty = true;
486
487 o = s.taboption('adv_dns', form.Flag, 'adb_dnsinotify', _('Disable DNS Restarts'), _('Disable adblock triggered restarts for dns backends with autoload/inotify functions.'));
488 o.depends('adb_dnsflush', '0');
489 o.rmempty = true;
490
491 /*
492 advanced report settings tab
493 */
494 o = s.taboption('adv_report', form.DummyValue, '_sub');
495 o.rawhtml = true;
496 o.default = '<em><b>Changes on this tab needs a full adblock service restart to take effect.</b></em>';
497
498 o = s.taboption('adv_report', widgets.DeviceSelect, 'adb_repiface', _('Report Interface'), _('List of available network devices used by tcpdump.'));
499 o.unspecified = true;
500 o.nocreate = false;
501 o.rmempty = true;
502
503 o = s.taboption('adv_report', form.Value, 'adb_reportdir', _('Report Directory'), _('Target directory for DNS related report files.'));
504 o.placeholder = '/tmp/adblock-Report';
505 o.rmempty = true;
506
507 o = s.taboption('adv_report', form.Value, 'adb_repchunkcnt', _('Report Chunk Count'), _('Report chunk count used by tcpdump.'));
508 o.placeholder = '5';
509 o.datatype = 'range(1,10)';
510 o.rmempty = true;
511
512 o = s.taboption('adv_report', form.Value, 'adb_repchunksize', _('Report Chunk Size'), _('Report chunk size used by tcpdump in MByte.'));
513 o.placeholder = '1';
514 o.datatype = 'range(1,10)';
515 o.rmempty = true;
516
517 o = s.taboption('adv_report', form.Value, 'adb_replisten', _('Report Ports'), _('Space separated list of ports used by tcpdump.'));
518 o.placeholder = '53';
519 o.rmempty = true;
520
521 o = s.taboption('adv_report', form.Flag, 'adb_represolve', _('Resolve IPs'), _('Resolve reporting IP addresses by using reverse DNS (PTR) lookups.'));
522 o.rmempty = true;
523
524 /*
525 advanced email settings tab
526 */
527 o = s.taboption('adv_email', form.Value, 'adb_mailsender', _('E-Mail Sender Address'), _('Sender address for adblock notification E-Mails.'));
528 o.placeholder = 'no-reply@adblock';
529 o.rmempty = true;
530
531 o = s.taboption('adv_email', form.Value, 'adb_mailtopic', _('E-Mail Topic'), _('Topic for adblock notification E-Mails.'));
532 o.placeholder = 'adblock notification';
533 o.rmempty = true;
534
535 o = s.taboption('adv_email', form.Value, 'adb_mailprofile', _('E-Mail Profile'), _('Profile used by \'msmtp\' for adblock notification E-Mails.'));
536 o.placeholder = 'adb_notify';
537 o.rmempty = true;
538
539 o = s.taboption('adv_email', form.Value, 'adb_mailcnt', _('E-Mail Notification Count'), _('Raise the notification count, to get E-Mails if the overall blocklist count is less or equal to the given limit.'));
540 o.placeholder = '0';
541 o.datatype = 'min(0)';
542 o.rmempty = true;
543
544 /*
545 blocklist sources tab
546 */
547 o = s.taboption('sources', form.DummyValue, '_sub');
548 o.rawhtml = true;
549 o.default = '<em><b>List of supported and fully pre-configured adblock sources.</b></em><br /> \
550 List size information with the respective domain ranges as follows:<br /> \
551 &#8226;&#xa0;<b>S</b> (-10k), <b>M</b> (10k-30k) and <b>L</b> (30k-80k) should work for 128 MByte devices,<br /> \
552 &#8226;&#xa0;<b>XL</b> (80k-200k) should work for 256-512 MByte devices,<br /> \
553 &#8226;&#xa0;<b>XXL</b> (200k-) needs more RAM and Multicore support, e.g. x86 or raspberry devices.<br /> \
554 &#8226;&#xa0;<b>VAR</b> (50k-500k) variable size depending on the selection.<br />';
555
556 var name, size, focus, sources = [];
557 if (result[0]) {
558 sources = result[0].trim().split('\n');
559 }
560
561 o = s.taboption('sources', form.MultiValue, 'adb_sources', _('Sources (Size, Focus)'));
562 for (var i = 0; i < sources.length; i++) {
563 if (sources[i].match(/^\s+\+/)) {
564 name = sources[i].match(/^\s+\+\s(\w+)\s/)[1] || '-';
565 size = sources[i].match(/^\s+\+\s\w+[\sx]+(\w+)/)[1] || '-';
566 focus = sources[i].match(/^\s+\+\s\w+[\sx]+\w+\s+([\w\+]+)/)[1] || '-';
567 o.value(name, name + ' (' + size + ', ' + focus + ')');
568 }
569 }
570 o.optional = true;
571 o.rmempty = true;
572
573 /*
574 prepare category data
575 */
576 var code, category, list, path, categories = [];
577 if (result[1]) {
578 categories = result[1].trim().split('\n');
579 }
580
581 o = s.taboption('sources', form.DummyValue, '_sub');
582 o.rawhtml = true;
583 o.default = '<em><b>Shallalist Archive Selection</b></em>';
584
585 o = s.taboption('sources', form.DynamicList, 'adb_sha_sources', _('Categories'));
586 for (var i = 0; i < categories.length; i++) {
587 code = categories[i].match(/^(\w+);/)[1].trim();
588 if (code === 'sha') {
589 category = categories[i].match(/^\w+;(.*$)/)[1].trim();
590 o.value(category);
591 }
592 }
593 o.optional = true;
594 o.rmempty = true;
595
596 o = s.taboption('sources', form.DummyValue, '_sub');
597 o.rawhtml = true;
598 o.default = '<em><b>UTCapitole Archive Selection</b></em>';
599
600 o = s.taboption('sources', form.DynamicList, 'adb_utc_sources', _('Categories'));
601 for (var i = 0; i < categories.length; i++) {
602 code = categories[i].match(/^(\w+);/)[1].trim();
603 if (code === 'utc') {
604 category = categories[i].match(/^\w+;(.*$)/)[1].trim();
605 o.value(category);
606 }
607 }
608 o.optional = true;
609 o.rmempty = true;
610
611 o = s.taboption('sources', form.DummyValue, '_sub');
612 o.rawhtml = true;
613 o.default = '<em><b>Energized List Selection</b></em>';
614
615 o = s.taboption('sources', form.DynamicList, 'adb_eng_sources', _('Variants'));
616 for (var i = 0; i < categories.length; i++) {
617 code = categories[i].match(/^(\w+);/)[1].trim();
618 if (code === 'eng') {
619 list = categories[i].match(/^\w+;(.*);/)[1].trim();
620 path = categories[i].match(/^.*;(.*$)/)[1].trim();
621 o.value(path, list);
622 }
623 }
624 o.optional = true;
625 o.rmempty = true;
626
627 o = s.taboption('sources', form.DummyValue, '_sub');
628 o.rawhtml = true;
629 o.default = '<em><b>StevenBlack List Selection</b></em>';
630
631 o = s.taboption('sources', form.DynamicList, 'adb_stb_sources', _('Variants'));
632 for (var i = 0; i < categories.length; i++) {
633 code = categories[i].match(/^(\w+);/)[1].trim();
634 if (code === 'stb') {
635 list = categories[i].match(/^\w+;(.*);/)[1].trim();
636 path = categories[i].match(/^.*;(.*$)/)[1].trim();
637 o.value(path, list);
638 }
639 }
640 o.optional = true;
641 o.rmempty = true;
642
643 return m.render();
644 },
645 handleReset: null
646 });