diff options
author | Kristian Lyngstøl <kly@kly.no> | 2017-04-20 12:09:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-20 12:09:09 +0200 |
commit | 50b648bf3814e8e7e288965dc8fae987392efd55 (patch) | |
tree | b7b99ba2d97139826eb5491367b84b3e9b849fef /web/js/nms-info-box.js | |
parent | a86fa790950906f0d0f32d2b3d2069fb11d34c98 (diff) | |
parent | 10f6ab7d5b9f5c9abcdfcd66104b24c3ff47133c (diff) |
Merge pull request #155 from msbone/master
Added a basic search results page and search on tags
Diffstat (limited to 'web/js/nms-info-box.js')
-rw-r--r-- | web/js/nms-info-box.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/web/js/nms-info-box.js b/web/js/nms-info-box.js index b902a69..66b81b9 100644 --- a/web/js/nms-info-box.js +++ b/web/js/nms-info-box.js @@ -76,6 +76,16 @@ var nmsInfoBox = nmsInfoBox || { } } }, + { + 'id': 'searchResults', + 'title': 'Search Results', + 'views': { + 'initial': { + 'name': 'Search Results', + 'panels': ['searchResults'] + } + } + }, { 'id': 'inventoryListing', 'title': 'Inventory listing', @@ -723,6 +733,36 @@ var searchHelpPanel = function() { }; nmsInfoBox.addPanelType("searchHelp",searchHelpPanel); + +/* + * Panel type: Search Results + * + * Show the search results + * + */ +var searchResultsPanel = function() { + var searchPage = 0; + nmsInfoPanel.call(this,"searchResults"); + this.refresh = function(reason) { + var collator = new Intl.Collator(undefined, {numeric: true, sensitivity: 'base'}); + var switches = nmsSearch.matches.sort(collator.compare); + 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); + /* * Panel type: Add switch * |