enigma-bbs/mods/matrix.js

91 lines
2.2 KiB
JavaScript
Raw Normal View History

2014-10-17 02:21:06 +00:00
/* jslint node: true */
'use strict';
var ansi = require('../core/ansi_term.js');
var art = require('../core/art.js');
var user = require('../core/user.js');
var theme = require('../core/theme.js');
var MenuModule = require('../core/menu_module.js').MenuModule;
//var view = require('../core/view.js');
var textView = require('../core/text_view.js');
var editTextView = require('../core/edit_text_view.js');
2014-11-05 06:50:42 +00:00
var ViewController = require('../core/view_controller.js').ViewController;
//var async = require('async');
2014-10-20 03:06:39 +00:00
// :TODO: clean up requires
// :TODO: rename to matrix.js
2014-10-17 02:21:06 +00:00
exports.moduleInfo = {
name : 'Matrix',
desc : 'Standardish Matrix',
author : 'NuSkooler',
};
exports.getModule = MatrixModule;
2015-03-23 04:52:04 +00:00
function MatrixModule(menuConfig) {
MenuModule.call(this, menuConfig);
}
require('util').inherits(MatrixModule, MenuModule);
MatrixModule.prototype.enter = function(client) {
2015-03-23 04:52:04 +00:00
MatrixModule.super_.prototype.enter.call(this, client);
};
MatrixModule.prototype.beforeArt = function() {
MatrixModule.super_.prototype.beforeArt.call(this);
};
2015-03-23 04:52:04 +00:00
MatrixModule.prototype.mciReady = function(mciMap) {
MatrixModule.super_.prototype.mciReady.call(this, mciMap);
var self = this;
if(mciMap.ET1 && mciMap.ET2 && mciMap.BN1 && mciMap.BN2 && mciMap.BN3) {
//
// Form via EditTextViews and ButtonViews
// * ET1 - userName
// * ET2 - password
// * BN1 - Login
// * BN2 - New
// * BN3 - Bye!
//
} else if(mciMap.VM1) {
//
// Menu via VerticalMenuView
//
// * VM1 - menu with the following items:
// 0 - Login
// 1 - New
// 2 - Bye!
//
//var vc = new ViewController(client);
var vc = self.addViewController(new ViewController({ client : self.client } ));
2015-03-23 04:52:04 +00:00
vc.on('submit', function onSubmit(form) {
console.log(form);
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]]);
}
2015-03-23 04:52:04 +00:00
});
vc.loadFromMCIMap(mciMap);
vc.setViewOrder();
// :TODO: Localize
vc.getView(1).setItems(['Login', 'New User', 'Goodbye!']);
vc.getView(1).submit = true;
vc.switchFocus(1);
}
2015-03-23 05:16:49 +00:00
};