* Better form submit format

* Allow comments in menu.json
This commit is contained in:
Bryan Ashby
2015-03-25 23:23:14 -06:00
parent d1b0663b5d
commit 4c4b0de54c
7 changed files with 118 additions and 80 deletions

View File

@@ -1,39 +0,0 @@
/* jslint node: true */
'use strict';
var MenuModule = require('../core/menu_module.js').MenuModule;
var ansi = require('../core/ansi_term.js');
exports.moduleInfo = {
name : 'Goodbye',
desc : 'Log off / Goodbye Module',
author : 'NuSkooler',
};
exports.getModule = GoodbyeModule;
function GoodbyeModule(menuConfig) {
MenuModule.call(this, menuConfig);
}
require('util').inherits(GoodbyeModule, MenuModule);
GoodbyeModule.prototype.enter = function(client) {
GoodbyeModule.super_.prototype.enter.call(this, client);
};
GoodbyeModule.prototype.beforeArt = function() {
GoodbyeModule.super_.prototype.beforeArt.call(this);
this.client.term.write(ansi.resetScreen());
};
GoodbyeModule.prototype.mciReady = function(mciMap) {
GoodbyeModule.super_.prototype.mciReady.call(this, mciMap);
};
GoodbyeModule.prototype.finishedLoading = function() {
GoodbyeModule.super_.prototype.finishedLoading.call(this);
this.client.end();
};

39
mods/logoff.js Normal file
View File

@@ -0,0 +1,39 @@
/* jslint node: true */
'use strict';
var MenuModule = require('../core/menu_module.js').MenuModule;
var ansi = require('../core/ansi_term.js');
exports.moduleInfo = {
name : 'LogOff',
desc : 'Log off / Goodbye Module',
author : 'NuSkooler',
};
exports.getModule = LogOffModule;
function LogOffModule(menuConfig) {
MenuModule.call(this, menuConfig);
}
require('util').inherits(LogOffModule, MenuModule);
LogOffModule.prototype.enter = function(client) {
LogOffModule.super_.prototype.enter.call(this, client);
};
LogOffModule.prototype.beforeArt = function() {
LogOffModule.super_.prototype.beforeArt.call(this);
this.client.term.write(ansi.resetScreen());
};
LogOffModule.prototype.mciReady = function(mciMap) {
LogOffModule.super_.prototype.mciReady.call(this, mciMap);
};
LogOffModule.prototype.finishedLoading = function() {
LogOffModule.super_.prototype.finishedLoading.call(this);
this.client.end();
};

View File

@@ -71,9 +71,15 @@ MatrixModule.prototype.mciReady = function(mciMap) {
vc.on('submit', function onSubmit(form) {
console.log(form);
if(0 === form.id && 1 === form.viewId) {
// :TODO: fix me. Need to finalize form data. Current is kinda... meh.
self.client.gotoMenuModule('goodbye');
var viewModuleMap = {
'0' : 'login',
'1' : 'new',
'2' : 'logoff',
};
if(0 === form.id && 1 === form.submitId) {
console.log(viewModuleMap[form.values[1]]);
self.client.gotoMenuModule(viewModuleMap[form.values[1]]);
}
});

View File

@@ -1,4 +1,7 @@
{
/*
Menu Configuration
*/
"matrix" : {
"art" : "matrix",
"module" : "matrix"
@@ -7,8 +10,8 @@
"art" : "login",
"module" : "login"
},
"goodbye" : {
"logoff" : {
"art" : "logoff",
"module" : "goodbye"
"module" : "logoff"
}
}