version v0.1.3
This commit is contained in:
68
client/lib/utils/client_utils.js
Normal file
68
client/lib/utils/client_utils.js
Normal file
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* @file client_utils.js
|
||||
* @author frtk@tetalab
|
||||
*/
|
||||
|
||||
NPGClient.Utils = {
|
||||
|
||||
/**
|
||||
* UI
|
||||
*/
|
||||
//
|
||||
setTxtStyle : function(ctx, style) {
|
||||
ctx.font = style.font;
|
||||
ctx.fillStyle = style.col;
|
||||
ctx.textAlign = style.align;
|
||||
},
|
||||
|
||||
//
|
||||
applyStyle : function(ctx, style) {
|
||||
//
|
||||
if (style.bm) {
|
||||
ctx.lineWidth = style.bw;
|
||||
ctx.strokeStyle = style.bc;
|
||||
}
|
||||
//
|
||||
if (style.fm) {
|
||||
ctx.fillStyle = style.fc;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* User Name
|
||||
*/
|
||||
//
|
||||
addChar : function(key) {
|
||||
//console.log(key + ' ' + NPGClient.userName);
|
||||
if (NPGClient.userName.length < NPGClient.NAMEMAXSIZE) {
|
||||
NPGClient.userName = NPGClient.userName + String.fromCharCode(key).toLowerCase();
|
||||
console.log(NPGClient.userName);
|
||||
}
|
||||
},
|
||||
|
||||
//
|
||||
removeChar : function(key) {
|
||||
if (NPGClient.userName.length > 0) {
|
||||
NPGClient.userName = NPGClient.userName.substring(0, NPGClient.userName.length - 1);
|
||||
console.log(NPGClient.userName);
|
||||
}
|
||||
},
|
||||
|
||||
//
|
||||
validChar : function(key) {
|
||||
return NPGClient.evtHandler.loginValidKey(key);
|
||||
},
|
||||
|
||||
//
|
||||
validName : function(key) {
|
||||
var len = NPGClient.userName.length;
|
||||
return (len >= 0 && len <= NPGClient.NAMEMAXSIZE);
|
||||
},
|
||||
|
||||
//
|
||||
resetName : function() {
|
||||
NPGClient.userName = '';
|
||||
},
|
||||
|
||||
}
|
||||
12
client/lib/utils/js_utils.js
Normal file
12
client/lib/utils/js_utils.js
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* @file js_utils.js
|
||||
* @author frtk@tetalab
|
||||
*/
|
||||
|
||||
function countProperties(obj) {
|
||||
var count = 0;
|
||||
for (var prop in obj) {
|
||||
if (obj.hasOwnProperty(prop)) count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
Reference in New Issue
Block a user