|
|
@ -6,7 +6,64 @@ |
|
|
|
NPGClient.Utils = { |
|
|
|
|
|
|
|
/** |
|
|
|
* UI |
|
|
|
* UI draw |
|
|
|
*/ |
|
|
|
//
|
|
|
|
drawText: function(ctx, x1, y1, t, s, c) { |
|
|
|
ctx.font = s; |
|
|
|
ctx.fillStyle = c; |
|
|
|
ctx.fillText(t, x1, y1); |
|
|
|
}, |
|
|
|
|
|
|
|
//
|
|
|
|
drawFillRect: function(ctx, x1, y1, w, h) { |
|
|
|
ctx.fillRect(x1, y1, w, h); |
|
|
|
}, |
|
|
|
|
|
|
|
//
|
|
|
|
drawRect: function(ctx, x1, y1, w, h) { |
|
|
|
ctx.beginPath(); |
|
|
|
ctx.rect(x1, y1, w, h); |
|
|
|
ctx.stroke(); |
|
|
|
}, |
|
|
|
|
|
|
|
//
|
|
|
|
drawLine: function(ctx, x1, y1, x2, y2) { |
|
|
|
ctx.beginPath(); |
|
|
|
ctx.moveTo(x1, y1); |
|
|
|
ctx.lineTo(x2, y2); |
|
|
|
ctx.stroke(); |
|
|
|
}, |
|
|
|
|
|
|
|
//
|
|
|
|
drawSemiCircle: function(ctx, x, y, r, a1, a2, o, w, c) { |
|
|
|
ctx.lineWidth = w; |
|
|
|
ctx.strokeStyle = c; |
|
|
|
ctx.beginPath(); |
|
|
|
ctx.arc(x, y, r, a1, a2, o); |
|
|
|
ctx.closePath(); |
|
|
|
ctx.stroke(); |
|
|
|
}, |
|
|
|
|
|
|
|
drawFillCircle: function(ctx, x, y, r) { |
|
|
|
ctx.beginPath(); |
|
|
|
ctx.arc(x, y, r, 0, Math.PI*2, false); |
|
|
|
ctx.fill(); |
|
|
|
ctx.stroke(); |
|
|
|
ctx.closePath(); |
|
|
|
}, |
|
|
|
|
|
|
|
//
|
|
|
|
drawCircle: function(ctx, x, y, r) { |
|
|
|
ctx.beginPath(); |
|
|
|
ctx.arc(x, y, r, 0, Math.PI*2, false); |
|
|
|
ctx.closePath(); |
|
|
|
ctx.stroke(); |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* UI Style |
|
|
|
*/ |
|
|
|
//
|
|
|
|
setTxtStyle : function(ctx, style) { |
|
|
@ -37,32 +94,42 @@ NPGClient.Utils = { |
|
|
|
//console.log(key + ' ' + NPGClient.userName);
|
|
|
|
if (NPGClient.userName.length < NPGClient.NAMEMAXSIZE) { |
|
|
|
NPGClient.userName = NPGClient.userName + String.fromCharCode(key).toLowerCase(); |
|
|
|
console.log(NPGClient.userName); |
|
|
|
//console.log(NPGClient.userName);
|
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
//
|
|
|
|
removeChar : function(key) { |
|
|
|
removeChar: function(key) { |
|
|
|
if (NPGClient.userName.length > 0) { |
|
|
|
NPGClient.userName = NPGClient.userName.substring(0, NPGClient.userName.length - 1); |
|
|
|
console.log(NPGClient.userName); |
|
|
|
//console.log(NPGClient.userName);
|
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
//
|
|
|
|
validChar : function(key) { |
|
|
|
validChar: function(key) { |
|
|
|
return NPGClient.evtHandler.loginValidKey(key); |
|
|
|
}, |
|
|
|
|
|
|
|
//
|
|
|
|
validName : function(key) { |
|
|
|
validName: function() { |
|
|
|
var len = NPGClient.userName.length; |
|
|
|
return (len >= 0 && len <= NPGClient.NAMEMAXSIZE); |
|
|
|
return (len >= 3 && len <= NPGClient.NAMEMAXSIZE); |
|
|
|
}, |
|
|
|
|
|
|
|
//
|
|
|
|
maxNameSize: function() { |
|
|
|
return NPGClient.userName.length == NPGClient.NAMEMAXSIZE; |
|
|
|
}, |
|
|
|
|
|
|
|
//
|
|
|
|
resetName : function() { |
|
|
|
resetName: function() { |
|
|
|
NPGClient.userName = ''; |
|
|
|
}, |
|
|
|
|
|
|
|
//
|
|
|
|
nameEmpty: function() { |
|
|
|
return (NPGClient.userName.length == 0); |
|
|
|
}, |
|
|
|
|
|
|
|
} |