|
@@ -36,7 +36,7 @@ function createMainNavigation() {
|
|
|
var nav = [
|
|
|
{name: 'Параметры', link: 'index.html', child:['/index.html', '/'], access: 2},
|
|
|
{name: 'Настройки', link: 'settings.html', child: '/settings.html', access: 1},
|
|
|
-
|
|
|
+ {name: 'Уведомления', link: 'snmp.html', child: '/snmp.html', access: 1},
|
|
|
{name: 'Информация', link: 'info.html', child: '/info.html', access: 2},
|
|
|
{name: 'Журнал', link: 'history.html', child: ['/history.html', '/ups_history.html'], access: 2}
|
|
|
];
|
|
@@ -254,6 +254,154 @@ function getParam(e,x) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+var snmpArray = [];
|
|
|
+function snmpPush(e){
|
|
|
+ var index = snmpArray.indexOf(e);
|
|
|
+ if (index !== -1) {
|
|
|
+ snmpArray.splice(index, 1);
|
|
|
+ } else {
|
|
|
+ snmpArray.push(e);
|
|
|
+ }
|
|
|
+ if (snmpArray.length > 0){
|
|
|
+ $('sa').style.height = 'auto';
|
|
|
+ $('sa').style.opacity = 1;
|
|
|
+ $('sa_length').textContent = snmpArray.length;
|
|
|
+ } else {
|
|
|
+ $('sa').style.height = 0;
|
|
|
+ $('sa').style.opacity = 0;
|
|
|
+ }
|
|
|
+ checkAllStates();
|
|
|
+}
|
|
|
+
|
|
|
+function rowsToSubmit(array){
|
|
|
+ var rows = [];
|
|
|
+ for (var i = 0; i < array.length; i++) {
|
|
|
+ var parent = $(array[i]).parentNode.parentNode;
|
|
|
+ array[i];
|
|
|
+ var index = rows.indexOf(parent.id);
|
|
|
+ if (index !== -1) {
|
|
|
+ rows[index] = parent.id;
|
|
|
+ } else {
|
|
|
+ rows.push(parent.id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return rows;
|
|
|
+}
|
|
|
+
|
|
|
+function createSNMP(id){
|
|
|
+ getJSON('snmp.cgi', function(data) {
|
|
|
+ $(id).innerHTML = '';
|
|
|
+ for (var i = 0; i < data.params.length; i++) {
|
|
|
+ var param = data.params[i];
|
|
|
+ var param_row = document.createElement('tr');
|
|
|
+ param_row.id = param.name;
|
|
|
+ var param_name = document.createElement('td');
|
|
|
+ param_name.textContent = param.label;
|
|
|
+ param_row.appendChild(param_name);
|
|
|
+ for (var x = 0; x < 1; x++) {
|
|
|
+ var cb_td = document.createElement('td');
|
|
|
+ var cb_input = document.createElement('input');
|
|
|
+ cb_input.type = 'checkbox';
|
|
|
+ cb_input.checked = getParam(param,x);
|
|
|
+ cb_input.id = 'cb'+x+param.name;
|
|
|
+ cb_input.className = 'checkbox';
|
|
|
+ cb_input.setAttribute('onchange', 'snmpPush(this.id)');
|
|
|
+ cb_td.appendChild(cb_input);
|
|
|
+ param_row.appendChild(cb_td);
|
|
|
+ }
|
|
|
+ var param_snmp = document.createElement('td');
|
|
|
+ $(id).appendChild(param_row);
|
|
|
+ }
|
|
|
+ utcParam = data.utc;
|
|
|
+
|
|
|
+ checkAllStates();
|
|
|
+ setCookie('netsettings_changed', data.netsettings_changed);
|
|
|
+ setCookie('profilaction_changed', data.profilaction_changed);
|
|
|
+ setCookie('need_confirm', data.need_confirm);
|
|
|
+ checkNotify();
|
|
|
+ }, function(error){});
|
|
|
+}
|
|
|
+
|
|
|
+function snmpSaSubmit(){
|
|
|
+ var url = 'snmp.cgi?';
|
|
|
+ var string = '';
|
|
|
+ for (var i = 0; i < rowsToSubmit(snmpArray).length; i++) {
|
|
|
+ if(i == rowsToSubmit(snmpArray).length-1) {
|
|
|
+ string+= $(rowsToSubmit(snmpArray)[i]).id + '=' + arrayToBitMask(rowsToSubmit(snmpArray)[i]);
|
|
|
+ } else {
|
|
|
+ string+= $(rowsToSubmit(snmpArray)[i]).id + '=' + arrayToBitMask(rowsToSubmit(snmpArray)[i]) + '&';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (string){
|
|
|
+ loadXMLDoc( url + string, 'GET', updatepage);
|
|
|
+ } else {
|
|
|
+ updatepage();
|
|
|
+ }
|
|
|
+ $('sa').style.height = 0;
|
|
|
+ $('sa').style.opacity = 0;
|
|
|
+ snmpArray = [];
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+function snmpChangeCancel(){
|
|
|
+ updatepage();
|
|
|
+ $('sa').style.height = 0;
|
|
|
+ $('sa').style.opacity = 0;
|
|
|
+ snmpArray = [];
|
|
|
+}
|
|
|
+
|
|
|
+function checkAll(e,id){
|
|
|
+ var rows = $('snmp_list').getElementsByTagName('tr');
|
|
|
+ if (!$(id).checked && $(id).indeterminate){
|
|
|
+ for (var i = 0; i < rows.length; i++) {
|
|
|
+ var input = rows[i].children[e].getElementsByTagName('input')[0];
|
|
|
+ input.checked = true;
|
|
|
+ snmpPush(input.id);
|
|
|
+ }
|
|
|
+ } else if (!$(id).checked && !$(id).indeterminate) {
|
|
|
+ for (var i = 0; i < rows.length; i++) {
|
|
|
+ var input = rows[i].children[e].getElementsByTagName('input')[0];
|
|
|
+ input.checked = false;
|
|
|
+ snmpPush(input.id);
|
|
|
+ }
|
|
|
+ } else if ($(id).checked) {
|
|
|
+ for (var i = 0; i < rows.length; i++) {
|
|
|
+ var input = rows[i].children[e].getElementsByTagName('input')[0];
|
|
|
+ input.checked = true;
|
|
|
+ snmpPush(input.id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function checkAllStates(){
|
|
|
+ allCheckboxStates(1,'cb_snmp');
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+function allCheckboxStates(e,id){
|
|
|
+ var rows = $('snmp_list').getElementsByTagName('tr');
|
|
|
+ var c = [];
|
|
|
+ var nc = [];
|
|
|
+ for (var i = 0; i < rows.length; i++) {
|
|
|
+ var input = rows[i].children[e].getElementsByTagName('input')[0];
|
|
|
+ if (input.checked){
|
|
|
+ c.push(input.id);
|
|
|
+ } else {
|
|
|
+ nc.push(input.id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (c.length && nc.length) {
|
|
|
+ $(id).indeterminate = true;
|
|
|
+ } else if (c.length == rows.length) {
|
|
|
+ $(id).checked = true;
|
|
|
+ $(id).indeterminate = false;
|
|
|
+ } else {
|
|
|
+ $(id).checked = false;
|
|
|
+ $(id).indeterminate = false;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
function decimalToBinary(decimal) {
|
|
|
return (decimal >>> 0).toString(2);
|
|
|
}
|
|
@@ -270,9 +418,9 @@ function cbToBit(id, n){
|
|
|
function arrayToBitMask(id){
|
|
|
|
|
|
var snmp = cbToBit('cb0'+id, 0);
|
|
|
- var sms = cbToBit('cb1'+id, 1);
|
|
|
+
|
|
|
|
|
|
- return binaryToDecimal( decimalToBinary( (snmp | sms) ) );
|
|
|
+ return binaryToDecimal( decimalToBinary( (snmp) ) );
|
|
|
}
|
|
|
|
|
|
function NotificationBox (id, options) {
|