diff --git a/luci-app-zapret/htdocs/luci-static/resources/view/zapret/settings.js b/luci-app-zapret/htdocs/luci-static/resources/view/zapret/settings.js
index afd00f8..a92548a 100644
--- a/luci-app-zapret/htdocs/luci-static/resources/view/zapret/settings.js
+++ b/luci-app-zapret/htdocs/luci-static/resources/view/zapret/settings.js
@@ -141,26 +141,36 @@ return view.extend({
o.default = '
';
};
- let add_param = function(sec, param, locname = null, rows = 10) {
+ let add_param = function(sec, param, locname = null, rows = 10, multiline = false) {
if (!locname)
locname = param;
let btn = sec.taboption(tabname, form.Button, '_' + param + '_btn', locname);
btn.inputtitle = _('Edit');
btn.inputstyle = 'edit btn';
let val = sec.taboption(tabname, form.DummyValue, '_' + param);
- val.rawhtml = false;
+ val.rawhtml = multiline ? true : false;
val.cfgvalue = function(section_id) {
- let name = uci.get(tools.appName, section_id, param);
- if (name == null || name == "")
- name = "";
- return name;
+ let value = uci.get(tools.appName, section_id, param);
+ if (value == null) {
+ return "";
+ }
+ value = value.trim();
+ if (multiline == 2) {
+ value = value.replace(/\n --/g, "\n--");
+ value = value.replace(/\n --/g, "\n--");
+ value = value.replace(/ --/g, "\n--");
+ }
+ if (val.rawhtml) {
+ value = value.replace(//g, '˃');
+ value = value.replace(/\n/g, '
');
+ }
+ return value;
};
val.validate = function(section_id, value) {
- if (!value)
- return "";
- return value.trim();
+ return (value) ? value.trim() : "";
};
- btn.onclick = () => new tools.longstrEditDialog('config', param, param, locname, rows).show();
+ btn.onclick = () => new tools.longstrEditDialog('config', param, param, locname, rows, multiline).show();
};
add_delim(s);
@@ -213,7 +223,7 @@ return view.extend({
o.inputtitle = _('Edit');
o.inputstyle = 'edit btn';
o.description = tools.autoHostListFN;
- o.onclick = () => new tools.fileEditDialog(
+ o.onclick = () => new tools.fileEditDialog(
tools.autoHostListFN,
_('Auto host list'),
'',
@@ -229,7 +239,7 @@ return view.extend({
o.inputtitle = _('Edit');
o.inputstyle = 'edit btn';
o.description = tools.autoHostListDbgFN;
- o.onclick = () => new tools.fileEditDialog(
+ o.onclick = () => new tools.fileEditDialog(
tools.autoHostListDbgFN,
_('Auto host debug list'),
'',
@@ -246,7 +256,7 @@ return view.extend({
o.inputtitle = _('Edit');
o.inputstyle = 'edit btn';
o.description = tools.hostsUserFN;
- o.onclick = () => new tools.fileEditDialog(
+ o.onclick = () => new tools.fileEditDialog(
tools.hostsUserFN,
_('User entries'),
_('One hostname per line.
Examples:'),
@@ -258,7 +268,7 @@ return view.extend({
o.inputtitle = _('Edit');
o.inputstyle = 'edit btn';
o.description = tools.hostsUserExcludeFN;
- o.onclick = () => new tools.fileEditDialog(
+ o.onclick = () => new tools.fileEditDialog(
tools.hostsUserExcludeFN,
_('User excluded entries'),
_('One hostname per line.
Examples:'),
diff --git a/luci-app-zapret/htdocs/luci-static/resources/view/zapret/tools.js b/luci-app-zapret/htdocs/luci-static/resources/view/zapret/tools.js
index aab0b1b..e16ade0 100644
--- a/luci-app-zapret/htdocs/luci-static/resources/view/zapret/tools.js
+++ b/luci-app-zapret/htdocs/luci-static/resources/view/zapret/tools.js
@@ -350,18 +350,24 @@ return baseclass.extend({
}),
longstrEditDialog: baseclass.extend({
- __init__: function(cfgsec, cfgparam, title, desc, rows = 10) {
+ __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;
},
load: function() {
let value = uci.get('zapret', this.cfgsec, this.cfgparam);
if (typeof(value) === 'string') {
- return value.trim();
+ value = value.trim();
+ if (this.multiline == 2) {
+ value = value.replace(/\n --/g, "\n--");
+ value = value.replace(/\n --/g, "\n--");
+ value = value.replace(/ --/g, "\n--");
+ }
}
return value;
},
@@ -401,15 +407,36 @@ return baseclass.extend({
handleSave: function(ev) {
let txt = document.getElementById('widget.modal_content');
- let value = txt.value.trim().replace(/\r\n/g, ' ').replace(/\r/g, ' ').replace(/\n/g, ' ').trim();
+ let value = txt.value.trim();
+ if (this.multiline) {
+ value = value.replace(/\r/g, '');
+ if (value != "" && value != "\t") {
+ value = '\n' + value + '\n';
+ }
+ } else {
+ value = value.replace(/\r\n/g, ' ');
+ value = value.replace(/\r/g, ' ');
+ value = value.replace(/\n/g, ' ');
+ value = value.trim();
+ }
if (value == "") {
value = "\t";
}
+ value = value.replace(/˂/g, '<');
+ value = value.replace(/˃/g, '>');
uci.set('zapret', this.cfgsec, this.cfgparam, value);
uci.save();
let elem = document.getElementById("cbi-zapret-" + this.cfgsec + "-_" + this.cfgparam);
if (elem) {
- elem.querySelector('div').textContent = value;
+ let val = value.trim();
+ if (this.multiline) {
+ val = val.replace(//g, '˃');
+ val = val.replace(/\n/g, '
');
+ elem.querySelector('div').innerHTML = val;
+ } else {
+ elem.querySelector('div').textContent = val;
+ }
}
ui.hideModal();
/*