aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMagnus Kirø <magnuskiro@gmail.com>2016-03-21 10:33:40 +0100
committerMagnus Kirø <magnuskiro@gmail.com>2016-03-21 10:33:40 +0100
commit8def7ece0c59dcc2753800f4b97b4d409b1ef949 (patch)
tree4dbbabfecf20b090611c79e9d88a6302738e5886
parent4dffc5e5431c83595f2bd102f120ad6def011d22 (diff)
parent3d840d42ab7a05059b457fd5ffb22b6c3beea8a6 (diff)
Merge branch 'master' of github.com:tech-server/tgmanage into dev
-rw-r--r--web/nms.gathering.org/index.html2
-rw-r--r--web/nms.gathering.org/js/nms-info-box.js21
2 files changed, 20 insertions, 3 deletions
diff --git a/web/nms.gathering.org/index.html b/web/nms.gathering.org/index.html
index bdb5912..db1acfa 100644
--- a/web/nms.gathering.org/index.html
+++ b/web/nms.gathering.org/index.html
@@ -92,7 +92,7 @@
<div class="input-group input-group-sm">
<input id="searchbox" type="text" class="form-control" placeholder="Filter" oninput="nmsInfoBox._search()" />
<span class="input-group-btn">
- <button class="btn btn-default" type="button" onclick="nmsInfoBox.show(document.getElementById('searchbox').value);">Go!</button>
+ <button id="searchbox-submit" class="btn btn-default" type="button" onclick="nmsInfoBox.showWindow('switchInfo',document.getElementById('searchbox').value);">Go!</button>
</span>
</div>
</div>
diff --git a/web/nms.gathering.org/js/nms-info-box.js b/web/nms.gathering.org/js/nms-info-box.js
index 49825bc..88bc7d7 100644
--- a/web/nms.gathering.org/js/nms-info-box.js
+++ b/web/nms.gathering.org/js/nms-info-box.js
@@ -425,7 +425,7 @@ nmsInfoBox._searchSmart = function(id, sw) {
nmsInfoBox._search = function() {
var el = document.getElementById("searchbox");
var id = false;
- var hits = 0;
+ var matches = [];
if (el) {
id = el.value;
}
@@ -433,13 +433,14 @@ nmsInfoBox._search = function() {
for(var sw in nmsData.switches.switches) {
if (id[0] == "/") {
if (nmsInfoBox._searchSmart(id.slice(1),sw)) {
+ matches.push(sw);
nmsMap.setSwitchHighlight(sw,true);
} else {
nmsMap.setSwitchHighlight(sw,false);
}
} else {
if(sw.indexOf(id) > -1) {
- hits++;
+ matches.push(sw);
nmsMap.setSwitchHighlight(sw,true);
} else {
nmsMap.setSwitchHighlight(sw,false);
@@ -449,6 +450,22 @@ nmsInfoBox._search = function() {
} else {
nmsMap.removeAllSwitchHighlights();
}
+ 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);
+ }
}