print('SMB_SHARES require root privileges')
return False
-# if settings.ENABLE_REBOOT: # TODO
-# print('reboot requires root privileges')
-# return False
+ if settings.ENABLE_REBOOT:
+ print('reboot requires root privileges')
+ return False
try:
import tornado # @UnusedImport
return true;
}, '');
+ $('tr[validate] input[type=text]').each(function () {
+ var $this = $(this);
+ var $tr = $this.parent().parent();
+ var required = $tr.attr('required');
+ var validate = $tr.attr('validate');
+ if (!validate) {
+ return;
+ }
+
+ makeCustomValidator($this, function (value) {
+ if (!value && required) {
+ return 'this field is required';
+ }
+
+ if (!value.toLowerCase().match(new RegExp(validate))) {
+ return 'enter a valid value';
+ }
+
+ return true;
+ }, '');
+ });
/* input value processors */
makeStrippedInput($('tr[strip=true] input[type=text]'));
var $tr = $(this);
var depends = $tr.attr('depends').split(' ');
depends.forEach(function (depend) {
- if (depend.charAt(0) == '!') {
- depend = depend.substring(1);
- }
+ depend = depend.split('=')[0];
+ depend = depend.replace(new RegExp('[^a-zA-Z0-9_]', 'g'), '');
if (depend in seenDependNames) {
return;
var depends = $tr.attr('depends').split(' ');
var conditionOk = true;
depends.every(function (depend) {
- var neg = false;
- if (depend.charAt(0) == '!') {
- neg = true;
- depend = depend.substring(1);
- }
+ var neg = depend.indexOf('!') >= 0;
+ var parts = depend.split('=');
+ var boolCheck = parts.length == 1;
+ depend = parts[0].replace(new RegExp('[^a-zA-Z0-9_$]', 'g'), '');
var control = $('#' + depend + 'Entry, #' + depend + 'Select, #' + depend + 'Slider');
var val = false;
val = control.get(0).checked;
}
}
-
- val = Boolean(val);
- if (neg) {
- val = !val;
+
+ if (boolCheck) {
+ if (neg) {
+ val = !val;
+ }
+
+ if (!val) {
+ conditionOk = false;
+ return false;
+ }
}
-
- if (!val) {
- conditionOk = false;
- return false;
+ else { /* comparison */
+ var equal = parts[parts.length - 1] == val;
+ if (equal == neg) {
+ conditionOk = false;
+ return false;
+ }
}
-
+
return true;
});
{% if config.get('ticks') %}ticks="{{config['ticks']}}"{% endif %}
{% if config.get('ticksnum') is not none %}ticksnum="{{config['ticksnum']}}"{% endif %}
{% if config.get('decimals') is not none %}decimals="{{config['decimals']}}"{% endif %}
- {% if config.get('unit') %}unit="{{config['unit']}}"{% endif %}>
+ {% if config.get('unit') %}unit="{{config['unit']}}"{% endif %}
+ {% if config.get('validate') %}validate="{{config['validate']}}"{% endif %}>
{% if config['type'] == 'separator' %}
<td colspan="100"><div class="settings-item-separator"></div></td>
{% else %}