bla
This commit is contained in:
1 parent
b5064543e4
commit
3d360494cf
30 files changed
-1646
No files matched your search
@@ -1,8 +0,0 @@
|
||||
/**
|
||||
* @file NPGClient.js
|
||||
* @author frtk
|
||||
*/
|
||||
|
||||
var NPGClient = { 'version': '' };
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
/**
|
||||
* @file NPGClientConfig.js
|
||||
*/
|
||||
|
||||
var NPGClient.Config = {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
/**
|
||||
* @file AppPage.js
|
||||
* @author frtk@tetalab
|
||||
*/
|
||||
|
||||
NPGClient.AppPage = function(n) {
|
||||
|
||||
Object.defineProperty(this, 'id', { value: NPGClient.pageCount++ });
|
||||
|
||||
this.name = n || '';
|
||||
// draw loop paramaters
|
||||
this.loopIntervalId = 0;
|
||||
this.loopDelay = 40;
|
||||
// canvas
|
||||
this.canvas_id = "";
|
||||
this.canvas_bcol = "";
|
||||
this.canvas = {};
|
||||
this.ctx = {};
|
||||
|
||||
// ui elements
|
||||
this.uiElems = [];
|
||||
|
||||
};
|
||||
|
||||
NPGClient.AppPage.prototype = {
|
||||
|
||||
constructor: NPGClient.AppPage,
|
||||
|
||||
//
|
||||
setLoopDelay: function(d) {
|
||||
this.loopDelay = d;
|
||||
},
|
||||
|
||||
//
|
||||
startDrawLoop: function() {
|
||||
var self = this;
|
||||
self.loopIntervalId = setInterval(function() {
|
||||
self.run();
|
||||
}, self.loopDelay);
|
||||
},
|
||||
|
||||
//
|
||||
stopDrawLoop: function() {
|
||||
var self = this;
|
||||
clearInterval(self.loopIntervalId);
|
||||
self.loopIntervalId = 0;
|
||||
},
|
||||
|
||||
//
|
||||
run: function() {
|
||||
var self = this;
|
||||
self.drawUI();
|
||||
},
|
||||
|
||||
//
|
||||
configUI: function(id, w, h, c) {
|
||||
var self = this;
|
||||
self.canvas_id = id;
|
||||
self.canvas = document.getElementById(id);
|
||||
self.ctx = self.canvas.getContext("2d");
|
||||
self.canvas.width = w;
|
||||
self.canvas.height = h;
|
||||
self.canvas_bcol = c;
|
||||
},
|
||||
|
||||
//
|
||||
addUIObject: function(c) {
|
||||
var self = this;
|
||||
self.uiElems.push(c);
|
||||
},
|
||||
|
||||
//
|
||||
getUIElemByName: function(name) {
|
||||
var self = this;
|
||||
if (self.uiElems.length > 0) {
|
||||
for (var i = 0; i < self.uiElems.length; i++)
|
||||
if (self.uiElems[i].name == name) return self.uiElems[i];
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
|
||||
//
|
||||
drawUI: function() {
|
||||
var self = this;
|
||||
self.clear();
|
||||
self.drawUIBackground();
|
||||
self.drawUIObjects();
|
||||
},
|
||||
|
||||
//
|
||||
drawUIBackground: function() {
|
||||
var self = this;
|
||||
self.ctx.fillStyle = self.canvas_bcol;
|
||||
self.ctx.fillRect(0, 0, self.canvas.width, self.canvas.height);
|
||||
},
|
||||
|
||||
//
|
||||
drawUIObjects: function() {
|
||||
var self = this;
|
||||
if (self.uiElems.length > 0) {
|
||||
for (var i = 0; i < self.uiElems.length; i++)
|
||||
self.uiElems[i].draw(self.ctx);
|
||||
}
|
||||
},
|
||||
|
||||
//
|
||||
clear: function() {
|
||||
var self = this;
|
||||
self.ctx.clearRect(0, 0, self.canvas.width, self.canvas.height);
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/**
|
||||
* @file event_handling.js
|
||||
* @autour frtk@tetalab
|
||||
*/
|
||||
|
||||
NPGClient.evtHandler = {
|
||||
|
||||
keysList: {
|
||||
F1 : 112,
|
||||
SPACE : 32,
|
||||
ESC : 27,
|
||||
ARROW_UP : 38,
|
||||
ARROW_DOWN : 40,
|
||||
ENTER : 13,
|
||||
DELETE : 46,
|
||||
BACKSPACE : 8,
|
||||
},
|
||||
|
||||
keyState: {},
|
||||
|
||||
//
|
||||
init: function() {
|
||||
var self = this;
|
||||
//
|
||||
self.keyState = {};
|
||||
for (k in self.keyList) {
|
||||
self.keyState[self.keysList[k]] = false;
|
||||
}
|
||||
//
|
||||
document.addEventListener('keydown',function(e) {
|
||||
self.keyState[e.keyCode || e.which] = true;
|
||||
self.onKeyDown(e);
|
||||
}, true);
|
||||
//
|
||||
document.addEventListener('keyup',function(e){
|
||||
self.keyState[e.keyCode || e.which] = false;
|
||||
}, true);
|
||||
},
|
||||
|
||||
//
|
||||
loginValidKey: function(k) {
|
||||
return (key >= 48 && key <= 90);
|
||||
},
|
||||
|
||||
//
|
||||
onKeyDown : function(evt) {
|
||||
console.log(evt.keyCode);
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/**
|
||||
* @file NPGClient.js
|
||||
* @author frtk
|
||||
*/
|
||||
|
||||
var NPGClient = { 'version': '' };
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
/**
|
||||
* @file login_page.js
|
||||
* @author frtk@tetalab
|
||||
*/
|
||||
|
||||
NPGClient.LoginPage = {
|
||||
|
||||
pageIdx: 0,
|
||||
page: new NPGClient.AppPage('login'),
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
/**
|
||||
* @file SocketIO.js
|
||||
* @author frtk
|
||||
*/
|
||||
|
||||
NPGClient.SocketIO = {
|
||||
|
||||
// Connection to server
|
||||
conn_nAttempts: 0,
|
||||
conn_IntervalID: 0,
|
||||
socket: {},
|
||||
isConnected: false,
|
||||
|
||||
// start connection loop
|
||||
initConnectLoop: function() {
|
||||
var self = this;
|
||||
console.log();
|
||||
self.startConnectLoop();
|
||||
},
|
||||
// start connection loop
|
||||
startConnectLoop: function() {
|
||||
var self = this;
|
||||
self.conn_IntervalID = setInterval(function() { self.connect(); }, 1500);
|
||||
},
|
||||
// stop connection loop
|
||||
stopConnectLoop: function() {
|
||||
var self = this;
|
||||
clearInterval(self.conn_IntervalID);
|
||||
self.conn_IntervalID = 0;
|
||||
self.conn_nAttempts = 0;
|
||||
},
|
||||
// connect socket
|
||||
connect: function() {
|
||||
var self = this;
|
||||
// check for connection
|
||||
if (self.isConnected) {
|
||||
return false;
|
||||
}
|
||||
//
|
||||
if (typeof io !== 'object') {
|
||||
//console.log('[NPGClient.SocketIO] io object is unknown');
|
||||
}
|
||||
if ((typeof self.socket.socket === 'undefined')) {
|
||||
console.log('[NPGClient.SocketIO] attempting server connection...');
|
||||
self.socket = io.connect();
|
||||
self.defineSocketMsgs();
|
||||
} else if (!self.socket.socket.connected && !self.socket.socket.connecting) {
|
||||
console.log('[NPGClient.SocketIO] attempting server connection...');
|
||||
self.socket.socket.connect();
|
||||
}
|
||||
},
|
||||
// Define Socket Messages
|
||||
defineSocketMsgs: function() {
|
||||
var self = this;
|
||||
if (typeof self.socket === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
console.log('[NPGClient.SocketIO] deploying socket object features.');
|
||||
// 'connecting'
|
||||
self.socket.on('connecting', function () {
|
||||
console.log('[NPGClient.SocketIO] connecting ...');
|
||||
});
|
||||
// 'connect'
|
||||
self.socket.on('connect', function() {
|
||||
console.log('[NPGClient.SocketIO] connected to server');
|
||||
self.stopConnectLoop();
|
||||
self.isConnected = true;
|
||||
});
|
||||
// 'disconnect'
|
||||
self.socket.on('disconnect', function() {
|
||||
console.log('[NPGClient.SocketIO] > Server: socket disconnected.');
|
||||
self.startConnectLoop();
|
||||
self.isConnected = false;
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
@@ -1,77 +0,0 @@
|
||||
/**
|
||||
* @file SocketIO.js
|
||||
* @author frtk
|
||||
*/
|
||||
|
||||
NPGClient.SocketIO = {
|
||||
|
||||
// Connection to server
|
||||
conn_nAttempts: 0,
|
||||
conn_IntervalID: 0,
|
||||
socket: {},
|
||||
isConnected: false,
|
||||
|
||||
// start connection loop
|
||||
initConnectLoop: function() {
|
||||
var self = this;
|
||||
console.log();
|
||||
self.startConnectLoop();
|
||||
},
|
||||
// start connection loop
|
||||
startConnectLoop: function() {
|
||||
var self = this;
|
||||
self.conn_IntervalID = setInterval(function() { self.connect(); }, 1500);
|
||||
},
|
||||
// stop connection loop
|
||||
stopConnectLoop: function() {
|
||||
var self = this;
|
||||
clearInterval(self.conn_IntervalID);
|
||||
self.conn_IntervalID = 0;
|
||||
self.conn_nAttempts = 0;
|
||||
},
|
||||
// connect socket
|
||||
connect: function() {
|
||||
var self = this;
|
||||
// check for connection
|
||||
if (self.isConnected) {
|
||||
return false;
|
||||
}
|
||||
//
|
||||
if (typeof io !== 'object') {
|
||||
//console.log('[NPGClient.SocketIO] io object is unknown');
|
||||
}
|
||||
if ((typeof self.socket.socket === 'undefined')) {
|
||||
console.log('[NPGClient.SocketIO] attempting server connection...');
|
||||
self.socket = io.connect();
|
||||
self.defineSocketMsgs();
|
||||
} else if (!self.socket.socket.connected && !self.socket.socket.connecting) {
|
||||
console.log('[NPGClient.SocketIO] attempting server connection...');
|
||||
self.socket.socket.connect();
|
||||
}
|
||||
},
|
||||
// Define Socket Messages
|
||||
defineSocketMsgs: function() {
|
||||
var self = this;
|
||||
if (typeof self.socket === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
console.log('[NPGClient.SocketIO] deploying socket object features.');
|
||||
// 'connecting'
|
||||
self.socket.on('connecting', function () {
|
||||
console.log('[NPGClient.SocketIO] connecting ...');
|
||||
});
|
||||
// 'connect'
|
||||
self.socket.on('connect', function() {
|
||||
console.log('[NPGClient.SocketIO] connected to server');
|
||||
self.stopConnectLoop();
|
||||
self.isConnected = true;
|
||||
});
|
||||
// 'disconnect'
|
||||
self.socket.on('disconnect', function() {
|
||||
console.log('[NPGClient.SocketIO] > Server: socket disconnected.');
|
||||
self.startConnectLoop();
|
||||
self.isConnected = false;
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
Vendored
-4
@@ -1,4 +0,0 @@
|
||||
/*! jQuery v2.1.3 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
|
||||
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l=a.document,m="2.1.3",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(n.isPlainObject(d)||(e=n.isArray(d)))?(e?(e=!1,f=c&&n.isArray(c)?c:[]):f=c&&n.isPlainObject(c)?c:{},g[b]=n.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){return!n.isArray(a)&&a-parseFloat(a)+1>=0},isPlainObject:function(a){return"object"!==n.type(a)||a.nodeType||n.isWindow(a)?!1:a.constructor&&!j.call(a.constructor.prototype,"isPrototypeOf")?!1:!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=n.trim(a),a&&(1===a.indexOf("use strict")?(b=l.createElement("script"),b.text=a,l.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:g.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(c=a[b],b=a,a=c),n.isFunction(a)?(e=d.call(arguments,2),f=function(){return a.apply(b||this,e.concat(d.call(arguments)))},f.guid=a.guid=a.guid||n.guid++,f):void 0},now:Date.now,support:k}),n.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=hb(),z=hb(),A=hb(),B=function(a,b){return a===b&&(l=!0),0},C=1<<31,D={}.hasOwnProperty,E=[],F=E.pop,G=E.push,H=E.push,I=E.slice,J=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},K="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",L="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",N=M.replace("w","w#"),O="\\["+L+"*("+M+")(?:"+L+"*([*^$|!~]?=)"+L+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+N+"))|)"+L+"*\\]",P=":("+M+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+O+")*)|.*)\\)|)",Q=new RegExp(L+"+","g"),R=new RegExp("^"+L+"+|((?:^|[^\\\\])(?:\\\\.)*)"+L+"+$","g"),S=new RegExp("^"+L+"*,"+L+"*"),Line truncated
|
||||
},removeData:function(a,b){M.remove(a,b)},_data:function(a,b,c){return L.access(a,b,c)},_removeData:function(a,b){L.remove(a,b)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=M.get(f),1===f.nodeType&&!L.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),P(f,d,e[d])));L.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){M.set(this,a)}):J(this,function(b){var c,d=n.camelCase(a);if(f&&void 0===b){if(c=M.get(f,a),void 0!==c)return c;if(c=M.get(f,d),void 0!==c)return c;if(c=P(f,d,void 0),void 0!==c)return c}else this.each(function(){var c=M.get(this,d);M.set(this,d,b),-1!==a.indexOf("-")&&void 0!==c&&M.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){M.remove(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=L.get(a,b),c&&(!d||n.isArray(c)?d=L.access(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return L.get(a,c)||L.access(a,c,{empty:n.Callbacks("once memory").add(function(){L.remove(a,[b+"queue",c])})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?n.queue(this[0],a):void 0===b?this:this.each(function(){var c=n.queue(this,a,b);n._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&n.dequeue(this,a)})},dequeue:function(a){return this.each(function(){n.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=n.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=L.get(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var Q=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,R=["Top","Right","Bottom","Left"],S=function(a,b){return a=b||a,"none"===n.css(a,"display")||!n.contains(a.ownerDocument,a)},T=/^(?:checkbox|radio)$/i;!function(){var a=l.createDocumentFragment(),b=a.appendChild(l.createElement("div")),c=l.createElement("input");c.setAttribute("type","radio"),c.setAttribute("checked","checked"),c.setAttribute("name","t"),b.appendChild(c),k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,b.innerHTML="<textarea>x</textarea>",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var U="undefined";k.focusinBubbles="onfocusin"in a;var V=/^key/,W=/^(?:mouse|pointer|contextmenu)|click/,X=/^(?:focusinfocus|focusoutblur)$/,Y=/^([^.]*)(?:\.(.+)|)$/;function Z(){return!0}function $(){return!1}function _(){try{return l.activeElement}catch(a){}}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.get(a);if(r){c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=n.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return typeof n!==U&&n.event.triggered!==b.type?n.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(E)||[""],j=b.length;while(j--)h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o&&(l=n.event.special[o]||{},o=(e?l.delegateType:l.bindType)||o,l=n.event.special[o]||{},k=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[o])||(m=i[o]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!==!1||a.addEventListener&&a.addEventListener(o,g,!1)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),n.event.global[o]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.hasData(a)&&L.get(a);if(r&&(i=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=i[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&q!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete i[o])}else for(o in i)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(i)&&(delete r.handle,L.remove(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,m,o,p=[d||l],q=j.call(b,"type")?b.type:b,r=j.call(b,"namespace")?b.namespace.split("."):[];if(g=h=d=d||l,3!==d.nodeType&&8!==d.nodeType&&!X.test(q+n.event.triggered)&&(q.indexOf(".")>=0&&(r=q.split("."),q=r.shift(),r.sort()),k=q.indexOf(":")<0&&"on"+q,b=b[n.expando]?b:new n.Event(q,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=r.join(".Line truncated
|
||||
},removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(E);if(f&&1===a.nodeType)while(c=f[e++])d=n.propFix[c]||c,n.expr.match.bool.test(c)&&(a[d]=!1),a.removeAttribute(c)},attrHooks:{type:{set:function(a,b){if(!k.radioValue&&"radio"===b&&n.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}}}),Zb={set:function(a,b,c){return b===!1?n.removeAttr(a,c):a.setAttribute(c,c),c}},n.each(n.expr.match.bool.source.match(/\w+/g),function(a,b){var c=$b[b]||n.find.attr;$b[b]=function(a,b,d){var e,f;return d||(f=$b[b],$b[b]=e,e=null!=c(a,b,d)?b.toLowerCase():null,$b[b]=f),e}});var _b=/^(?:input|select|textarea|button)$/i;n.fn.extend({prop:function(a,b){return J(this,n.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[n.propFix[a]||a]})}}),n.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(a,b,c){var d,e,f,g=a.nodeType;if(a&&3!==g&&8!==g&&2!==g)return f=1!==g||!n.isXMLDoc(a),f&&(b=n.propFix[b]||b,e=n.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){return a.hasAttribute("tabindex")||_b.test(a.nodeName)||a.href?a.tabIndex:-1}}}}),k.optSelected||(n.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null}}),n.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){n.propFix[this.toLowerCase()]=this});var ac=/[\t\r\n\f]/g;n.fn.extend({addClass:function(a){var b,c,d,e,f,g,h="string"==typeof a&&a,i=0,j=this.length;if(n.isFunction(a))return this.each(function(b){n(this).addClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ac," "):" ")){f=0;while(e=b[f++])d.indexOf(" "+e+" ")<0&&(d+=e+" ");g=n.trim(d),c.className!==g&&(c.className=g)}return this},removeClass:function(a){var b,c,d,e,f,g,h=0===arguments.length||"string"==typeof a&&a,i=0,j=this.length;if(n.isFunction(a))return this.each(function(b){n(this).removeClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ac," "):"")){f=0;while(e=b[f++])while(d.indexOf(" "+e+" ")>=0)d=d.replace(" "+e+" "," ");g=a?n.trim(d):"",c.className!==g&&(c.className=g)}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):this.each(n.isFunction(a)?function(c){n(this).toggleClass(a.call(this,c,this.className,b),b)}:function(){if("string"===c){var b,d=0,e=n(this),f=a.match(E)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else(c===U||"boolean"===c)&&(this.className&&L.set(this,"__className__",this.className),this.className=this.className||a===!1?"":L.get(this,"__className__")||"")})},hasClass:function(a){for(var b=" "+a+" ",c=0,d=this.length;d>c;c++)if(1===this[c].nodeType&&(" "+this[c].className+" ").replace(ac," ").indexOf(b)>=0)return!0;return!1}});var bc=/\r/g;n.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=n.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,n(this).val()):a,null==e?e="":"number"==typeof e?e+="":n.isArray(e)&&(e=n.map(e,function(a){return null==a?"":a+""})),b=n.valHooks[this.type]||n.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=n.valHooks[e.type]||n.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(bc,""):null==c?"":c)}}}),n.extend({valHooks:{option:{get:function(a){var b=n.find.attr(a,"value");return null!=b?b:n.trim(n.text(a))}},select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||0>e,g=f?null:[],h=f?e+1:d.length,i=0>e?h:f?e:0;h>i;i++)if(c=d[i],!(!c.selected&&i!==e||(k.optDisabled?c.disabled:null!==c.getAttribute("disabled"))||c.parentNode.disabled&&n.nodeName(c.parentNode,"optgroup"))){if(b=n(c).val(),f)return b;g.push(b)}return g},set:function(a,b){var c,d,e=a.options,f=n.makeArray(b),g=e.length;while(g--)d=e[g],(d.selected=n.inArray(d.value,f)>=0)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),n.each(["radio","checkbox"],function(){n.valHooks[this]={set:function(a,b){return n.isArray(b)?a.checked=n.inArray(n(a).val(),b)>=0:void 0}},k.checkOn||(n.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})}),n.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){n.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),n.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||Line truncated
|
||||
-50
@@ -1,50 +0,0 @@
|
||||
/**
|
||||
* @file nodePong.js
|
||||
* @author frtk
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* nodejs modules
|
||||
*/
|
||||
//---
|
||||
var fs = require('fs');
|
||||
var express = require('express');
|
||||
var http = require('http');
|
||||
//--- server app libs & params
|
||||
//var servP = require('./server/server_config.js');
|
||||
var npg = require('./server/server_core.js');
|
||||
//--- nodePong config
|
||||
var cfg = require('./server/server_config.js');
|
||||
|
||||
|
||||
//
|
||||
npg.NPGServer.init(cfg.Config);
|
||||
|
||||
|
||||
/*
|
||||
* starting HTTP and socket.io services
|
||||
*/
|
||||
//--- HTTP server
|
||||
npg.NPGServer.log("$ # starting http service on port " + npg.NPGServer.port);
|
||||
var app = express();
|
||||
var httpserv = http.createServer(app);
|
||||
httpserv.listen(npg.NPGServer.port);
|
||||
//--- allow access to static files from "/client" directory
|
||||
app.use(express.static(__dirname + '/client/'));
|
||||
|
||||
//--- socket.io
|
||||
npg.NPGServer.log('$ # registering socket.io service on port ' + npg.NPGServer.port);
|
||||
var io = require('socket.io').listen(httpserv, { log: true } );
|
||||
//-- setup server socket handling features
|
||||
npg.NPGServer.socketHandling(io);
|
||||
//
|
||||
npg.NPGServer.log('$ #####');
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* running nodePong server
|
||||
*/
|
||||
//---
|
||||
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
Original Library
|
||||
- Copyright (c) Marak Squires
|
||||
|
||||
Additional Functionality
|
||||
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
-178
@@ -1,178 +0,0 @@
|
||||
# colors.js [](https://travis-ci.org/Marak/colors.js)
|
||||
|
||||
## get color and style in your node.js console
|
||||
|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
npm install colors
|
||||
|
||||
## colors and styles!
|
||||
|
||||
### text colors
|
||||
|
||||
- black
|
||||
- red
|
||||
- green
|
||||
- yellow
|
||||
- blue
|
||||
- magenta
|
||||
- cyan
|
||||
- white
|
||||
- gray
|
||||
- grey
|
||||
|
||||
### background colors
|
||||
|
||||
- bgBlack
|
||||
- bgRed
|
||||
- bgGreen
|
||||
- bgYellow
|
||||
- bgBlue
|
||||
- bgMagenta
|
||||
- bgCyan
|
||||
- bgWhite
|
||||
|
||||
### styles
|
||||
|
||||
- reset
|
||||
- bold
|
||||
- dim
|
||||
- italic
|
||||
- underline
|
||||
- inverse
|
||||
- hidden
|
||||
- strikethrough
|
||||
|
||||
### extras
|
||||
|
||||
- rainbow
|
||||
- zebra
|
||||
- america
|
||||
- trap
|
||||
- random
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
By popular demand, `colors` now ships with two types of usages!
|
||||
|
||||
The super nifty way
|
||||
|
||||
```js
|
||||
var colors = require('colors');
|
||||
|
||||
console.log('hello'.green); // outputs green text
|
||||
console.log('i like cake and pies'.underline.red) // outputs red underlined text
|
||||
console.log('inverse the color'.inverse); // inverses the color
|
||||
console.log('OMG Rainbows!'.rainbow); // rainbow
|
||||
console.log('Run the trap'.trap); // Drops the bass
|
||||
|
||||
```
|
||||
|
||||
or a slightly less nifty way which doesn't extend `String.prototype`
|
||||
|
||||
```js
|
||||
var colors = require('colors/safe');
|
||||
|
||||
console.log(colors.green('hello')); // outputs green text
|
||||
console.log(colors.red.underline('i like cake and pies')) // outputs red underlined text
|
||||
console.log(colors.inverse('inverse the color')); // inverses the color
|
||||
console.log(colors.rainbow('OMG Rainbows!')); // rainbow
|
||||
console.log(colors.trap('Run the trap')); // Drops the bass
|
||||
|
||||
```
|
||||
|
||||
I prefer the first way. Some people seem to be afraid of extending `String.prototype` and prefer the second way.
|
||||
|
||||
If you are writing good code you will never have an issue with the first approach. If you really don't want to touch `String.prototype`, the second usage will not touch `String` native object.
|
||||
|
||||
## Disabling Colors
|
||||
|
||||
To disable colors you can pass the following arguments in the command line to your application:
|
||||
|
||||
```bash
|
||||
node myapp.js --no-color
|
||||
```
|
||||
|
||||
## Console.log [string substitution](http://nodejs.org/docs/latest/api/console.html#console_console_log_data)
|
||||
|
||||
```js
|
||||
var name = 'Marak';
|
||||
console.log(colors.green('Hello %s'), name);
|
||||
// outputs -> 'Hello Marak'
|
||||
```
|
||||
|
||||
## Custom themes
|
||||
|
||||
### Using standard API
|
||||
|
||||
```js
|
||||
|
||||
var colors = require('colors');
|
||||
|
||||
colors.setTheme({
|
||||
silly: 'rainbow',
|
||||
input: 'grey',
|
||||
verbose: 'cyan',
|
||||
prompt: 'grey',
|
||||
info: 'green',
|
||||
data: 'grey',
|
||||
help: 'cyan',
|
||||
warn: 'yellow',
|
||||
debug: 'blue',
|
||||
error: 'red'
|
||||
});
|
||||
|
||||
// outputs red text
|
||||
console.log("this is an error".error);
|
||||
|
||||
// outputs yellow text
|
||||
console.log("this is a warning".warn);
|
||||
```
|
||||
|
||||
### Using string safe API
|
||||
|
||||
```js
|
||||
var colors = require('colors/safe');
|
||||
|
||||
// set single property
|
||||
var error = colors.red;
|
||||
error('this is red');
|
||||
|
||||
// set theme
|
||||
colors.setTheme({
|
||||
silly: 'rainbow',
|
||||
input: 'grey',
|
||||
verbose: 'cyan',
|
||||
prompt: 'grey',
|
||||
info: 'green',
|
||||
data: 'grey',
|
||||
help: 'cyan',
|
||||
warn: 'yellow',
|
||||
debug: 'blue',
|
||||
error: 'red'
|
||||
});
|
||||
|
||||
// outputs red text
|
||||
console.log(colors.error("this is an error"));
|
||||
|
||||
// outputs yellow text
|
||||
console.log(colors.warn("this is a warning"));
|
||||
|
||||
```
|
||||
|
||||
You can also combine them:
|
||||
|
||||
```javascript
|
||||
var colors = require('colors');
|
||||
|
||||
colors.setTheme({
|
||||
custom: ['red', 'underline']
|
||||
});
|
||||
|
||||
console.log('test'.custom);
|
||||
```
|
||||
|
||||
*Protip: There is a secret undocumented style in `colors`. If you find the style you can summon him.*
|
||||
-74
@@ -1,74 +0,0 @@
|
||||
var colors = require('../lib/index');
|
||||
|
||||
console.log("First some yellow text".yellow);
|
||||
|
||||
console.log("Underline that text".yellow.underline);
|
||||
|
||||
console.log("Make it bold and red".red.bold);
|
||||
|
||||
console.log(("Double Raindows All Day Long").rainbow)
|
||||
|
||||
console.log("Drop the bass".trap)
|
||||
|
||||
console.log("DROP THE RAINBOW BASS".trap.rainbow)
|
||||
|
||||
|
||||
console.log('Chains are also cool.'.bold.italic.underline.red); // styles not widely supported
|
||||
|
||||
console.log('So '.green + 'are'.underline + ' ' + 'inverse'.inverse + ' styles! '.yellow.bold); // styles not widely supported
|
||||
console.log("Zebras are so fun!".zebra);
|
||||
|
||||
//
|
||||
// Remark: .strikethrough may not work with Mac OS Terminal App
|
||||
//
|
||||
console.log("This is " + "not".strikethrough + " fun.");
|
||||
|
||||
console.log('Background color attack!'.black.bgWhite)
|
||||
console.log('Use random styles on everything!'.random)
|
||||
console.log('America, Heck Yeah!'.america)
|
||||
|
||||
|
||||
console.log('Setting themes is useful')
|
||||
|
||||
//
|
||||
// Custom themes
|
||||
//
|
||||
console.log('Generic logging theme as JSON'.green.bold.underline);
|
||||
// Load theme with JSON literal
|
||||
colors.setTheme({
|
||||
silly: 'rainbow',
|
||||
input: 'grey',
|
||||
verbose: 'cyan',
|
||||
prompt: 'grey',
|
||||
info: 'green',
|
||||
data: 'grey',
|
||||
help: 'cyan',
|
||||
warn: 'yellow',
|
||||
debug: 'blue',
|
||||
error: 'red'
|
||||
});
|
||||
|
||||
// outputs red text
|
||||
console.log("this is an error".error);
|
||||
|
||||
// outputs yellow text
|
||||
console.log("this is a warning".warn);
|
||||
|
||||
// outputs grey text
|
||||
console.log("this is an input".input);
|
||||
|
||||
console.log('Generic logging theme as file'.green.bold.underline);
|
||||
|
||||
// Load a theme from file
|
||||
colors.setTheme(__dirname + '/../themes/generic-logging.js');
|
||||
|
||||
// outputs red text
|
||||
console.log("this is an error".error);
|
||||
|
||||
// outputs yellow text
|
||||
console.log("this is a warning".warn);
|
||||
|
||||
// outputs grey text
|
||||
console.log("this is an input".input);
|
||||
|
||||
//console.log("Don't summon".zalgo)
|
||||
-76
@@ -1,76 +0,0 @@
|
||||
var colors = require('../safe');
|
||||
|
||||
console.log(colors.yellow("First some yellow text"));
|
||||
|
||||
console.log(colors.yellow.underline("Underline that text"));
|
||||
|
||||
console.log(colors.red.bold("Make it bold and red"));
|
||||
|
||||
console.log(colors.rainbow("Double Raindows All Day Long"))
|
||||
|
||||
console.log(colors.trap("Drop the bass"))
|
||||
|
||||
console.log(colors.rainbow(colors.trap("DROP THE RAINBOW BASS")));
|
||||
|
||||
console.log(colors.bold.italic.underline.red('Chains are also cool.')); // styles not widely supported
|
||||
|
||||
|
||||
console.log(colors.green('So ') + colors.underline('are') + ' ' + colors.inverse('inverse') + colors.yellow.bold(' styles! ')); // styles not widely supported
|
||||
|
||||
console.log(colors.zebra("Zebras are so fun!"));
|
||||
|
||||
console.log("This is " + colors.strikethrough("not") + " fun.");
|
||||
|
||||
|
||||
console.log(colors.black.bgWhite('Background color attack!'));
|
||||
console.log(colors.random('Use random styles on everything!'))
|
||||
console.log(colors.america('America, Heck Yeah!'));
|
||||
|
||||
console.log('Setting themes is useful')
|
||||
|
||||
//
|
||||
// Custom themes
|
||||
//
|
||||
//console.log('Generic logging theme as JSON'.green.bold.underline);
|
||||
// Load theme with JSON literal
|
||||
colors.setTheme({
|
||||
silly: 'rainbow',
|
||||
input: 'grey',
|
||||
verbose: 'cyan',
|
||||
prompt: 'grey',
|
||||
info: 'green',
|
||||
data: 'grey',
|
||||
help: 'cyan',
|
||||
warn: 'yellow',
|
||||
debug: 'blue',
|
||||
error: 'red'
|
||||
});
|
||||
|
||||
// outputs red text
|
||||
console.log(colors.error("this is an error"));
|
||||
|
||||
// outputs yellow text
|
||||
console.log(colors.warn("this is a warning"));
|
||||
|
||||
// outputs grey text
|
||||
console.log(colors.input("this is an input"));
|
||||
|
||||
|
||||
// console.log('Generic logging theme as file'.green.bold.underline);
|
||||
|
||||
// Load a theme from file
|
||||
colors.setTheme(__dirname + '/../themes/generic-logging.js');
|
||||
|
||||
// outputs red text
|
||||
console.log(colors.error("this is an error"));
|
||||
|
||||
// outputs yellow text
|
||||
console.log(colors.warn("this is a warning"));
|
||||
|
||||
// outputs grey text
|
||||
console.log(colors.input("this is an input"));
|
||||
|
||||
// console.log(colors.zalgo("Don't summon him"))
|
||||
|
||||
|
||||
|
||||
-187
@@ -1,187 +0,0 @@
|
||||
/*
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Original Library
|
||||
- Copyright (c) Marak Squires
|
||||
|
||||
Additional functionality
|
||||
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
var colors = {};
|
||||
module['exports'] = colors;
|
||||
|
||||
colors.themes = {};
|
||||
|
||||
var ansiStyles = colors.styles = require('./styles');
|
||||
var defineProps = Object.defineProperties;
|
||||
|
||||
colors.supportsColor = require('./system/supports-colors');
|
||||
|
||||
if (typeof colors.enabled === "undefined") {
|
||||
colors.enabled = colors.supportsColor;
|
||||
}
|
||||
|
||||
colors.stripColors = colors.strip = function(str){
|
||||
return ("" + str).replace(/\x1B\[\d+m/g, '');
|
||||
};
|
||||
|
||||
|
||||
var stylize = colors.stylize = function stylize (str, style) {
|
||||
if (!colors.enabled) {
|
||||
return str+'';
|
||||
}
|
||||
|
||||
return ansiStyles[style].open + str + ansiStyles[style].close;
|
||||
}
|
||||
|
||||
var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
|
||||
var escapeStringRegexp = function (str) {
|
||||
if (typeof str !== 'string') {
|
||||
throw new TypeError('Expected a string');
|
||||
}
|
||||
return str.replace(matchOperatorsRe, '\\$&');
|
||||
}
|
||||
|
||||
function build(_styles) {
|
||||
var builder = function builder() {
|
||||
return applyStyle.apply(builder, arguments);
|
||||
};
|
||||
builder._styles = _styles;
|
||||
// __proto__ is used because we must return a function, but there is
|
||||
// no way to create a function with a different prototype.
|
||||
builder.__proto__ = proto;
|
||||
return builder;
|
||||
}
|
||||
|
||||
var styles = (function () {
|
||||
var ret = {};
|
||||
ansiStyles.grey = ansiStyles.gray;
|
||||
Object.keys(ansiStyles).forEach(function (key) {
|
||||
ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
|
||||
ret[key] = {
|
||||
get: function () {
|
||||
return build(this._styles.concat(key));
|
||||
}
|
||||
};
|
||||
});
|
||||
return ret;
|
||||
})();
|
||||
|
||||
var proto = defineProps(function colors() {}, styles);
|
||||
|
||||
function applyStyle() {
|
||||
var args = arguments;
|
||||
var argsLen = args.length;
|
||||
var str = argsLen !== 0 && String(arguments[0]);
|
||||
if (argsLen > 1) {
|
||||
for (var a = 1; a < argsLen; a++) {
|
||||
str += ' ' + args[a];
|
||||
}
|
||||
}
|
||||
|
||||
if (!colors.enabled || !str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
var nestedStyles = this._styles;
|
||||
|
||||
var i = nestedStyles.length;
|
||||
while (i--) {
|
||||
var code = ansiStyles[nestedStyles[i]];
|
||||
str = code.open + str.replace(code.closeRe, code.open) + code.close;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
function applyTheme (theme) {
|
||||
for (var style in theme) {
|
||||
(function(style){
|
||||
colors[style] = function(str){
|
||||
if (typeof theme[style] === 'object'){
|
||||
var out = str;
|
||||
for (var i in theme[style]){
|
||||
out = colors[theme[style][i]](out);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
return colors[theme[style]](str);
|
||||
};
|
||||
})(style)
|
||||
}
|
||||
}
|
||||
|
||||
colors.setTheme = function (theme) {
|
||||
if (typeof theme === 'string') {
|
||||
try {
|
||||
colors.themes[theme] = require(theme);
|
||||
applyTheme(colors.themes[theme]);
|
||||
return colors.themes[theme];
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
return err;
|
||||
}
|
||||
} else {
|
||||
applyTheme(theme);
|
||||
}
|
||||
};
|
||||
|
||||
function init() {
|
||||
var ret = {};
|
||||
Object.keys(styles).forEach(function (name) {
|
||||
ret[name] = {
|
||||
get: function () {
|
||||
return build([name]);
|
||||
}
|
||||
};
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
var sequencer = function sequencer (map, str) {
|
||||
var exploded = str.split(""), i = 0;
|
||||
exploded = exploded.map(map);
|
||||
return exploded.join("");
|
||||
};
|
||||
|
||||
// custom formatter methods
|
||||
colors.trap = require('./custom/trap');
|
||||
colors.zalgo = require('./custom/zalgo');
|
||||
|
||||
// maps
|
||||
colors.maps = {};
|
||||
colors.maps.america = require('./maps/america');
|
||||
colors.maps.zebra = require('./maps/zebra');
|
||||
colors.maps.rainbow = require('./maps/rainbow');
|
||||
colors.maps.random = require('./maps/random')
|
||||
|
||||
for (var map in colors.maps) {
|
||||
(function(map){
|
||||
colors[map] = function (str) {
|
||||
return sequencer(colors.maps[map], str);
|
||||
}
|
||||
})(map)
|
||||
}
|
||||
|
||||
defineProps(colors, init());
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
module['exports'] = function runTheTrap (text, options) {
|
||||
var result = "";
|
||||
text = text || "Run the trap, drop the bass";
|
||||
text = text.split('');
|
||||
var trap = {
|
||||
a: ["\u0040", "\u0104", "\u023a", "\u0245", "\u0394", "\u039b", "\u0414"],
|
||||
b: ["\u00df", "\u0181", "\u0243", "\u026e", "\u03b2", "\u0e3f"],
|
||||
c: ["\u00a9", "\u023b", "\u03fe"],
|
||||
d: ["\u00d0", "\u018a", "\u0500" , "\u0501" ,"\u0502", "\u0503"],
|
||||
e: ["\u00cb", "\u0115", "\u018e", "\u0258", "\u03a3", "\u03be", "\u04bc", "\u0a6c"],
|
||||
f: ["\u04fa"],
|
||||
g: ["\u0262"],
|
||||
h: ["\u0126", "\u0195", "\u04a2", "\u04ba", "\u04c7", "\u050a"],
|
||||
i: ["\u0f0f"],
|
||||
j: ["\u0134"],
|
||||
k: ["\u0138", "\u04a0", "\u04c3", "\u051e"],
|
||||
l: ["\u0139"],
|
||||
m: ["\u028d", "\u04cd", "\u04ce", "\u0520", "\u0521", "\u0d69"],
|
||||
n: ["\u00d1", "\u014b", "\u019d", "\u0376", "\u03a0", "\u048a"],
|
||||
o: ["\u00d8", "\u00f5", "\u00f8", "\u01fe", "\u0298", "\u047a", "\u05dd", "\u06dd", "\u0e4f"],
|
||||
p: ["\u01f7", "\u048e"],
|
||||
q: ["\u09cd"],
|
||||
r: ["\u00ae", "\u01a6", "\u0210", "\u024c", "\u0280", "\u042f"],
|
||||
s: ["\u00a7", "\u03de", "\u03df", "\u03e8"],
|
||||
t: ["\u0141", "\u0166", "\u0373"],
|
||||
u: ["\u01b1", "\u054d"],
|
||||
v: ["\u05d8"],
|
||||
w: ["\u0428", "\u0460", "\u047c", "\u0d70"],
|
||||
x: ["\u04b2", "\u04fe", "\u04fc", "\u04fd"],
|
||||
y: ["\u00a5", "\u04b0", "\u04cb"],
|
||||
z: ["\u01b5", "\u0240"]
|
||||
}
|
||||
text.forEach(function(c){
|
||||
c = c.toLowerCase();
|
||||
var chars = trap[c] || [" "];
|
||||
var rand = Math.floor(Math.random() * chars.length);
|
||||
if (typeof trap[c] !== "undefined") {
|
||||
result += trap[c][rand];
|
||||
} else {
|
||||
result += c;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
|
||||
}
|
||||
-104
@@ -1,104 +0,0 @@
|
||||
// please no
|
||||
module['exports'] = function zalgo(text, options) {
|
||||
text = text || " he is here ";
|
||||
var soul = {
|
||||
"up" : [
|
||||
'̍', '̎', '̄', '̅',
|
||||
'̿', '̑', '̆', '̐',
|
||||
'͒', '͗', '͑', '̇',
|
||||
'̈', '̊', '͂', '̓',
|
||||
'̈', '͊', '͋', '͌',
|
||||
'̃', '̂', '̌', '͐',
|
||||
'̀', '́', '̋', '̏',
|
||||
'̒', '̓', '̔', '̽',
|
||||
'̉', 'ͣ', 'ͤ', 'ͥ',
|
||||
'ͦ', 'ͧ', 'ͨ', 'ͩ',
|
||||
'ͪ', 'ͫ', 'ͬ', 'ͭ',
|
||||
'ͮ', 'ͯ', '̾', '͛',
|
||||
'͆', '̚'
|
||||
],
|
||||
"down" : [
|
||||
'̖', '̗', '̘', '̙',
|
||||
'̜', '̝', '̞', '̟',
|
||||
'̠', '̤', '̥', '̦',
|
||||
'̩', '̪', '̫', '̬',
|
||||
'̭', '̮', '̯', '̰',
|
||||
'̱', '̲', '̳', '̹',
|
||||
'̺', '̻', '̼', 'ͅ',
|
||||
'͇', '͈', '͉', '͍',
|
||||
'͎', '͓', '͔', '͕',
|
||||
'͖', '͙', '͚', '̣'
|
||||
],
|
||||
"mid" : [
|
||||
'̕', '̛', '̀', '́',
|
||||
'͘', '̡', '̢', '̧',
|
||||
'̨', '̴', '̵', '̶',
|
||||
'͜', '͝', '͞',
|
||||
'͟', '͠', '͢', '̸',
|
||||
'̷', '͡', ' ҉'
|
||||
]
|
||||
},
|
||||
all = [].concat(soul.up, soul.down, soul.mid),
|
||||
zalgo = {};
|
||||
|
||||
function randomNumber(range) {
|
||||
var r = Math.floor(Math.random() * range);
|
||||
return r;
|
||||
}
|
||||
|
||||
function is_char(character) {
|
||||
var bool = false;
|
||||
all.filter(function (i) {
|
||||
bool = (i === character);
|
||||
});
|
||||
return bool;
|
||||
}
|
||||
|
||||
|
||||
function heComes(text, options) {
|
||||
var result = '', counts, l;
|
||||
options = options || {};
|
||||
options["up"] = typeof options["up"] !== 'undefined' ? options["up"] : true;
|
||||
options["mid"] = typeof options["mid"] !== 'undefined' ? options["mid"] : true;
|
||||
options["down"] = typeof options["down"] !== 'undefined' ? options["down"] : true;
|
||||
options["size"] = typeof options["size"] !== 'undefined' ? options["size"] : "maxi";
|
||||
text = text.split('');
|
||||
for (l in text) {
|
||||
if (is_char(l)) {
|
||||
continue;
|
||||
}
|
||||
result = result + text[l];
|
||||
counts = {"up" : 0, "down" : 0, "mid" : 0};
|
||||
switch (options.size) {
|
||||
case 'mini':
|
||||
counts.up = randomNumber(8);
|
||||
counts.mid = randomNumber(2);
|
||||
counts.down = randomNumber(8);
|
||||
break;
|
||||
case 'maxi':
|
||||
counts.up = randomNumber(16) + 3;
|
||||
counts.mid = randomNumber(4) + 1;
|
||||
counts.down = randomNumber(64) + 3;
|
||||
break;
|
||||
default:
|
||||
counts.up = randomNumber(8) + 1;
|
||||
counts.mid = randomNumber(6) / 2;
|
||||
counts.down = randomNumber(8) + 1;
|
||||
break;
|
||||
}
|
||||
|
||||
var arr = ["up", "mid", "down"];
|
||||
for (var d in arr) {
|
||||
var index = arr[d];
|
||||
for (var i = 0 ; i <= counts[index]; i++) {
|
||||
if (options[index]) {
|
||||
result = result + soul[index][randomNumber(soul[index].length)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// don't summon him
|
||||
return heComes(text, options);
|
||||
}
|
||||
-113
@@ -1,113 +0,0 @@
|
||||
var colors = require('./colors');
|
||||
|
||||
module['exports'] = function () {
|
||||
|
||||
//
|
||||
// Extends prototype of native string object to allow for "foo".red syntax
|
||||
//
|
||||
var addProperty = function (color, func) {
|
||||
String.prototype.__defineGetter__(color, func);
|
||||
};
|
||||
|
||||
var sequencer = function sequencer (map, str) {
|
||||
return function () {
|
||||
var exploded = this.split(""), i = 0;
|
||||
exploded = exploded.map(map);
|
||||
return exploded.join("");
|
||||
}
|
||||
};
|
||||
|
||||
addProperty('strip', function () {
|
||||
return colors.strip(this);
|
||||
});
|
||||
|
||||
addProperty('stripColors', function () {
|
||||
return colors.strip(this);
|
||||
});
|
||||
|
||||
addProperty("trap", function(){
|
||||
return colors.trap(this);
|
||||
});
|
||||
|
||||
addProperty("zalgo", function(){
|
||||
return colors.zalgo(this);
|
||||
});
|
||||
|
||||
addProperty("zebra", function(){
|
||||
return colors.zebra(this);
|
||||
});
|
||||
|
||||
addProperty("rainbow", function(){
|
||||
return colors.rainbow(this);
|
||||
});
|
||||
|
||||
addProperty("random", function(){
|
||||
return colors.random(this);
|
||||
});
|
||||
|
||||
addProperty("america", function(){
|
||||
return colors.america(this);
|
||||
});
|
||||
|
||||
//
|
||||
// Iterate through all default styles and colors
|
||||
//
|
||||
var x = Object.keys(colors.styles);
|
||||
x.forEach(function (style) {
|
||||
addProperty(style, function () {
|
||||
return colors.stylize(this, style);
|
||||
});
|
||||
});
|
||||
|
||||
function applyTheme(theme) {
|
||||
//
|
||||
// Remark: This is a list of methods that exist
|
||||
// on String that you should not overwrite.
|
||||
//
|
||||
var stringPrototypeBlacklist = [
|
||||
'__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__', 'charAt', 'constructor',
|
||||
'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf', 'charCodeAt',
|
||||
'indexOf', 'lastIndexof', 'length', 'localeCompare', 'match', 'replace', 'search', 'slice', 'split', 'substring',
|
||||
'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toUpperCase', 'trim', 'trimLeft', 'trimRight'
|
||||
];
|
||||
|
||||
Object.keys(theme).forEach(function (prop) {
|
||||
if (stringPrototypeBlacklist.indexOf(prop) !== -1) {
|
||||
console.log('warn: '.red + ('String.prototype' + prop).magenta + ' is probably something you don\'t want to override. Ignoring style name');
|
||||
}
|
||||
else {
|
||||
if (typeof(theme[prop]) === 'string') {
|
||||
colors[prop] = colors[theme[prop]];
|
||||
addProperty(prop, function () {
|
||||
return colors[theme[prop]](this);
|
||||
});
|
||||
}
|
||||
else {
|
||||
addProperty(prop, function () {
|
||||
var ret = this;
|
||||
for (var t = 0; t < theme[prop].length; t++) {
|
||||
ret = colors[theme[prop][t]](ret);
|
||||
}
|
||||
return ret;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
colors.setTheme = function (theme) {
|
||||
if (typeof theme === 'string') {
|
||||
try {
|
||||
colors.themes[theme] = require(theme);
|
||||
applyTheme(colors.themes[theme]);
|
||||
return colors.themes[theme];
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
return err;
|
||||
}
|
||||
} else {
|
||||
applyTheme(theme);
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
var colors = require('./colors');
|
||||
module['exports'] = colors;
|
||||
|
||||
// Remark: By default, colors will add style properties to String.prototype
|
||||
//
|
||||
// If you don't wish to extend String.prototype you can do this instead and native String will not be touched
|
||||
//
|
||||
// var colors = require('colors/safe);
|
||||
// colors.red("foo")
|
||||
//
|
||||
//
|
||||
require('./extendStringPrototype')();
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
var colors = require('../colors');
|
||||
|
||||
module['exports'] = (function() {
|
||||
return function (letter, i, exploded) {
|
||||
if(letter === " ") return letter;
|
||||
switch(i%3) {
|
||||
case 0: return colors.red(letter);
|
||||
case 1: return colors.white(letter)
|
||||
case 2: return colors.blue(letter)
|
||||
}
|
||||
}
|
||||
})();
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
var colors = require('../colors');
|
||||
|
||||
module['exports'] = (function () {
|
||||
var rainbowColors = ['red', 'yellow', 'green', 'blue', 'magenta']; //RoY G BiV
|
||||
return function (letter, i, exploded) {
|
||||
if (letter === " ") {
|
||||
return letter;
|
||||
} else {
|
||||
return colors[rainbowColors[i++ % rainbowColors.length]](letter);
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
var colors = require('../colors');
|
||||
|
||||
module['exports'] = (function () {
|
||||
var available = ['underline', 'inverse', 'grey', 'yellow', 'red', 'green', 'blue', 'white', 'cyan', 'magenta'];
|
||||
return function(letter, i, exploded) {
|
||||
return letter === " " ? letter : colors[available[Math.round(Math.random() * (available.length - 1))]](letter);
|
||||
};
|
||||
})();
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
var colors = require('../colors');
|
||||
|
||||
module['exports'] = function (letter, i, exploded) {
|
||||
return i % 2 === 0 ? letter : colors.inverse(letter);
|
||||
};
|
||||
-77
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
var styles = {};
|
||||
module['exports'] = styles;
|
||||
|
||||
var codes = {
|
||||
reset: [0, 0],
|
||||
|
||||
bold: [1, 22],
|
||||
dim: [2, 22],
|
||||
italic: [3, 23],
|
||||
underline: [4, 24],
|
||||
inverse: [7, 27],
|
||||
hidden: [8, 28],
|
||||
strikethrough: [9, 29],
|
||||
|
||||
black: [30, 39],
|
||||
red: [31, 39],
|
||||
green: [32, 39],
|
||||
yellow: [33, 39],
|
||||
blue: [34, 39],
|
||||
magenta: [35, 39],
|
||||
cyan: [36, 39],
|
||||
white: [37, 39],
|
||||
gray: [90, 39],
|
||||
grey: [90, 39],
|
||||
|
||||
bgBlack: [40, 49],
|
||||
bgRed: [41, 49],
|
||||
bgGreen: [42, 49],
|
||||
bgYellow: [43, 49],
|
||||
bgBlue: [44, 49],
|
||||
bgMagenta: [45, 49],
|
||||
bgCyan: [46, 49],
|
||||
bgWhite: [47, 49],
|
||||
|
||||
// legacy styles for colors pre v1.0.0
|
||||
blackBG: [40, 49],
|
||||
redBG: [41, 49],
|
||||
greenBG: [42, 49],
|
||||
yellowBG: [43, 49],
|
||||
blueBG: [44, 49],
|
||||
magentaBG: [45, 49],
|
||||
cyanBG: [46, 49],
|
||||
whiteBG: [47, 49]
|
||||
|
||||
};
|
||||
|
||||
Object.keys(codes).forEach(function (key) {
|
||||
var val = codes[key];
|
||||
var style = styles[key] = [];
|
||||
style.open = '\u001b[' + val[0] + 'm';
|
||||
style.close = '\u001b[' + val[1] + 'm';
|
||||
});
|
||||
-61
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
var argv = process.argv;
|
||||
|
||||
module.exports = (function () {
|
||||
if (argv.indexOf('--no-color') !== -1 ||
|
||||
argv.indexOf('--color=false') !== -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (argv.indexOf('--color') !== -1 ||
|
||||
argv.indexOf('--color=true') !== -1 ||
|
||||
argv.indexOf('--color=always') !== -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (process.stdout && !process.stdout.isTTY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ('COLORTERM' in process.env) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (process.env.TERM === 'dumb') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
})();
|
||||
-58
@@ -1,58 +0,0 @@
|
||||
{
|
||||
"name": "colors",
|
||||
"description": "get colors in your node.js console",
|
||||
"version": "1.1.2",
|
||||
"author": {
|
||||
"name": "Marak Squires"
|
||||
},
|
||||
"homepage": "https://github.com/Marak/colors.js",
|
||||
"bugs": {
|
||||
"url": "https://github.com/Marak/colors.js/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"ansi",
|
||||
"terminal",
|
||||
"colors"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "http://github.com/Marak/colors.js.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "node tests/basic-test.js && node tests/safe-test.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.1.90"
|
||||
},
|
||||
"main": "lib",
|
||||
"files": [
|
||||
"examples",
|
||||
"lib",
|
||||
"LICENSE",
|
||||
"safe.js",
|
||||
"themes"
|
||||
],
|
||||
"gitHead": "8bf2ad9fa695dcb30b7e9fd83691b139fd6655c4",
|
||||
"_id": "colors@1.1.2",
|
||||
"_shasum": "168a4701756b6a7f51a12ce0c97bfa28c084ed63",
|
||||
"_from": "colors@",
|
||||
"_npmVersion": "2.1.8",
|
||||
"_nodeVersion": "0.11.13",
|
||||
"_npmUser": {
|
||||
"name": "marak",
|
||||
"email": "marak.squires@gmail.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "marak",
|
||||
"email": "marak.squires@gmail.com"
|
||||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "168a4701756b6a7f51a12ce0c97bfa28c084ed63",
|
||||
"tarball": "http://registry.npmjs.org/colors/-/colors-1.1.2.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz"
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
//
|
||||
// Remark: Requiring this file will use the "safe" colors API which will not touch String.prototype
|
||||
//
|
||||
// var colors = require('colors/safe);
|
||||
// colors.red("foo")
|
||||
//
|
||||
//
|
||||
var colors = require('./lib/colors');
|
||||
module['exports'] = colors;
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
module['exports'] = {
|
||||
silly: 'rainbow',
|
||||
input: 'grey',
|
||||
verbose: 'cyan',
|
||||
prompt: 'grey',
|
||||
info: 'green',
|
||||
data: 'grey',
|
||||
help: 'cyan',
|
||||
warn: 'yellow',
|
||||
debug: 'blue',
|
||||
error: 'red'
|
||||
};
|
||||
@@ -1,23 +0,0 @@
|
||||
/**
|
||||
* @file server_config.js
|
||||
* @author frtk
|
||||
*/
|
||||
|
||||
var Config = {
|
||||
VERSION : '0.0.8',
|
||||
HTTP: {
|
||||
host: '127.0.0.1',
|
||||
port: 8042
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* EXPORTS
|
||||
*
|
||||
*/
|
||||
if (typeof exports !== "undefined") {
|
||||
exports.Config = Config;
|
||||
}
|
||||
@@ -1,141 +0,0 @@
|
||||
/**
|
||||
* @file server_core.js
|
||||
* @author frtk
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* nodePong Server Object
|
||||
*
|
||||
*/
|
||||
var NPGServer = {
|
||||
|
||||
/*
|
||||
* Data
|
||||
*/
|
||||
// app
|
||||
version: '',
|
||||
host: '',
|
||||
port: 0,
|
||||
|
||||
// Users and Games
|
||||
users: [],
|
||||
games: [],
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
//--- init()
|
||||
init: function(o) {
|
||||
var self = this;
|
||||
self.version = o.VERSION || '';
|
||||
self.host = o.HTTP.host || '';
|
||||
self.port = o.HTTP.port || 8042;
|
||||
self.log('$ ##### nodePong - v'+self.version);
|
||||
},
|
||||
|
||||
|
||||
//--- setVersion(s)
|
||||
setVersion: function(s) {
|
||||
this.version = s;
|
||||
},
|
||||
|
||||
|
||||
/*
|
||||
* Server Messages
|
||||
*/
|
||||
//---
|
||||
log: function(msg) {
|
||||
var self = this;
|
||||
return console.log(self.newDateToString() + msg);
|
||||
},
|
||||
//--- dateToString
|
||||
dateToString: function(date) {
|
||||
var self = this;
|
||||
return '[' + self.addZero(date.getHours(), 'h') + ':'
|
||||
+ self.addZero(date.getMinutes(), 'm') + ':'
|
||||
+ self.addZero(date.getSeconds(), 's') + ':'
|
||||
+ self.addZero(date.getMilliseconds(), 'ms') + ']';
|
||||
},
|
||||
//--- addZero
|
||||
addZero: function(value, type) {
|
||||
switch(type) {
|
||||
case 'h':
|
||||
case 'm':
|
||||
case 's':
|
||||
if (value < 10) value = '0' + value;
|
||||
break;
|
||||
case 'ms':
|
||||
if (value < 10) value = '00' + value;
|
||||
else if (value >= 10 && value < 100) value = '0' + value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
return value;
|
||||
},
|
||||
//--- return new date string
|
||||
newDateToString: function() {
|
||||
var self = this;
|
||||
return self.dateToString(new Date());
|
||||
},
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Socket.io handling
|
||||
*/
|
||||
//---
|
||||
socketHandling: function(io) {
|
||||
var self = this;
|
||||
io.sockets.on('connection', function (socket) {
|
||||
//
|
||||
self.log('$ User connected : id=' + socket.id);
|
||||
|
||||
// 'disconnect'
|
||||
socket.on('disconnect', function () { self.log('$ User disconnected : id=' + socket.id);
|
||||
});
|
||||
|
||||
//
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* nodePong User Object
|
||||
*
|
||||
*/
|
||||
var User = function(name) {
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* nodePong Game Object
|
||||
*
|
||||
*/
|
||||
var Game = function() {
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* EXPORT
|
||||
*
|
||||
*/
|
||||
if (typeof exports !== "undefined") {
|
||||
exports.NPGServer = NPGServer;
|
||||
exports.User = User;
|
||||
exports.Game = Game;
|
||||
}
|
||||
Reference in new issue
Block a user