aboutsummaryrefslogtreecommitdiffstats
path: root/web/nms.gathering.org/js/nms-info-box.js
diff options
context:
space:
mode:
authorNicolai Tellefsen <niccofyren@gmail.com>2016-03-21 20:26:58 +0100
committerNicolai Tellefsen <niccofyren@gmail.com>2016-03-21 20:26:58 +0100
commitd528cad67897dd2c3b98ec15a82868ac2764e2c7 (patch)
treee22c00a1274e934352754e99b3cfce3619af2bf3 /web/nms.gathering.org/js/nms-info-box.js
parent4eedfbd1a9cbb447690f86fece8b2ff5a5fc2626 (diff)
NMS: Tweak search highlight and hotkeys
Diffstat (limited to 'web/nms.gathering.org/js/nms-info-box.js')
-rw-r--r--web/nms.gathering.org/js/nms-info-box.js20
1 files changed, 14 insertions, 6 deletions
diff --git a/web/nms.gathering.org/js/nms-info-box.js b/web/nms.gathering.org/js/nms-info-box.js
index 5f16ec2..8527a03 100644
--- a/web/nms.gathering.org/js/nms-info-box.js
+++ b/web/nms.gathering.org/js/nms-info-box.js
@@ -436,6 +436,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)) {
@@ -454,23 +455,30 @@ 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);
+ break;
+ case 27:
+ document.getElementById("searchbox").dataset.match = '';
+ document.getElementById("searchbox").value = '';
+ nmsInfoBox._search();
+ nmsInfoBox.hide();
+ break;
}
}