* Code cleanup and eslint since -- remove unused variables, clean up RegExs, so on...

This commit is contained in:
Bryan Ashby 2018-01-15 12:22:11 -07:00
parent a106050ba3
commit ac1433e84b
112 changed files with 1375 additions and 1898 deletions

View file

@ -52,8 +52,8 @@ exports.Client = Client;
// Resources & Standards:
// * http://www.ansi-bbs.org/ansi-bbs-core-server.html
//
const RE_DSR_RESPONSE_ANYWHERE = /(?:\u001b\[)([0-9\;]+)(R)/;
const RE_DEV_ATTR_RESPONSE_ANYWHERE = /(?:\u001b\[)[\=\?]([0-9a-zA-Z\;]+)(c)/;
const RE_DSR_RESPONSE_ANYWHERE = /(?:\u001b\[)([0-9;]+)(R)/;
const RE_DEV_ATTR_RESPONSE_ANYWHERE = /(?:\u001b\[)[=?]([0-9a-zA-Z;]+)(c)/;
const RE_META_KEYCODE_ANYWHERE = /(?:\u001b)([a-zA-Z0-9])/;
const RE_META_KEYCODE = new RegExp('^' + RE_META_KEYCODE_ANYWHERE.source + '$');
const RE_FUNCTION_KEYCODE_ANYWHERE = new RegExp('(?:\u001b+)(O|N|\\[|\\[\\[)(?:' + [
@ -64,19 +64,19 @@ const RE_FUNCTION_KEYCODE_ANYWHERE = new RegExp('(?:\u001b+)(O|N|\\[|\\[\\[)(?:'
const RE_FUNCTION_KEYCODE = new RegExp('^' + RE_FUNCTION_KEYCODE_ANYWHERE.source);
const RE_ESC_CODE_ANYWHERE = new RegExp( [
RE_FUNCTION_KEYCODE_ANYWHERE.source,
RE_META_KEYCODE_ANYWHERE.source,
RE_FUNCTION_KEYCODE_ANYWHERE.source,
RE_META_KEYCODE_ANYWHERE.source,
RE_DSR_RESPONSE_ANYWHERE.source,
RE_DEV_ATTR_RESPONSE_ANYWHERE.source,
/\u001b./.source
].join('|'));
function Client(input, output) {
function Client(/*input, output*/) {
stream.call(this);
const self = this;
this.user = new User();
this.currentTheme = { info : { name : 'N/A', description : 'None' } };
this.lastKeyPressMs = Date.now();
@ -125,9 +125,9 @@ function Client(input, output) {
if(!termClient) {
if(_.startsWith(deviceAttr, '67;84;101;114;109')) {
//
//
// See https://github.com/protomouse/synchronet/blob/master/src/conio/cterm.txt
//
//
// Known clients:
// * SyncTERM
//
@ -139,11 +139,11 @@ function Client(input, output) {
};
this.isMouseInput = function(data) {
return /\x1b\[M/.test(data) ||
/\u001b\[M([\x00\u0020-\uffff]{3})/.test(data) ||
return /\x1b\[M/.test(data) || // eslint-disable-line no-control-regex
/\u001b\[M([\x00\u0020-\uffff]{3})/.test(data) || // eslint-disable-line no-control-regex
/\u001b\[(\d+;\d+;\d+)M/.test(data) ||
/\u001b\[<(\d+;\d+;\d+)([mM])/.test(data) ||
/\u001b\[<(\d+;\d+;\d+;\d+)&w/.test(data) ||
/\u001b\[<(\d+;\d+;\d+;\d+)&w/.test(data) ||
/\u001b\[24([0135])~\[(\d+),(\d+)\]\r/.test(data) ||
/\u001b\[(O|I)/.test(data);
};
@ -163,7 +163,7 @@ function Client(input, output) {
'OE' : { name : 'clear' },
'OF' : { name : 'end' },
'OH' : { name : 'home' },
// xterm/rxvt
'[11~' : { name : 'f1' },
'[12~' : { name : 'f2' },
@ -290,7 +290,7 @@ function Client(input, output) {
if(self.cprOffset) {
cprArgs[0] = cprArgs[0] + self.cprOffset;
cprArgs[1] = cprArgs[1] + self.cprOffset;
}
}
self.emit('cursor position report', cprArgs);
}
}
@ -299,7 +299,7 @@ function Client(input, output) {
var termClient = self.getTermClient(parts[1]);
if(termClient) {
self.term.termClient = termClient;
}
}
} else if('\r' === s) {
key.name = 'return';
} else if('\n' === s) {
@ -347,10 +347,10 @@ function Client(input, output) {
key.meta = true;
key.shift = /^[A-Z]$/.test(parts[1]);
} else if((parts = RE_FUNCTION_KEYCODE.exec(s))) {
var code =
var code =
(parts[1] || '') + (parts[2] || '') +
(parts[4] || '') + (parts[9] || '');
var modifier = (parts[3] || parts[8] || 1) - 1;
key.ctrl = !!(modifier & 4);
@ -375,7 +375,7 @@ function Client(input, output) {
//
// Adjust name for CTRL/Shift/Meta modifiers
//
key.name =
key.name =
(key.ctrl ? 'ctrl + ' : '') +
(key.meta ? 'meta + ' : '') +
(key.shift ? 'shift + ' : '') +
@ -446,7 +446,7 @@ Client.prototype.end = function () {
}
clearInterval(this.idleCheck);
try {
//
// We can end up calling 'end' before TTY/etc. is established, e.g. with SSH
@ -482,7 +482,7 @@ Client.prototype.isLocal = function() {
///////////////////////////////////////////////////////////////////////////////
// :TODO: getDefaultHandler(name) -- handlers in default_handlers.js or something
Client.prototype.defaultHandlerMissingMod = function(err) {
Client.prototype.defaultHandlerMissingMod = function() {
var self = this;
function handler(err) {
@ -493,12 +493,12 @@ Client.prototype.defaultHandlerMissingMod = function(err) {
self.term.write('This has been logged for your SysOp to review.\n');
self.term.write('\nGoodbye!\n');
//self.term.write(err);
//if(miscUtil.isDevelopment() && err.stack) {
// self.term.write('\n' + err.stack + '\n');
//}
//}
self.end();
}
@ -516,8 +516,8 @@ Client.prototype.terminalSupports = function(query) {
case 'vtx_hyperlink' :
return 'vtx' === termClient;
default :
default :
return false;
}
};