From a24f3520a43cf59d0ac88270ba956c9aa67de469 Mon Sep 17 00:00:00 2001 From: Nicolai Tellefsen Date: Thu, 17 Mar 2016 22:38:32 +0100 Subject: 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. --- web/nms.gathering.org/js/nms-info-box.js | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) (limited to 'web/nms.gathering.org/js/nms-info-box.js') 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(); } } -- cgit v1.2.3