diff options
author | Nicolai Tellefsen <niccofyren@gmail.com> | 2016-03-21 00:26:14 +0100 |
---|---|---|
committer | Nicolai Tellefsen <niccofyren@gmail.com> | 2016-03-21 00:26:14 +0100 |
commit | 3d840d42ab7a05059b457fd5ffb22b6c3beea8a6 (patch) | |
tree | 1df8bbb38c540114e93e8e81cf8562b14a18e0a2 /web/nms.gathering.org/js/nms-info-box.js | |
parent | e763a7874093d7c36b89424b116dd99fc2966312 (diff) |
NMS: Improve search GO-button event listener
Diffstat (limited to 'web/nms.gathering.org/js/nms-info-box.js')
-rw-r--r-- | web/nms.gathering.org/js/nms-info-box.js | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/web/nms.gathering.org/js/nms-info-box.js b/web/nms.gathering.org/js/nms-info-box.js index d484cc8..88bc7d7 100644 --- a/web/nms.gathering.org/js/nms-info-box.js +++ b/web/nms.gathering.org/js/nms-info-box.js @@ -452,13 +452,19 @@ nmsInfoBox._search = function() { } if(matches.length == 1) { document.getElementById("searchbox-submit").classList.add("btn-primary"); - document.getElementById("searchbox").addEventListener("keydown",function(e) { - if(e.keyCode == 13) - nmsInfoBox.showWindow("switchInfo",matches[0]); - }); + 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").removeEventListener("keydown",false); + 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); } } |