* Fix EtherTerm backspace key

* Better WIP apply art / module
* Better WIP 'enter' and 'leave' events from VC
This commit is contained in:
Bryan Ashby
2015-04-14 00:19:14 -06:00
parent b0103cb178
commit 77600d3dde
10 changed files with 150 additions and 60 deletions

View File

@@ -27,10 +27,8 @@ function ApplyModule(menuConfig) {
var self = this;
this.clearForm = function() {
[ 1, 2, ].forEach(function onId(id) {
self.viewController.getView(id).clearText();
});
this.menuMethods.submitApplication = function(args) {
console.log('do submit')
};
}
@@ -49,46 +47,63 @@ ApplyModule.prototype.mciReady = function(mciMap) {
var self = this;
self.viewController = self.addViewController(new ViewController(self.client));
self.viewController = self.addViewController(new ViewController({ client : self.client } ));
self.viewController.loadFromMCIMapAndConfig( { mciMap : mciMap, menuConfig : self.menuConfig }, function onViewReady(err) {
var usernameView = self.viewController.getView(1);
var userExistsView = self.viewController.getView(10);
usernameView.on('leave', function leave() {
var passwordView = self.viewController.getView(9);
var pwConfirmView = self.viewController.getView(10);
var statusView = self.viewController.getView(11);
self.viewController.on('leave', function leaveView(view) {
switch(view.getId()) {
case 1 :
user.getUserIdAndName(view.getViewData(), function userIdAndName(err) {
var alreadyExists = !err;
if(alreadyExists) {
statusView.setText('Username unavailable!');
self.viewController.switchFocus(1); // don't allow to leave
} else {
statusView.setText('');
self.viewController.switchFocus(2);
}
});
break;
}
});
/*
usernameView.on('leave', function leaveUsername() {
user.getUserIdAndName(usernameView.getViewData(), function userIdAndName(err) {
if(!err) {
userExistsView.setText('That username already exists!');
var alreadyExists = !err;
if(alreadyExists) {
statusView.setText('Username unavailable!');
self.viewController.switchFocus(1); // don't allow to leave
} else {
userExistsView.setText('');
statusView.setText('');
self.viewController.switchFocus(2);
}
//if(11 !== self.viewController.getFocusedView()) {
self.viewController.switchFocus(2);
//}
});
});
var pwView = self.viewController.getView(8);
var pwConfirmView = self.viewController.getView(9);
var pwSecureView = self.viewController.getView(11);
var pwConfirmNoticeView = self.viewController.getView(12);
// :TODO: show a secure meter here instead
pwView.on('leave', function pwLeave() {
if(pwView.getViewData().length > 3) {
pwSecureView.setColor(32);
pwSecureView.setText('Secure');
passwordView.on('leave', function leavePw() {
if(passwordView.getViewData().length < 3) {
statusView.setText('Password too short!');
self.viewController.switchFocus(9);
} else {
pwSecureView.setColor(31);
pwSecureView.setText('Insecure!');
statusView.setText('');
}
});
pwConfirmView.on('leave', function confirmPwLeave() {
if(pwView.getViewData() !== pwConfirmView.getViewData()) {
pwConfirmNoticeView.setText('Passwords must match!');
pwConfirmView.on('leave', function leavePwConfirm() {
if(passwordView.getViewData() !== pwConfirmView.getViewData()) {
statusView.setText('Passwords must match!');
self.viewController.switchFocus(9);
} else {
pwConfirmNoticeView.setText('');
statusView.setText('');
}
});
*/
});
};

Binary file not shown.

View File

@@ -1,4 +1,7 @@
{
"name" : "Nu Mayan",
"author" : "NuSkooler"
"author" : "NuSkooler",
"config" : {
"passwordChar" : "*"
}
}

View File

@@ -80,7 +80,7 @@ LoginModule.prototype.mciReady = function(mciMap) {
var self = this;
self.viewController = self.addViewController(new ViewController(self.client));
self.viewController = self.addViewController(new ViewController( { client : self.client } ));
self.viewController.loadFromMCIMapAndConfig( { mciMap : mciMap, menuConfig : self.menuConfig }, function onViewReady(err) {
});
};

View File

@@ -66,7 +66,7 @@ MatrixModule.prototype.mciReady = function(mciMap) {
// 2 - Bye!
//
//var vc = new ViewController(client);
var vc = self.addViewController(new ViewController(self.client));
var vc = self.addViewController(new ViewController({ client : self.client } ));
vc.on('submit', function onSubmit(form) {
console.log(form);

View File

@@ -105,17 +105,44 @@
"module" : "apply",
"form" : {
"0" : {
"BN13BN14ET1ET2ET3ET4ET5ET6ET7ET8ET9TL10TL11TL12" : {
"BN12BN13ET1ET10ET2ET3ET4ET5ET6ET7ET8ET9TL11" : {
"mci" : {
"ET1" : {
"focus" : true
},
"BN13" : {
"BN12" : {
"submit" : true,
"text" : "Apply"
},
"BN14" : {
"BN13" : {
"submit" : true,
"text" : "Cancel"
}
},
"submit" : {
"12" : [ // Apply
{
"value" : { "12" : null },
"action" : "@method:submitApplication",
"args" : {
"username" : "{1}",
"realName" : "{2}",
"age" : "{3}",
"sex" : "{4}",
"location" : "{5}",
"affils" : "{6}",
"email" : "{7}",
"web" : "{8}",
"password" : "{9}"
}
}
],
"13" : [ // Cancel
{
"value" : { "13" : null },
"action" : "@menu:matrix"
}
]
}
}
}

View File

@@ -34,7 +34,7 @@ StandardMenuModule.prototype.mciReady = function(mciMap) {
var self = this;
var vc = self.addViewController(new ViewController(self.client));
var vc = self.addViewController(new ViewController({ client : self.client } ));
vc.loadFromMCIMapAndConfig( { mciMap : mciMap, menuConfig : self.menuConfig }, function onViewReady(err) {
if(err) {
console.log(err);