aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOle Mathias Heggem <ole@sdok.no>2017-04-20 03:50:48 +0200
committerOle Mathias Heggem <ole@sdok.no>2017-04-20 03:50:48 +0200
commit10f6ab7d5b9f5c9abcdfcd66104b24c3ff47133c (patch)
tree1416c330dc85978da8066784a28ef7ce7360bcd0
parentb75bf7c42a3ea871b92360739011b8b387cc087e (diff)
No search-box at zero results, the search button change color on 0 (white) , 1 (green) and multiple (blue) hits
-rw-r--r--web/js/nms-info-box.js36
-rw-r--r--web/js/nms-search.js17
2 files changed, 28 insertions, 25 deletions
diff --git a/web/js/nms-info-box.js b/web/js/nms-info-box.js
index cd84ec0..66b81b9 100644
--- a/web/js/nms-info-box.js
+++ b/web/js/nms-info-box.js
@@ -746,30 +746,20 @@ var searchResultsPanel = function() {
this.refresh = function(reason) {
var collator = new Intl.Collator(undefined, {numeric: true, sensitivity: 'base'});
var switches = nmsSearch.matches.sort(collator.compare);
- if(switches.length <= 0) {
- var x = document.createElement("div");
- var c = document.createElement("p");
- c.innerText = "No results :(";
- x.appendChild(c);
- this._render(x)
+ var table = document.createElement('table');
+ table.className = "table table-condensed";
+ table.id = "searchResults-table"
+ for (var sw in switches) {
+ var row = table.insertRow(sw);
+ var cell1 = row.insertCell(0);
+ var cell2 = row.insertCell(1);
+ var cell3 = row.insertCell(2);
+ cell1.innerHTML = "<a href='#' onclick='nmsInfoBox.showWindow(\"switchInfo\",\""+switches[sw]+"\");'>"+switches[sw]+ '</a>';
+ cell2.innerHTML = nmsData.switches["switches"][switches[sw]].distro_name;
+ cell3.innerHTML = handlers[0].getInfo(switches[sw]).why;
+ }
+ this._render(table);
}
-
- else {
- var table = document.createElement('table');
- table.className = "table table-condensed";
- table.id = "searchResults-table"
- for (var sw in switches) {
- var row = table.insertRow(sw);
- var cell1 = row.insertCell(0);
- var cell2 = row.insertCell(1);
- var cell3 = row.insertCell(2);
- cell1.innerHTML = "<a href='#' onclick='nmsInfoBox.showWindow(\"switchInfo\",\""+switches[sw]+"\");'>"+switches[sw]+ '</a>';
- cell2.innerHTML = nmsData.switches["switches"][switches[sw]].distro_name;
- cell3.innerHTML = handlers[0].getInfo(switches[sw]).why;
- }
- this._render(table);
- }
- };
};
nmsInfoBox.addPanelType("searchResults",searchResultsPanel);
diff --git a/web/js/nms-search.js b/web/js/nms-search.js
index 41e5397..0726bb4 100644
--- a/web/js/nms-search.js
+++ b/web/js/nms-search.js
@@ -171,18 +171,31 @@ nmsSearch.search = function() {
nmsMap.disableHighlights();
}
if(nmsSearch.matches.length == 0) {
+ document.getElementById("searchbox-submit").classList.remove("btn-success");
+ document.getElementById("searchbox-submit").classList.remove("btn-primary");
+ }
+ else if(nmsSearch.matches.length == 1) {
+ document.getElementById("searchbox-submit").classList.add("btn-success");
document.getElementById("searchbox-submit").classList.remove("btn-primary");
- document.getElementById("searchbox").dataset.match = '';
}
+ else {
+ document.getElementById("searchbox-submit").classList.add("btn-primary");
+ document.getElementById("searchbox-submit").classList.remove("btn-success");
+ }
+
};
nmsSearch.runSearch = function() {
if(nmsSearch.matches.length == 1) {
nmsInfoBox.showWindow("switchInfo",nmsSearch.matches[0]);
}
- else {
+ else if(nmsSearch.matches.length > 1) {
nmsInfoBox.showWindow('searchResults',nmsSearch.matches.length);
}
+ else {
+ document.getElementById("searchbox-submit").classList.remove("btn-primary");
+ document.getElementById("searchbox").dataset.match = '';
+ }
};
nmsSearch._searchKeyListener = function(e) {