-$.fn.populateSubmenu = function(header, items, translator) {
- var submenuHeader = $("<li/>").append($("<a/>", {text : header, href : "#"}));
- var submenu = $("<ul/>", {"class" : "submenu"});
-
- for (var item in items) {
- var info = translator(item, items);
- submenu.append($("<li/>").append(
- $("<a/>", {text : info.text,
- href : info.href, target : "_blank"})
- ));
- }
-
- this.append(submenuHeader.append(submenu));
- return this;
-};
-
-/**
- * Populates the navigation bar
- */
-$.fn.populateNavbar = function () {
- var menu = $("<ul/>", {"class" : "menu"});
- var sensorTranslator = function(item, items) {
- var href = mctx.api + "sensors?start_time=0&format=tsv&id=" + item;
- return {text : items[item].name, href : href};
- };
- var actuatorTranslator = function(item, items) {
- var href = mctx.api + "actuators?start_time=0&format=tsv&id=" + item;
- return {text : items[item].name, href : href};
- };
-
- menu.populateSubmenu("Sensor data", mctx.sensors, sensorTranslator);
- menu.populateSubmenu("Actuator data", mctx.actuators, actuatorTranslator);
- menu.appendTo(this);
- return this;
+$.fn.populateNavMenu = function() {
+ var root = $("<ul/>")
+ for (var i = 0; i < mctx.menu.length; i++) {
+ var item = mctx.menu[i];
+ var entry = $("<li/>").append(
+ $("<a/>", {text : item.text, href: item.href})
+ );
+ root.append(entry);
+ }
+ $(this).append(root);
+ return this;