diff options
author | Nicolai Tellefsen <niccofyren@gmail.com> | 2016-03-17 22:38:32 +0100 |
---|---|---|
committer | Nicolai Tellefsen <niccofyren@gmail.com> | 2016-03-17 22:38:32 +0100 |
commit | a24f3520a43cf59d0ac88270ba956c9aa67de469 (patch) | |
tree | fa0c91f605ccedd9cb946fb37d6686560b5ded3b /web/nms.gathering.org/js/nms-info-box.js | |
parent | b7887d4b7181e057d77a5f5d093de0400052bd0b (diff) |
NMS: Add live highlight to search
Original search only worked with exact matches. Added a simple highlight
interface to nms-map.js to enable live highlights while typing.
Diffstat (limited to 'web/nms.gathering.org/js/nms-info-box.js')
-rw-r--r-- | web/nms.gathering.org/js/nms-info-box.js | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/web/nms.gathering.org/js/nms-info-box.js b/web/nms.gathering.org/js/nms-info-box.js index b559ba2..6b13498 100644 --- a/web/nms.gathering.org/js/nms-info-box.js +++ b/web/nms.gathering.org/js/nms-info-box.js @@ -147,30 +147,21 @@ nmsInfoBox._makeCommentTable = function(content) { nmsInfoBox._search = function() { var el = document.getElementById("searchbox"); var id = false; + var hits = 0; if (el) { id = el.value; } - if (id && nmsData.switches.switches[id] != undefined) { - nmsMap.setSwitchColor(id, "red"); - window.setTimeout(function(){ - nmsMap.setSwitchColor(id, "pink"); - window.setTimeout(function(){ - nmsMap.setSwitchColor(id, "red"); - window.setTimeout(function(){ - nmsMap.setSwitchColor(id, "pink"); - window.setTimeout(function(){ - nmsMap.setSwitchColor(id, "red"); - window.setTimeout(function(){ - nmsMap.setSwitchColor(id, "pink"); - },300); - },300); - },300); - },300); - },300); - el.parentElement.classList.remove("has-error"); - el.parentElement.classList.add("has-success"); + if(id) { + for(var sw in nmsData.switches.switches) { + if(sw.indexOf(id) > -1) { + hits++; + nmsMap.setSwitchHighlight(sw,true); + } else { + nmsMap.setSwitchHighlight(sw,false); + } + } } else { - el.parentElement.classList.add("has-error"); + nmsMap.removeAllSwitchHighlights(); } } |