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