aboutsummaryrefslogtreecommitdiffstats
path: root/web/js/nms.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/js/nms.js')
-rw-r--r--web/js/nms.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/web/js/nms.js b/web/js/nms.js
index ca87f5d..a3706b9 100644
--- a/web/js/nms.js
+++ b/web/js/nms.js
@@ -813,3 +813,24 @@ function startNowPicker(now) {
}
});
}
+
+/*
+ * Test if the entire path specified in the arrary "ar" exists under the
+ * specified root.
+ *
+ * E.g.:
+ * if (!testTree(nmsData,['snmp','snmp',sw,'misc'])) {
+ * do stuff with nmsData.snmp.snmp[sw].misc
+ * }
+ *
+ */
+function testTree(root, ar) {
+ if (ar == undefined || root == undefined)
+ return false;
+ for (var i in ar) {
+ root = root[ar[i]];
+ if (root == undefined)
+ return false;
+ }
+ return true;
+}