From 78684bd2f31a6e8bd174219d363d116e1273f6a2 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Mon, 23 May 2016 23:38:40 +0200 Subject: front: Use RegExp all over for searches creates some interesting opportunities, as searches can be combined. E.g.: '(row\d+-2|distro0|presse) can be used to mark multiple different switches now. Or '(::1$|^noc$|127.*\.14$) etc. Could probably get rid of the ""-hack now too. It was mainly meant for the automatic oplog entry on switch-creation, which can now use "^switch$" instead. --- web/js/nms-search.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'web/js/nms-search.js') diff --git a/web/js/nms-search.js b/web/js/nms-search.js index f5cfb8c..46c0571 100644 --- a/web/js/nms-search.js +++ b/web/js/nms-search.js @@ -8,6 +8,7 @@ var nmsSearch = nmsSearch || { nmsSearch.helpText = [ "The search box can be used to identify switches in several ways. The simplest is by name.", "Searching by name can be done by just entering text, or if you want to match \"foobar1\" but not \"foobar15\" you can enclose the name in quotation marks. E.g.: foobar1 matches foobar1 and foobar1123123123, while \"foobar1\" only matches exactly foobar1.", + "All text-oriented searches are regular expressions. ^row\\d-2$ matches row1-2, row2-2, etc, but not row13-2 or rowx-2.", "If you are using the non-public version of Gondul, you can also perform smart searches.", "Distro search: Type the name of a distro-switch and all access switches registered to that distro switch will also be hilighted.", 'Active ports: Type "active>x", "active30".', @@ -64,22 +65,22 @@ nmsSearch.searchTest = function(id, sw) { } } catch (e) {} try { - if (nmsData.smanagement.switches[sw].mgmt_v4_addr.match(id)) { + if (re.test(nmsData.smanagement.switches[sw].mgmt_v4_addr)) { return true; } - if (nmsData.smanagement.switches[sw].mgmt_v6_addr.match(id)) { + if (re.test(nmsData.smanagement.switches[sw].mgmt_v6_addr)) { return true; } } catch (e) {} try { - if (nmsData.smanagement.switches[sw].subnet4.match(id)) { + if (re.test(nmsData.smanagement.switches[sw].subnet4)) { return true; } - if (nmsData.smanagement.switches[sw].subnet6.match(id)) { + if (re.test(nmsData.smanagement.switches[sw].subnet6)) { return true; } } catch (e) {} - if (nmsData.snmp.snmp[sw].misc.sysDescr[0].toLowerCase().match(id)) { + if (re.test(nmsData.snmp.snmp[sw].misc.sysDescr[0])) { return true; } } catch (e) { -- cgit v1.2.3