2014-10-17 02:21:06 +00:00
|
|
|
/* jslint node: true */
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
//var art = require('../core/art.js');
|
|
|
|
var ansi = require('../core/ansi_term.js');
|
|
|
|
var lineEditor = require('../core/line_editor.js');
|
|
|
|
var art = require('../core/art.js');
|
2014-10-20 05:30:44 +00:00
|
|
|
var user = require('../core/user.js');
|
2014-10-27 04:06:41 +00:00
|
|
|
var theme = require('../core/theme.js');
|
2014-10-17 02:21:06 +00:00
|
|
|
|
2014-10-22 05:12:44 +00:00
|
|
|
//var view = require('../core/view.js');
|
|
|
|
var textView = require('../core/text_view.js');
|
2014-10-23 05:41:00 +00:00
|
|
|
var editTextView = require('../core/edit_text_view.js');
|
|
|
|
var viewController = require('../core/view_controller.js');
|
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;
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
//art.getArt('SO-CC1.ANS'/* 'MATRIX'*/, { types: ['.ans'], random: true}, function onArt(err, theArt) {
|
2014-10-27 04:06:41 +00:00
|
|
|
theme.getThemeArt('MATRIX_1', 'NU-MAYAN', 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
|
|
|
|
2014-10-27 04:06:41 +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
|
|
|
}
|
|
|
|
|
2014-10-28 03:58:34 +00:00
|
|
|
console.log(mci);
|
|
|
|
|
2014-10-26 03:35:42 +00:00
|
|
|
user.authenticate('NuSkooler', 'password', client, function onAuth(isValid) {
|
|
|
|
console.log(isValid);
|
|
|
|
});
|
|
|
|
|
2014-10-24 04:18:38 +00:00
|
|
|
user.createNew({
|
2014-10-26 03:35:42 +00:00
|
|
|
userName : 'NuSkooler',
|
2014-10-24 04:18:38 +00:00
|
|
|
password : 'password',
|
|
|
|
//properties : {
|
|
|
|
// pw_pbkdf2_salt : '81b45dc699c716ac1913039138b64e3057844128cf1f9291c6475d26dab3d4a5',
|
|
|
|
// pw_pbkdf2_dk : '14856dc5d6d277e29c5bb2ca4511695203fc48260128d2a4a611be4eefa1acfa80f8656e80d3361baa3a10ce5918829e9e3a4197b0c552978b6546d2b885d93e933a1270a5e4a81af06818d1fa9f7df830bc46f6f5870f46be818a05114f77b5605477c09e987dc4faf2a939c6869dcf2a28652d5607e5cca2e987ea2003ab4e',
|
|
|
|
//}
|
|
|
|
}, function onCreated(err, id) {
|
|
|
|
if(err) {
|
|
|
|
console.log(err);
|
|
|
|
} else {
|
|
|
|
console.log('new user created: ' + id);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-10-23 05:41:00 +00:00
|
|
|
var vc = new viewController.ViewController(client);
|
|
|
|
vc.loadFromMCIMap(mci);
|
2014-10-24 04:18:38 +00:00
|
|
|
//vc.getView(3).setText('New');
|
|
|
|
//vc.getView(4).setText('Login');
|
2014-10-23 05:41:00 +00:00
|
|
|
vc.setViewOrder();
|
|
|
|
vc.switchFocus(1);
|
|
|
|
//vc.addView(etv);
|
|
|
|
//vc.switchFocus(2);
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
client.on('key press', function onKp(key, isSpecial) {
|
|
|
|
key = 'string' === typeof key ? key : key.toString();
|
|
|
|
etv.onKeyPress(key, isSpecial);
|
|
|
|
});
|
|
|
|
|
|
|
|
client.on('special key', function onSK(keyName) {
|
|
|
|
etv.onSpecialKeyPress(keyName);
|
|
|
|
});
|
|
|
|
*/
|
2014-10-22 05:12:44 +00:00
|
|
|
|
|
|
|
/*
|
2014-10-20 03:06:39 +00:00
|
|
|
var vc = new view.ViewsController(client);
|
|
|
|
vc.loadFromMCIMap(mci);
|
|
|
|
vc.setViewOrder();
|
|
|
|
vc.switchFocus(1);
|
2014-10-20 05:30:44 +00:00
|
|
|
vc.setSubmitView(2);
|
|
|
|
|
|
|
|
vc.on('action', function onAction(act) {
|
|
|
|
if('submit' === act.action) {
|
2014-10-21 04:47:13 +00:00
|
|
|
var un = vc.getView(1).value;
|
|
|
|
var pw = vc.getView(2).value;
|
|
|
|
console.log('userName: ' + un);
|
2014-10-22 05:12:44 +00:00
|
|
|
console.log('password: ' + pw);
|
2014-10-21 04:47:13 +00:00
|
|
|
|
|
|
|
user.User.loadWithCredentials(un, pw, function onUser(err, user) {
|
2014-10-20 05:30:44 +00:00
|
|
|
if(err) {
|
|
|
|
console.log(err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log(user.id);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2014-10-22 05:12:44 +00:00
|
|
|
*/
|
2014-10-17 02:21:06 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|