Enabled imbedding fields, added nodeid

This commit is contained in:
Deon George
2020-11-01 21:55:32 +11:00
parent fe21ee5379
commit 440f34919c
9 changed files with 83 additions and 16 deletions

View File

@@ -111,11 +111,7 @@ function ANSIFrame() {
console.clear();
if ((this.type == FRAME_TYPE_LOGIN) || (this.type == FRAME_TYPE_RESPONSE)) {
return console.putmsg(header+this.parse(base64_decode(this.content)));
} else {
return console.putmsg(header+base64_decode(this.content));
}
return console.putmsg(header+this.parse(base64_decode(this.content)));
};
this.fieldValue=function(key) {
@@ -286,7 +282,34 @@ function ANSIFrame() {
break;
// SOS
// X - dynamic fields, terminated with ESC
case 'X':
//log(LOG_DEBUG,'PU ['+r+'x'+c+'] '+advance);
advance++;
// Find our end ST param in the next 50 chars
matches = text.substr(p+advance,50).match(/(([a-z]+;[0-9]+)([;]?.+)?)\x1b\\/);
//log(LOG_DEBUG,'PU ['+r+'x'+c+'] ADVANCE: '+advance+', MATCHES: '+JSON.stringify(matches)+', LENGTH: '+(matches ? matches[0].length : 0)+', STRING: '+text.substr(p+advance,50));
if (! matches) {
chars += nextbyte;
break;
}
advance += matches[0].length-1;
var pu = matches[0].substr(0,matches[0].length-2).split(';');
//log(LOG_DEBUG,'PU ['+r+'x'+c+'] ADVANCE: '+advance+', PU: '+pu);
chars = renderfield(pu[0],pu[1]);
byte = '';
log(LOG_DEBUG,'PU Field found at ['+r+'x'+(c-1)+'], Field: '+pu[0]+', Length: '+pu[1]+', Attrs: '+JSON.stringify({i:i,f:f,b:b}));
break;
// _ - has our fields that take input
case '_':
//log(LOG_DEBUG,'SOS ['+r+'x'+c+'] '+advance);
advance++;
@@ -304,10 +327,11 @@ function ANSIFrame() {
advance += matches[0].length-1;
// The last 2 chars of matches[0] are the ESC \
sos = matches[0].substr(0,matches[0].length-2).split(';');
var sos = matches[0].substr(0,matches[0].length-2).split(';');
//log(LOG_DEBUG,'SOS ['+r+'x'+c+'] ADVANCE: '+advance+', SOS: '+sos);
var num = null;
var field = null;
var fieldlen = null;
for (num in sos) {
//log(LOG_DEBUG,'SOS ['+r+'x'+c+'] NUM: '+num+', SOS: '+sos[num]);
@@ -548,4 +572,4 @@ function ANSIFrame() {
return base64_decode(pageOwner(this.frame).logoans);
}
})
}
}

View File

@@ -35,4 +35,6 @@ var INKEY_TIMEOUT =10000;
var INACTIVE_NOLOGIN =30000;
var INACTIVE_LOGIN =5*60000;
this;
var SYSTEM_ZONE =516;
this;

View File

@@ -112,6 +112,26 @@ function getArg(key,error,abort) {
}
}
/**
* Returns the current node number
*
* @returns {string}
*/
function getNodeID() {
var regex = new RegExp('^'+SYSTEM_ZONE+':');
for each (var addr in system.fido_addr_list)
{
if (regex.test(addr)) {
addr = addr.replace(regex,'');
matches = addr.split('/',2);
break;
}
}
return pad(matches[0],3)+pad(matches[1],3)+pad(bbs.node_num,2);
}
function getPageOwners() {
// Load the owner configuration into memory
if (! pageowners.length) {
@@ -173,6 +193,13 @@ function msgBaseImport(msgbase,page,text) {
return msgbase.save_msg(hdr, body);
}
// Pad a number with zeros
function pad(n, width, z) {
z = z || '0';
n = n + '';
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
}
/**
* Return the frame as a string
*/
@@ -252,8 +279,22 @@ function pageEditor(page) {
return pageditor;
}
function renderfield(field,length) {
switch (field) {
case 'nodeid':
result = getNodeID();
}
if (result.length < length)
result += ' '.repeat(length-result.length);
else if (result.length > length)
result = result.substr(0,length);
return result;
}
function compare(a,b) {
return (a.prefix < b.prefix) ? 1 : ((b.prefix < a.prefix) ? -1 : 0);
}
this;
this;