aboutsummaryrefslogtreecommitdiffstats
path: root/web/nms.gathering.org/js/nms-info-box.js
diff options
context:
space:
mode:
authorMagnus Kirø <magnuskiro@gmail.com>2016-03-22 11:14:46 +0100
committerMagnus Kirø <magnuskiro@gmail.com>2016-03-22 11:14:46 +0100
commit7806081670c8c9807fc8b6628b3d7a6eff841ded (patch)
tree082e522b99cd5b864a8963523f2b3889f6cff808 /web/nms.gathering.org/js/nms-info-box.js
parente501dd7dd88bf52edd914a8f078141b91d53939b (diff)
parent2d19233ba32fd23ad7182d3cccb58cec9e377a75 (diff)
MERGE fix.
Diffstat (limited to 'web/nms.gathering.org/js/nms-info-box.js')
-rw-r--r--web/nms.gathering.org/js/nms-info-box.js77
1 files changed, 47 insertions, 30 deletions
diff --git a/web/nms.gathering.org/js/nms-info-box.js b/web/nms.gathering.org/js/nms-info-box.js
index e0f9273..24c1e31 100644
--- a/web/nms.gathering.org/js/nms-info-box.js
+++ b/web/nms.gathering.org/js/nms-info-box.js
@@ -251,6 +251,8 @@ nmsInfoBox._windowTypes.switchInfo = {
content.push([v, html]);
}
+ content.sort();
+
var table = nmsInfoBox._makeTable(content, "edit");
domObj.appendChild(table);
@@ -318,6 +320,7 @@ nmsInfoBox._windowTypes.switchInfo = {
nmsInfoBox.click = function(sw)
{
this.showWindow("switchInfo",sw);
+ this._windowTypes.switchInfo.showComments();
};
/*
@@ -394,33 +397,37 @@ nmsInfoBox._makeCommentTable = function(content) {
};
nmsInfoBox._searchSmart = function(id, sw) {
- if (nmsData.smanagement.switches[sw].distro == id) {
- console.log("ieh");
- return true;
- }
- if (id.match("[a-z]+.active")) {
- console.log("hei: " + sw);
- var family = id.match("[a-z]+");
- var limit = id;
- limit = limit.replace(family + ".active>","");
- limit = limit.replace(family + ".active<","");
- limit = limit.replace(family + ".active=","");
- var operator = id.replace(family + ".active","")[0];
- if (limit == parseInt(limit)) {
- if (operator == ">" ) {
- if (nmsData.switchstate.switches[sw][family].live > limit) {
- return true;
- }
- } else if (operator == "<") {
- if (nmsData.switchstate.switches[sw][family].live < limit) {
- return true;
- }
- } else if (operator == "=") {
- if (nmsData.switchstate.switches[sw][family].live == limit) {
- return true;
+ try {
+ if (nmsData.smanagement.switches[sw].distro == id) {
+ return true;
+ }
+ if (id.match("active")) {
+ var limit = id;
+ limit = limit.replace("active>","");
+ limit = limit.replace("active<","");
+ limit = limit.replace("active=","");
+ var operator = id.replace("active","")[0];
+ if (limit == parseInt(limit)) {
+ if (operator == ">" ) {
+ if (nmsData.switchstate.switches[sw]['totals'].live > limit) {
+ return true;
+ }
+ } else if (operator == "<") {
+ if (nmsData.switchstate.switches[sw]['totals'].live < limit) {
+ return true;
+ }
+ } else if (operator == "=") {
+ if (nmsData.switchstate.switches[sw]['totals'].live == limit) {
+ return true;
+ }
}
}
}
+ if (nmsData.snmp.snmp[sw].misc.sysDescr[0].match(id)) {
+ return true;
+ }
+ } catch (e) {
+ return false;
}
return false;
};
@@ -437,6 +444,7 @@ nmsInfoBox._search = function() {
id = el.value;
}
if(id) {
+ nmsMap.enableHighlights();
for(var sw in nmsData.switches.switches) {
if (id[0] == "/") {
if (nmsInfoBox._searchSmart(id.slice(1),sw)) {
@@ -455,23 +463,32 @@ nmsInfoBox._search = function() {
}
}
} else {
- nmsMap.removeAllSwitchHighlights();
+ nmsMap.disableHighlights();
}
if(matches.length == 1) {
document.getElementById("searchbox-submit").classList.add("btn-primary");
document.getElementById("searchbox").dataset.match = matches[0];
- document.getElementById("searchbox").addEventListener("keydown",nmsInfoBox._searchKeyListener,false);
} else {
document.getElementById("searchbox-submit").classList.remove("btn-primary");
document.getElementById("searchbox").dataset.match = '';
- document.getElementById("searchbox").removeEventListener("keydown",nmsInfoBox._searchKeyListener,false);
}
};
nmsInfoBox._searchKeyListener = function(e) {
- if(e.keyCode == 13) {
- var sw = document.getElementById("searchbox").dataset.match;
- nmsInfoBox.showWindow("switchInfo",sw);
+ switch (e.keyCode) {
+ case 13:
+ var sw = document.getElementById("searchbox").dataset.match;
+ if(sw != '') {
+ nmsInfoBox.showWindow("switchInfo",sw);
+ this._windowTypes.switchInfo.showComments();
+ }
+ break;
+ case 27:
+ document.getElementById("searchbox").dataset.match = '';
+ document.getElementById("searchbox").value = '';
+ nmsInfoBox._search();
+ nmsInfoBox.hide();
+ break;
}
};