function write_keepalive(section_id, value) {
var f_opt = this.map.lookupOption('_keepalive_failure', section_id),
i_opt = this.map.lookupOption('_keepalive_interval', section_id),
- f = (f_opt != null) ? +f_opt[0].formvalue(section_id) : null,
- i = (i_opt != null) ? +i_opt[0].formvalue(section_id) : null;
+ f = parseInt(f_opt?.[0]?.formvalue(section_id), 10),
+ i = parseInt(i_opt?.[0]?.formvalue(section_id), 10);
- if (f === '' || isNaN(f))
- f = null;
-
- if (i == null || i == '' || isNaN(i) || i < 1)
+ if (isNaN(i))
i = 1;
+ if (isNaN(f))
+ f = (i == 1) ? null : 5;
+
if (f !== null)
uci.set('network', section_id, 'keepalive', '%d %d'.format(f, i));
else
o = s.taboption('advanced', form.Value, '_keepalive_interval', _('LCP echo interval'), _('Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold'));
o.placeholder = '1';
- o.datatype = 'min(1)';
+ o.datatype = 'and(uinteger,min(1))';
o.write = write_keepalive;
o.remove = write_keepalive;
o.cfgvalue = function(section_id) {
function write_keepalive(section_id, value) {
var f_opt = this.map.lookupOption('_keepalive_failure', section_id),
i_opt = this.map.lookupOption('_keepalive_interval', section_id),
- f = (f_opt != null) ? +f_opt[0].formvalue(section_id) : null,
- i = (i_opt != null) ? +i_opt[0].formvalue(section_id) : null;
+ f = parseInt(f_opt?.[0]?.formvalue(section_id), 10),
+ i = parseInt(i_opt?.[0]?.formvalue(section_id), 10);
- if (f === '' || isNaN(f))
- f = null;
-
- if (i == null || i == '' || isNaN(i) || i < 1)
+ if (isNaN(i))
i = 1;
+ if (isNaN(f))
+ f = (i == 1) ? null : 5;
+
if (f !== null)
uci.set('network', section_id, 'keepalive', '%d %d'.format(f, i));
else
o = s.taboption('advanced', form.Value, '_keepalive_interval', _('LCP echo interval'), _('Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold'));
o.placeholder = '1';
- o.datatype = 'min(1)';
+ o.datatype = 'and(uinteger,min(1))';
o.write = write_keepalive;
o.remove = write_keepalive;
o.cfgvalue = function(section_id) {
function write_keepalive(section_id, value) {
var f_opt = this.map.lookupOption('_keepalive_failure', section_id),
i_opt = this.map.lookupOption('_keepalive_interval', section_id),
- f = (f_opt != null) ? +f_opt[0].formvalue(section_id) : null,
- i = (i_opt != null) ? +i_opt[0].formvalue(section_id) : null;
+ f = parseInt(f_opt?.[0]?.formvalue(section_id), 10),
+ i = parseInt(i_opt?.[0]?.formvalue(section_id), 10);
- if (f === '' || isNaN(f))
- f = null;
-
- if (i == null || i == '' || isNaN(i) || i < 1)
+ if (isNaN(i))
i = 1;
+ if (isNaN(f))
+ f = (i == 1) ? null : 5;
+
if (f !== null)
uci.set('network', section_id, 'keepalive', '%d %d'.format(f, i));
else
o = s.taboption('advanced', form.Value, '_keepalive_interval', _('LCP echo interval'), _('Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold'));
o.placeholder = '1';
- o.datatype = 'min(1)';
+ o.datatype = 'and(uinteger,min(1))';
o.write = write_keepalive;
o.remove = write_keepalive;
o.cfgvalue = function(section_id) {
function write_keepalive(section_id, value) {
var f_opt = this.map.lookupOption('_keepalive_failure', section_id),
i_opt = this.map.lookupOption('_keepalive_interval', section_id),
- f = (f_opt != null) ? +f_opt[0].formvalue(section_id) : null,
- i = (i_opt != null) ? +i_opt[0].formvalue(section_id) : null;
+ f = parseInt(f_opt?.[0]?.formvalue(section_id), 10),
+ i = parseInt(i_opt?.[0]?.formvalue(section_id), 10);
- if (f === '' || isNaN(f))
- f = null;
-
- if (i == null || i == '' || isNaN(i) || i < 1)
+ if (isNaN(i))
i = 1;
+ if (isNaN(f))
+ f = (i == 1) ? null : 5;
+
if (f !== null)
uci.set('network', section_id, 'keepalive', '%d %d'.format(f, i));
else
o = s.taboption('advanced', form.Value, '_keepalive_interval', _('LCP echo interval'), _('Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold'));
o.placeholder = '1';
- o.datatype = 'min(1)';
+ o.datatype = 'and(uinteger,min(1))';
o.write = write_keepalive;
o.remove = write_keepalive;
o.cfgvalue = function(section_id) {
function write_keepalive(section_id, value) {
var f_opt = this.map.lookupOption('_keepalive_failure', section_id),
i_opt = this.map.lookupOption('_keepalive_interval', section_id),
- f = (f_opt != null) ? +f_opt[0].formvalue(section_id) : null,
- i = (i_opt != null) ? +i_opt[0].formvalue(section_id) : null;
+ f = parseInt(f_opt?.[0]?.formvalue(section_id), 10),
+ i = parseInt(i_opt?.[0]?.formvalue(section_id), 10);
- if (f === '' || isNaN(f))
- f = null;
-
- if (i == null || i == '' || isNaN(i) || i < 1)
+ if (isNaN(i))
i = 1;
+ if (isNaN(f))
+ f = (i == 1) ? null : 5;
+
if (f !== null)
uci.set('network', section_id, 'keepalive', '%d %d'.format(f, i));
else
o = s.taboption('advanced', form.Value, '_keepalive_interval', _('LCP echo interval'), _('Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold'));
o.placeholder = '1';
- o.datatype = 'min(1)';
+ o.datatype = 'and(uinteger,min(1))';
o.write = write_keepalive;
o.remove = write_keepalive;
o.cfgvalue = function(section_id) {
function write_keepalive(section_id, value) {
var f_opt = this.map.lookupOption('_keepalive_failure', section_id),
i_opt = this.map.lookupOption('_keepalive_interval', section_id),
- f = (f_opt != null) ? +f_opt[0].formvalue(section_id) : null,
- i = (i_opt != null) ? +i_opt[0].formvalue(section_id) : null;
+ f = parseInt(f_opt?.[0]?.formvalue(section_id), 10),
+ i = parseInt(i_opt?.[0]?.formvalue(section_id), 10);
- if (f === '' || isNaN(f))
- f = null;
-
- if (i == null || i == '' || isNaN(i) || i < 1)
+ if (isNaN(i))
i = 1;
+ if (isNaN(f))
+ f = (i == 1) ? null : 5;
+
if (f !== null)
uci.set('network', section_id, 'keepalive', '%d %d'.format(f, i));
else
o = s.taboption('advanced', form.Value, '_keepalive_interval', _('LCP echo interval'), _('Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold'));
o.placeholder = '1';
- o.datatype = 'min(1)';
+ o.datatype = 'and(uinteger,min(1))';
o.write = write_keepalive;
o.remove = write_keepalive;
o.cfgvalue = function(section_id) {