webui: small main reorganisation

This commit is contained in:
zeners 2016-01-26 11:55:48 +01:00
parent cdddab1f6a
commit b2b96c097f
2 changed files with 13 additions and 6 deletions

View File

@ -17,7 +17,14 @@ function sendPassword(data) {
}); });
} }
function Page(content, runst){ function Page(menu){
this.menu = menu;
this.module = (menu.module != undefined) ? menu.module : menu.name;
this.path = menu.path != undefined ? menu.path : ("/" + menu.name);
var runst = menu.runstate;
var content = require(module);
this.view = function(){ this.view = function(){
var runstate = rs("control/runstate"); var runstate = rs("control/runstate");
var needpasswd = rs("control/password"); var needpasswd = rs("control/password");
@ -85,10 +92,9 @@ module.exports = {
menudef.nodes.map(function(menu){ menudef.nodes.map(function(menu){
if (menu.action === undefined) { if (menu.action === undefined) {
var path = menu.path != undefined ? menu.path : ("/" + menu.name); var p = new Page(menu)
var module = menu.module != undefined ? menu.module : menu.name console.log("adding route " + menu.name + " for " + p.path + " with module " + p.module);
console.log("adding route " + menu.name + " for " + path + " with module " + module); maps[p.path] = p;
maps[path] = new Page(require(module), menu.runstate);
} }
}); });
m.route.mode = "hash"; m.route.mode = "hash";

View File

@ -161,7 +161,8 @@ function checkFocus(){
ctrl.focus(); ctrl.focus();
m.initControl = undefined; m.initControl = undefined;
} else { } else {
console.log("focus-control '" + m.initControl + "' not found!") console.log("focus-control '" + m.initControl + "' not found!");
m.initControl = undefined;
} }
} }
} }