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 c901b3d..452a2d2 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 @@ -404,13 +404,13 @@ return baseclass.extend({ E('button', { 'id': 'btn_save', 'class': 'btn cbi-button-positive important', - 'click': ui.createHandlerFn(this, this.handleSave), + 'click': ui.createHandlerFn(this, this.handleSaveAdv), }, _('Save')), ]), ]); }, - handleSave: function(ev) { + handleSaveAdv: function(ev) { let txt = document.getElementById('widget.modal_content'); let value = txt.value.trim().replace(/\r\n/g, '\n') + '\n'; @@ -515,13 +515,13 @@ return baseclass.extend({ E('button', { 'id': 'btn_save', 'class': 'btn cbi-button-positive important', - 'click': ui.createHandlerFn(this, this.handleSave), + 'click': ui.createHandlerFn(this, this.handleSaveAdv), }, _('Save')), ]), ]); }, - handleSave: function(ev) { + handleSaveAdv: function(ev) { let txt = document.getElementById('widget.modal_content'); let value = txt.value.trim(); if (this.multiline) { @@ -544,19 +544,32 @@ return baseclass.extend({ } value = value.replace(/˂/g, '<'); value = value.replace(/˃/g, '>'); - let elem = document.getElementById("cbi-zapret-" + this.cfgsec + "-_" + this.cfgparam); - if (elem) { - 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; + try { + let elem2 = null; + let elem = document.getElementById("cbi-zapret-" + this.cfgsec + "-_" + this.cfgparam); + if (elem) { + if (!elem2) { + elem2 = elem.querySelector('div'); + } + if (!elem2) { + elem2 = elem.querySelector('output'); + } } + if (elem2) { + let val = value.trim(); + if (this.multiline) { + val = val.replace(//g, '˃'); + val = val.replace(/\n/g, '
'); + 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); },