This commit is contained in:
2016-02-16 00:47:28 +01:00
parent 45a0e86e74
commit 9677666b48
16 changed files with 252 additions and 283 deletions

View File

@@ -55,11 +55,9 @@ NPGClient.evtHandler = {
*/
//
userLogin : function (evt) {
//
var self = this;
var oldNameWidth, newNameWidth;
var size = NPGClient.PageHandler.getPageByName('login').ctx.measureText(NPGClient.userName).width;
oldNameWidth = 2.1*size; // corr factor 2.1
//
switch (evt.keyCode) {
case NPGClient.KEYS.ENTER:
if (NPGClient.SocketIO.isConnected) {
@@ -67,32 +65,27 @@ NPGClient.evtHandler = {
NPGClient.SocketIO.sendMsg('registration', NPGClient.userName);
}
} else {
//self.serverExit();
NPGClient.Utils.resetName();
NPGClient.PageHandler.getCurrPageUIElemByName('login_cursor').reset();
}
break;
case NPGClient.KEYS.BACKSPACE:
//--- remove a character
evt.preventDefault();
NPGClient.Utils.removeChar();
newNameWidth = NPGClient.PageHandler.getPageByName('login').ctx.measureText(NPGClient.userName).width
// newNameWidth = 2.1*self.ctx.measureText(self.tmpName).width; // corr factor 2.1
// self.cursor.shiftX(newNameWidth - oldNameWidth);
if (!NPGClient.Utils.nameEmpty()) {
NPGClient.Utils.removeChar();
NPGClient.PageHandler.getCurrPageUIElemByName('login_cursor').translateX(-15);
}
break;
default:
//console.log(evt.keyCode + ' ' + self.isValidKey(evt.keyCode));
//--- add character
if (self.isValidKey(evt.keyCode)) {
//self.cursor.stopBlink;
if (self.isValidKey(evt.keyCode) && !NPGClient.Utils.maxNameSize()) {
NPGClient.Utils.addChar(evt.keyCode);
//newNameWidth = 2.1*self.ctx.measureText(self.tmpName).width; // corr factor 2.1
//if (self.validName()) {
// self.cursor.shiftX(newNameWidth - oldNameWidth);
//}
//self.cursor.startBlink;
newNameW = NPGClient.ui.ctx.measureText(NPGClient.userName).width;
NPGClient.PageHandler.getCurrPageUIElemByName('login_cursor').translateX(15);
}
break;
}
},
}
}