enigma-bbs/mods/matrix.js

165 lines
3.9 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
2014-10-17 02:21:06 +00:00
exports.moduleInfo = {
name : 'Matrix',
desc : 'Standardish Matrix',
author : 'NuSkooler',
};
//exports.entryPoint = entryPoint;
exports.getModule = MatrixModule;
function MatrixModule() {
MenuModule.call(this);
}
require('util').inherits(MatrixModule, MenuModule);
MatrixModule.prototype.enter = function(client) {
MatrixModule.super_.prototype.enter.call(this);
var self = this;
client.term.write(ansi.resetScreen());
//client.term.write('\x1b[?33h');
theme.displayThemeArt('MATRIX', client, function onMatrix(err, mciMap) {
console.log(mciMap);
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));
vc.on('submit', function onSubmit(form) {
console.log(form);
});
vc.loadFromMCIMap(mciMap);
vc.setViewOrder();
// :TODO: Localize
vc.getView(1).setItems(['Login', 'New User', 'Goodbye!']);
vc.getView(1).submit = true;
vc.switchFocus(1);
}
});
};
2014-10-17 02:21:06 +00:00
/*
2014-11-05 06:50:42 +00:00
function entryPoint(client) {
client.term.write(ansi.resetScreen());
//client.term.write('\x1b[?33h');
2014-11-05 06:50:42 +00:00
theme.displayThemeArt('MATRIX', client, function onMatrix(err, mciMap) {
console.log(mciMap);
2014-11-05 06:50:42 +00:00
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);
vc.on('submit', function onSubmit(form) {
console.log(form);
2014-11-05 06:50:42 +00:00
});
vc.loadFromMCIMap(mciMap);
vc.setViewOrder();
// :TODO: Localize
vc.getView(1).setItems(['Login', 'New User', 'Goodbye!']);
vc.getView(1).submit = true;
2014-11-05 06:50:42 +00:00
vc.switchFocus(1);
}
});
}
*/
2014-11-05 06:50:42 +00:00
/*
2014-10-17 02:21:06 +00:00
function entryPoint(client) {
var term = client.term;
2014-10-20 03:06:39 +00:00
term.write(ansi.resetScreen());
2014-10-20 05:30:44 +00:00
2014-10-17 02:21:06 +00:00
// :TODO: types, random, and others? could come from conf.mods.matrix or such
theme.getThemeArt('MCI_ET1.ANS', client.user.properties.art_theme_id, function onArt(err, theArt) {
//art.getArt('MATRIX_1.ANS', {}, function onArt(err, theArt) {
2014-10-17 02:21:06 +00:00
if(!err) {
2014-10-20 03:06:39 +00:00
art.display(theArt, { client : client, mciReplaceChar : ' ' }, function onArtDisplayed(err, mci) {
2014-10-17 02:21:06 +00:00
if(err) {
2014-10-20 03:06:39 +00:00
return;
2014-10-17 02:21:06 +00:00
}
user.authenticate('NuSkooler', 'password', client, function onAuth(isValid) {
console.log(isValid);
});
var vc = new viewController.ViewController(client);
vc.on('submit', function onSubmit(formData) {
console.log(formData);
vc.detachClientEvents();
modules.goto('test_module1', client);
});
vc.loadFromMCIMap(mci);
//vc.getView(3).setText('New');
//vc.getView(4).setText('Login');
vc.setViewOrder();
vc.getView(2).submit = true;
//vc.getView(1).setItems(['System Login', 'Apply', 'GTFO!']);
//vc.getView(2).submit = true;
//vc.getView(3).setText('Apply');
vc.switchFocus(1);
2014-10-17 02:21:06 +00:00
});
}
});
2014-11-05 06:50:42 +00:00
}
*/