diff --git a/luci-app-zapret2/htdocs/luci-static/resources/view/zapret2/settings.js b/luci-app-zapret2/htdocs/luci-static/resources/view/zapret2/settings.js index 3f324a4..8982173 100644 --- a/luci-app-zapret2/htdocs/luci-static/resources/view/zapret2/settings.js +++ b/luci-app-zapret2/htdocs/luci-static/resources/view/zapret2/settings.js @@ -157,7 +157,14 @@ return view.extend({ if (multiline == 2) { desc += '
' + _('Example') + ': %s'.format(tools.nfqws_opt_url); } - btn.onclick = () => new tools.longstrEditDialog('config', param, param, desc, rows, multiline).show(); + btn.onclick = () => new tools.longstrEditDialog({ + cfgsec: 'config', + cfgparam: param, + title: param, + desc: desc, + rows: rows, + multiline: multiline, + }).show(); }; if (tools.appName == 'zapret2') { @@ -313,13 +320,12 @@ return view.extend({ o.inputtitle = _('Edit'); o.inputstyle = 'edit btn'; o.description = tools.autoHostListFN; - o.onclick = () => new tools.fileEditDialog( - tools.autoHostListFN, - _('Auto host list'), - '', - '', - 15 - ).show(); + o.onclick = () => new tools.fileEditDialog({ + file: tools.autoHostListFN, + title: _('Auto host list'), + desc: '', + rows: 15, + }).show(); o = s.taboption(tabname, form.Flag, 'AUTOHOSTLIST_DEBUGLOG', _('DEBUGLOG')); o.rmempty = false; @@ -329,13 +335,12 @@ return view.extend({ o.inputtitle = _('Edit'); o.inputstyle = 'edit btn'; o.description = tools.autoHostListDbgFN; - o.onclick = () => new tools.fileEditDialog( - tools.autoHostListDbgFN, - _('Auto host debug list'), - '', - '', - 15 - ).show(); + o.onclick = () => new tools.fileEditDialog({ + file: tools.autoHostListDbgFN, + title: _('Auto host debug list'), + desc: '', + rows: 15, + }).show(); /* HostList settings */ @@ -346,37 +351,37 @@ return view.extend({ o.inputtitle = _('Edit'); o.inputstyle = 'edit btn'; o.description = tools.hostsGoogleFN; - o.onclick = () => new tools.fileEditDialog( - tools.hostsGoogleFN, - _('Google hostname entries'), - _('One hostname per line.
Examples:'), - 'youtube.com
googlevideo.com
', - 15 - ).show(); + o.onclick = () => new tools.fileEditDialog({ + file: tools.hostsGoogleFN, + title: _('Google hostname entries'), + desc: _('One hostname per line.
Examples:'), + aux: 'youtube.com
googlevideo.com
', + rows: 15, + }).show(); o = s.taboption(tabname, form.Button, '_user_entries_btn', _('User hostname entries ')); o.inputtitle = _('Edit'); o.inputstyle = 'edit btn'; o.description = tools.hostsUserFN; - o.onclick = () => new tools.fileEditDialog( - tools.hostsUserFN, - _('User entries'), - _('One hostname per line.
Examples:'), - 'domain.net
sub.domain.com
facebook.com
', - 15 - ).show(); + o.onclick = () => new tools.fileEditDialog({ + file: tools.hostsUserFN, + title: _('User entries'), + desc: _('One hostname per line.
Examples:'), + aux: 'domain.net
sub.domain.com
facebook.com
', + rows: 15, + }).show(); o = s.taboption(tabname, form.Button, '_user_excluded_entries_btn', _('User excluded hostname entries')); o.inputtitle = _('Edit'); o.inputstyle = 'edit btn'; o.description = tools.hostsUserExcludeFN; - o.onclick = () => new tools.fileEditDialog( - tools.hostsUserExcludeFN, - _('User excluded entries'), - _('One hostname per line.
Examples:'), - 'domain.net
sub.domain.com
gosuslugi.ru
', - 15 - ).show(); + o.onclick = () => new tools.fileEditDialog({ + file: tools.hostsUserExcludeFN, + title: _('User excluded entries'), + desc: _('One hostname per line.
Examples:'), + aux: 'domain.net
sub.domain.com
gosuslugi.ru
', + rows: 15, + }).show(); add_delim(s); @@ -384,37 +389,37 @@ return view.extend({ o.inputtitle = _('Edit'); o.inputstyle = 'edit btn'; o.description = tools.iplstExcludeFN; - o.onclick = () => new tools.fileEditDialog( - tools.iplstExcludeFN, - _('Excluded IP filter'), - _('Patterns can be strings or regular expressions. Each pattern in a separate line
Examples:'), - '128.199.0.0/16
34.217.90.52
162.13.190.77
', - 15 - ).show(); + o.onclick = () => new tools.fileEditDialog({ + file: tools.iplstExcludeFN, + title: _('Excluded IP filter'), + desc: _('Patterns can be strings or regular expressions. Each pattern in a separate line
Examples:'), + aux: '128.199.0.0/16
34.217.90.52
162.13.190.77
', + rows: 15, + }).show(); o = s.taboption(tabname, form.Button, '_user_ip_filter_btn', _('User IP entries')); o.inputtitle = _('Edit'); o.inputstyle = 'edit btn'; o.description = tools.iplstUserFN; - o.onclick = () => new tools.fileEditDialog( - tools.iplstUserFN, - _('User IP filter'), - _('Patterns can be strings or regular expressions. Each pattern in a separate line
Examples:'), - '128.199.0.0/16
34.217.90.52
162.13.190.77
', - 15 - ).show(); + o.onclick = () => new tools.fileEditDialog({ + file: tools.iplstUserFN, + title: _('User IP filter'), + desc: _('Patterns can be strings or regular expressions. Each pattern in a separate line
Examples:'), + aux: '128.199.0.0/16
34.217.90.52
162.13.190.77
', + rows: 15, + }).show(); o = s.taboption(tabname, form.Button, '_user_excluded_ip_filter_btn', _('User excluded IP entries')); o.inputtitle = _('Edit'); o.inputstyle = 'edit btn'; o.description = tools.iplstUserExcludeFN; - o.onclick = () => new tools.fileEditDialog( - tools.iplstUserExcludeFN, - _('User excluded IP filter'), - _('Patterns can be strings or regular expressions. Each pattern in a separate line
Examples:'), - '128.199.0.0/16
34.217.90.52
162.13.190.77
', - 15 - ).show(); + o.onclick = () => new tools.fileEditDialog({ + file: tools.iplstUserExcludeFN, + title: _('User excluded IP filter'), + desc: _('Patterns can be strings or regular expressions. Each pattern in a separate line
Examples:'), + aux: '128.199.0.0/16
34.217.90.52
162.13.190.77
', + rows: 15, + }).show(); add_delim(s); @@ -425,7 +430,7 @@ return view.extend({ o.inputtitle = _('Edit'); o.inputstyle = 'edit btn'; o.description = fn; - o.onclick = () => new tools.fileEditDialog(fn, name, '', '', 15).show(); + o.onclick = () => new tools.fileEditDialog({ file: fn, title: name, rows: 15}).show(); } /* custom.d files */ @@ -467,7 +472,7 @@ return view.extend({ desc += '' + filename + ''; } } - o.onclick = () => new tools.fileEditDialog(fn, name, desc, '', 15).show(); + o.onclick = () => new tools.fileEditDialog({ file: fn, title: name, desc: desc, rows: 15}).show(); } let map_promise = m.render(); diff --git a/luci-app-zapret2/htdocs/luci-static/resources/view/zapret2/tools.js b/luci-app-zapret2/htdocs/luci-static/resources/view/zapret2/tools.js index 8017b4d..f505aee 100644 --- a/luci-app-zapret2/htdocs/luci-static/resources/view/zapret2/tools.js +++ b/luci-app-zapret2/htdocs/luci-static/resources/view/zapret2/tools.js @@ -320,14 +320,17 @@ return baseclass.extend({ }, fileEditDialog: baseclass.extend({ - __init__: function(file, title, desc, aux = null, rows = 10, callback, file_exists = false) { - this.file = file; - this.title = title; - this.desc = desc; - this.aux = aux; - this.rows = rows, - this.callback = callback; - this.file_exists = file_exists; + __init__: function(opts = {}) + { + Object.assign(this, { + file: '', + title: '', + desc: '', + aux: '', + rows: 10, + callback: null, + file_exists: false + }, opts); }, load: function() { @@ -455,13 +458,16 @@ return baseclass.extend({ }), longstrEditDialog: baseclass.extend({ - __init__: function(cfgsec, cfgparam, title, desc, rows = 10, multiline = false) { - this.cfgsec = cfgsec; - this.cfgparam = cfgparam; - this.title = title; - this.desc = desc; - this.rows = rows; - this.multiline = multiline; + __init__: function(opts = {}) + { + Object.assign(this, { + cfgsec: '', + cfgparam: '', + title: '', + desc: '', + rows: 10, + multiline: false // may be 2 + }, opts); env_tools.load_env(this); },