mirror of
https://github.com/remittor/zapret-openwrt.git
synced 2026-01-31 23:00:42 +03:00
luci: tools: Fix save changes into modal dialog for NFQWS_OPT
This commit is contained in:
@@ -404,13 +404,13 @@ return baseclass.extend({
|
|||||||
E('button', {
|
E('button', {
|
||||||
'id': 'btn_save',
|
'id': 'btn_save',
|
||||||
'class': 'btn cbi-button-positive important',
|
'class': 'btn cbi-button-positive important',
|
||||||
'click': ui.createHandlerFn(this, this.handleSave),
|
'click': ui.createHandlerFn(this, this.handleSaveAdv),
|
||||||
}, _('Save')),
|
}, _('Save')),
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
|
|
||||||
handleSave: function(ev) {
|
handleSaveAdv: function(ev) {
|
||||||
let txt = document.getElementById('widget.modal_content');
|
let txt = document.getElementById('widget.modal_content');
|
||||||
let value = txt.value.trim().replace(/\r\n/g, '\n') + '\n';
|
let value = txt.value.trim().replace(/\r\n/g, '\n') + '\n';
|
||||||
|
|
||||||
@@ -515,13 +515,13 @@ return baseclass.extend({
|
|||||||
E('button', {
|
E('button', {
|
||||||
'id': 'btn_save',
|
'id': 'btn_save',
|
||||||
'class': 'btn cbi-button-positive important',
|
'class': 'btn cbi-button-positive important',
|
||||||
'click': ui.createHandlerFn(this, this.handleSave),
|
'click': ui.createHandlerFn(this, this.handleSaveAdv),
|
||||||
}, _('Save')),
|
}, _('Save')),
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
|
|
||||||
handleSave: function(ev) {
|
handleSaveAdv: function(ev) {
|
||||||
let txt = document.getElementById('widget.modal_content');
|
let txt = document.getElementById('widget.modal_content');
|
||||||
let value = txt.value.trim();
|
let value = txt.value.trim();
|
||||||
if (this.multiline) {
|
if (this.multiline) {
|
||||||
@@ -544,19 +544,32 @@ return baseclass.extend({
|
|||||||
}
|
}
|
||||||
value = value.replace(/˂/g, '<');
|
value = value.replace(/˂/g, '<');
|
||||||
value = value.replace(/˃/g, '>');
|
value = value.replace(/˃/g, '>');
|
||||||
let elem = document.getElementById("cbi-zapret-" + this.cfgsec + "-_" + this.cfgparam);
|
try {
|
||||||
if (elem) {
|
let elem2 = null;
|
||||||
let val = value.trim();
|
let elem = document.getElementById("cbi-zapret-" + this.cfgsec + "-_" + this.cfgparam);
|
||||||
if (this.multiline) {
|
if (elem) {
|
||||||
val = val.replace(/</g, '˂');
|
if (!elem2) {
|
||||||
val = val.replace(/>/g, '˃');
|
elem2 = elem.querySelector('div');
|
||||||
val = val.replace(/\n/g, '<br/>');
|
}
|
||||||
elem.querySelector('div').innerHTML = val;
|
if (!elem2) {
|
||||||
} else {
|
elem2 = elem.querySelector('output');
|
||||||
elem.querySelector('div').textContent = val;
|
}
|
||||||
}
|
}
|
||||||
|
if (elem2) {
|
||||||
|
let val = value.trim();
|
||||||
|
if (this.multiline) {
|
||||||
|
val = val.replace(/</g, '˂');
|
||||||
|
val = val.replace(/>/g, '˃');
|
||||||
|
val = val.replace(/\n/g, '<br/>');
|
||||||
|
elem2.innerHTML = val;
|
||||||
|
} else {
|
||||||
|
elem2.textContent = val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
console.error('ERROR: cannot found elem for ' + this.cfgparam);
|
||||||
}
|
}
|
||||||
uci.set('zapret2', this.cfgsec, this.cfgparam, value);
|
uci.set('zapret', this.cfgsec, this.cfgparam, value);
|
||||||
uci.save().then(ui.hideModal);
|
uci.save().then(ui.hideModal);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user