Numerous minor fixes needed for echomail control, register control. Revert our page object, if the requested page doesnt exist. Rework default pages.

This commit is contained in:
2024-01-01 17:03:25 +11:00
parent de04ec11ee
commit a1bcc1f5cb
68 changed files with 350 additions and 336 deletions

View File

@@ -17,16 +17,15 @@ var CONTROL_ECHOMAIL = '1';
log(LOG_DEBUG,'+ Control ECHOMAIL loaded');
// A unique method name (same as the control name that is called as new method() on initialisation
function echomail(pagenum,session) {
function echomail(session,pagenum) {
log(LOG_DEBUG,' - Loading echomail page:'+pagenum);
// has this control completed
var complete = false;
var ready = false;
function init(pagenum,session) {
log(LOG_DEBUG,'- init()');
function init(session,pagenum) {
log(LOG_DEBUG,' - Echomail init('+pagenum+')');
ready = session.loadMessage(pagenum);
}
@@ -59,7 +58,7 @@ function echomail(pagenum,session) {
break;
}
so.render();
session.render();
return read;
}
@@ -75,6 +74,7 @@ function echomail(pagenum,session) {
* @returns {boolean}
*/
this.ready = function() {
log(LOG_DEBUG,'echomail:ready = '+JSON.stringify(ready));
return ready;
}

View File

@@ -8,11 +8,15 @@ load('graphic.js');
var CONTROL_FRAMEEDIT = '1';
function edit(fo) {
function edit(session) {
log(LOG_DEBUG,'+ Control EDIT loaded');
var complete = false;
var inProperty = false;
function init(session) {
log(LOG_DEBUG,' - Edit init()');
}
Object.defineProperty(this,'getName', {
get: function() {
return 'Frame Edit';
@@ -148,6 +152,6 @@ function edit(fo) {
save();
onexit();
}
}
this;
init.apply(this,arguments);
}

View File

@@ -2,7 +2,7 @@
* This handles user registration.
*
* The form must have the following fields:
* + UID The user's user id to login
* + USER The user's user id to login
* + EMAIL The users's email address - to receive tokens
* + FULLNAME The user's full name
* + PASS The users's preferred password
@@ -17,10 +17,16 @@ var cValChars='ACDEFHJKLMNPQRTUVWXY23456789!@$%&';
log(LOG_DEBUG,'+ Control REGISTER loaded');
function register() {
function register(session) {
var code = '';
var complete = false;
var processed = false;
var ready = false;
function init(session) {
log(LOG_DEBUG,' - Register init()');
ready = true;
}
// Called before processing for a field
Object.defineProperty(this, 'getName', {
@@ -35,11 +41,11 @@ function register() {
}
});
this.handle=function(read) {
this.handle = function(read) {
// Dont allow existing users to re-register
if (user.number) {
fo.baselineSend('ALREADY_MEMBER',false);
return read === '*' ? read : '';
session.baselineSend('ALREADY_MEMBER',false);
return (read === '*') ? read : '';
}
log(LOG_DEBUG,'Control REGISTER handle() start. ('+read+')');
@@ -55,9 +61,9 @@ function register() {
complete = true;
} else {
fo.baselineSend('INVALID_CODE',false);
fo.cursorOn(cf.c+cf.value.length,cf.r);
fo.attr(cf.attribute);
session.baselineSend('INVALID_CODE',false);
session.cursorOn(cf.c+cf.value.length,cf.r);
session.attr(cf.attribute);
read = '';
}
}
@@ -67,31 +73,31 @@ function register() {
return read;
}
// Make sure we got an email
this.prefield=function() {
this.prefield = function() {
log(LOG_DEBUG,'- prefield: Field '+cf.name+'('+JSON.stringify(cf)+')');
// Make sure we got an email
if (cf.name === 'TOKEN') {
if (! code.length) {
log(LOG_DEBUG,' - BASELINE '+cf.name+'('+JSON.stringify(cf)+')');
fo.baselineSend('TOKEN_EMAIL',false);
session.baselineSend('TOKEN_EMAIL',false);
var email = fo.fieldValue('EMAIL');
var uid = fo.fieldValue('UID');
var name = fo.fieldValue('FULLNAME');
var email = session.fieldValue('EMAIL');
var uid = session.fieldValue('USER');
var name = session.fieldValue('FULLNAME');
log(LOG_DEBUG,' - VALIDATE EMAIL TO ('+JSON.stringify(system.matchuserdata(U_NETMAIL,email))+')');
// Validate Email hasnt been used
// Validate USER_ID hasnt been used
if ((email.indexOf('@') === -1) || ! EMAIL_REGEX.test(email) || (system.matchuserdata(U_NETMAIL,email) !== 0)) {
fo.baselineSend('INVALID_EMAIL',false);
session.baselineSend('INVALID_EMAIL',false);
return;
}
if (! system.check_name(uid)) {
log(LOG_DEBUG,' - Cannot use user_id: ('+uid+')');
fo.baselineSend('INVALID_UID',false);
session.baselineSend('INVALID_UID',false);
return;
}
@@ -101,18 +107,20 @@ function register() {
}
var hdrs = new Object();
hdrs.to=name;
hdrs.to_net_type=netaddr_type(email);
hdrs.to = name;
hdrs.to_net_type = netaddr_type(email);
if (hdrs.to_net_type !== NET_NONE) {
hdrs.to_net_addr = email;
} else {
fo.baselineSend('CANNOT_SEND_TOKEN',false);
session.baselineSend('CANNOT_SEND_TOKEN',false);
return;
}
hdrs.from=system.name;
hdrs.from_net_addr='sysop@'+system.inet_addr;
hdrs.from_net_type=NET_INTERNET;
hdrs.subject='Registration TOKEN for '+system.name;
hdrs.from = system.name;
hdrs.from_net_addr = 'sysop@'+system.inet_addr;
hdrs.from_net_type = NET_INTERNET;
hdrs.subject = 'Registration TOKEN for '+system.name;
if (msgbase.open !== undefined && msgbase.open() === false) {
console.print("\r\n\1n\1h\1rERROR: \1y" + msgbase.last_error + "\1n \r\n");
@@ -137,19 +145,19 @@ function register() {
msgbase.close();
}
fo.baselineSend('TOKEN_SENT',false);
session.baselineSend('TOKEN_SENT',false);
log(LOG_DEBUG,'SENT EMAIL TOKEN ('+code+') ['+JSON.stringify(hdrs)+']');
}
}
this.process=function() {
log(LOG_DEBUG,'Creating user: '+fo.fieldValue('EMAIL'));
this.process = function() {
log(LOG_DEBUG,'Creating user: ['+session.fieldValue('EMAIL')+'] ['+session.fieldValue('USER')+']');
try {
var newuser = system.new_user(fo.fieldValue('UID'));
var newuser = system.new_user(session.fieldValue('USER'));
} catch (e) {
fo.baselineSend('USER_EXISTS',false);
session.baselineSend('USER_EXISTS',false);
log(LOG_ERROR,"New user couldn't be created (user created while signing up)");
log(LOG_ERROR,JSON.stringify(e));
processed = true;
@@ -157,7 +165,7 @@ function register() {
}
if (typeof newuser === 'number') {
fo.baselineSend('USER_CREATE_ERROR',false);
session.baselineSend('USER_CREATE_ERROR',false);
log(LOG_ERROR,"New user couldn't be created (error code "+newuser+")");
processed = true;
return this.isComplete;
@@ -166,12 +174,12 @@ function register() {
newuser.security.password = '';
if (bbs.login(newuser.alias,null)) {
user.number = newuser.number;
user.security.password = fo.fieldValue('PASS');
user.name = fo.fieldValue('FULLNAME');
user.handle = fo.fieldValue('UID');
user.location = fo.fieldValue('CITY')+', '+fo.fieldValue('COUNTRY');
user.zipcode = fo.fieldValue('PCODE');
user.netmail = fo.fieldValue('EMAIL');
user.security.password = session.fieldValue('PASS');
user.name = session.fieldValue('FULLNAME');
user.handle = session.fieldValue('USER');
user.location = session.fieldValue('CITY')+', '+session.fieldValue('COUNTRY');
user.zipcode = session.fieldValue('PCODE');
user.netmail = session.fieldValue('EMAIL');
user.comment = 'ANSItex registered user';
bbs.user_sync();
bbs.logon();
@@ -183,7 +191,7 @@ function register() {
return this.isComplete;
} else {
fo.baselineSend('LOGIN_ERROR',false);
session.baselineSend('LOGIN_ERROR',false);
log(LOG_INFO,"bbs.login() failed");
user.comment = 'Initial login failed!';
newuser.settings |= USER_DELETED;
@@ -193,6 +201,12 @@ function register() {
return this.isComplete;
}
}
}
this;
// @todo Doesnt appear to be used
this.ready = function() {
log(LOG_DEBUG,'register:ready = '+JSON.stringify(ready));
return ready;
}
init.apply(this,arguments);
}

View File

@@ -2,6 +2,10 @@
* ANSItex definitions
*/
/* Our home on disk */
const ANSITEX_HOME = system.mods_dir+'ansitex';
/* Frames location */
const FRAMES_HOME = ANSITEX_HOME+'/text/';
/* Load frames from msgbase */
const FRAMES_MSG_BASE = 'vtx_data';
/* Load frames from files */
@@ -97,20 +101,20 @@ const INACTIVE_NOLOGIN = 30000;
const INACTIVE_LOGIN = 5*60000;
/* Home Frame */
const FRAME_HOME = {frame: 1,index: 'a'};
const FRAME_HOME = {frame: '1',index: 'a'};
/* Login Frame */
const FRAME_LOGIN = {frame: 98,index: 'a'};
const FRAME_LOGIN = {frame: '98',index: 'a'};
/* Registration Frame */
const FRAME_REGISTER = {frame: 981,index: 'a'};
const FRAME_REGISTER = {frame: '981',index: 'a'};
/* SQRL Login */
const FRAME_SQRL = {frame: 982,index: 'a'};
const FRAME_SQRL = {frame: '982',index: 'a'};
/* Login Failed */
const FRAME_LOGIN_FAILED = {frame: 983,index: 'a'};
const FRAME_LOGIN_FAILED = {frame: '983',index: 'a'};
/* Home page after authentication */
const FRAME_HOME_AUTH = {frame: 98,index: 'b'};
const FRAME_HOME_AUTH = {frame: '98',index: 'b'};
/* Home page for initial connection */
const FRAME_HOME_CONNECT = {frame: 980,index: 'a'};
const FRAME_SYSTEM_ERROR = {frame: 998,index: 'a'};
const FRAME_HOME_CONNECT = {frame: '980',index: 'a'};
const FRAME_SYSTEM_ERROR = {frame: '998',index: 'a'};
/* Attributes saved/loaded from files */
const FRAME_SAVE_ATTRS = [
@@ -129,13 +133,17 @@ const FRAME_SAVE_ATTRS = [
];
/* The page that has our echomail area reading template */
const MAIL_TEMPLATE_FRAME = {frame: 199,index: 'a'};
const MAIL_TEMPLATE_FRAME = {frame: '199',index: 'a'};
/* The page that has our echomail area summary template */
const MAIL_TEMPLATE_AREA_SUMMARY = {frame: 198,index: 'a'};
const MAIL_TEMPLATE_AREA_SUMMARY = {frame: '198',index: 'a'};
// The maximum size of embedded dynamic fields in frames
const DYNAMIC_FIELD_SIZE_MAX = 50;
/** ESCAPE CODES **/
const ESC = '\x1b';
const FIELD_PASSWORD_MASK = '*';
const FIELD_TEXT = 't';
const FIELD_PASSWORD = 'p';

View File

@@ -1,3 +1,5 @@
require('ansitex/load/defs.js','ANSITEX_HOME'); // ANSITEX definitions
// Array of page owners
pageowners = [];
@@ -43,42 +45,6 @@ if (!String.prototype.repeat) {
return rpt;
};
}
/*
// Cant enable this - problem with frame.js, line 451. c.open not a function
// Group By
if (!Array.prototype.groupby) {
Array.prototype.groupby = function(prop) {
return this.reduce(function(groups, item) {
const val = item[prop]
groups[val] = groups[val] || []
groups[val].push(item)
return groups
}, {})
};
}
if (!Array.prototype.min) {
Array.prototype.min = function() {
return this[0];
}
}
if (!Array.prototype.max) {
Array.prototype.max = function() {
return this.reverse()[0];
}
}
if (!Array.prototype.pluck) {
Array.prototype.pluck = function(item) {
var pluck = [];
for(var x in this) {
if (this[x][item])
pluck.push(this[x][item]);
}
return pluck;
}
}
*/
/**
* Convert ANSI into BIN for loading into a Frame
@@ -307,7 +273,7 @@ function atcode(field,length,pad,context) {
break;
default:
result = (typeof bbs === 'undefined') ? '*'.repeat(Math.abs(length)) : bbs.atcode(field);
result = (typeof bbs === 'undefined') ? '*'.repeat(Math.abs(length)) : bbs.atcode(field+(args.length ? ':'+args : ''));
}
if ((result === null) || (typeof result === 'undefined'))
@@ -392,7 +358,7 @@ function getNodeID() {
function getPageOwners() {
// Load the owner configuration into memory
if (! pageowners.length) {
var f = new File(file_cfgname(system.mods_dir,'ansitex/ctrl/videotex.ini'));
var f = new File(ANSITEX_HOME+'/ctrl/videotex.ini');
if (f.open('r')) {
var logoans = f.iniGetValue('prefix','logoans');
@@ -409,6 +375,9 @@ function getPageOwners() {
//log(LOG_DEBUG,'+ pageOwner: users='+JSON.stringify(users));
pageowners.push({prefix: p,logoans: logoans,logovtx: logovtx,user:users});
});
} else {
log(LOG_DEBUG,'getPageOwners: Couldnt open videotex.ini? :'+JSON.stringify(f));
}
f.close();
@@ -423,9 +392,11 @@ function getPageOwners() {
}
function loadOptions(option) {
var f = new File(file_cfgname(system.mods_dir,'ansitex/ctrl/videotex.ini'));
var f = new File(ANSITEX_HOME+'/ctrl/videotex.ini');
if (! f.open('r')) {
log(LOG_DEBUG,'loadOptions: Couldnt open videotex.ini? :'+JSON.stringify(f));
return undefined;
}

View File

@@ -76,7 +76,6 @@
*/
load('ansitex/load/windows.js'); // Our supporting window class
require('ansitex/load/defs.js','FRAME_TYPE_INFO'); // FRAME definitions
require('ansitex/load/msgbases.js','MAX_PAGE_NUM'); // To read/write to message bases
require('sbbsdefs.js','SS_USERON'); // Need for our ANSI colors eg: BG_*
@@ -435,26 +434,42 @@ function Page(debug) {
var index = x-fields[i].x;
if (content[index])
build[fields[i].y][x].ch = fields[i].type !== 'p' ? content[index] : '*';
build[fields[i].y][x].ch = fields[i].type !== FIELD_PASSWORD ? content[index] : FIELD_PASSWORD_MASK;
}
}
}
}
/**
* Build in any input_fields with values
*/
this.build_input_fields = function()
{
var that = this;
var f = this.input_fields.filter(function(item) { return item.value.length; });
log(LOG_DEBUG,'* INPUT_FIELDS WITH VALUES:'+f.length);
if (f.length) {
f.forEach(function(field) {
that.input_field(field.name,field.value);
});
this.__compiled__.build = null;
}
}
/**
* Build in our dynamic_fields that can be populated automatically
*/
this.build_system_fields = function(context) {
var df = this.dynamic_fields.filter(function(item) { return item.value === undefined; });
if (! df.length)
return;
var that = this;
df.forEach(function(field) {
that.dynamic_field(field.name,atcode(field.name,field.length,field.pad,context));
});
var f = this.dynamic_fields.filter(function(item) { return item.value === undefined; });
if (f.length) {
f.forEach(function(field) {
that.dynamic_field(field.name,atcode(field.name,field.length,field.pad,context));
});
}
}
/**
@@ -820,11 +835,12 @@ function Page(debug) {
if (!(page instanceof PageObject))
throw new Error('page must be a PageObject');
// Try to load from the msgbase first
if (FRAMES_MSG_BASE && this.load(page))
// Load a page from disk first if it exists
if (FRAMES_MSG_FILES && this.import(FRAMES_HOME+SESSION_EXT+'/'+page.toString()))
return true;
return FRAMES_MSG_FILES ? this.import(system.mods_dir+'ansitex/text/'+page.toString()+'.'+SESSION_EXT) : false;
// Fall back to loading from msgbase
return FRAMES_MSG_BASE ? this.load(page) : false;
}
/**
@@ -857,7 +873,7 @@ function Page(debug) {
var f = new File(filename);
if (! f.exists || ! f.open('rb',true)) {
log(LOG_ERROR,' ? File doesnt exist: ['+filename+']');
log(LOG_ERROR,'|? File doesnt exist: ['+filename+']');
return null;
}
@@ -865,9 +881,11 @@ function Page(debug) {
f.close();
var valid_sauce = false;
var ext = file_getext(filename).substr(1).toLowerCase();
var ext = SESSION_EXT;
if (contents.substr(-128, 7) === 'SAUCE00') {
ext = file_getext(filename).substr(1).toLowerCase();
var sauceless_size = ascii(contents.substr(-35,1));
sauceless_size <<= 8;
sauceless_size |= ascii(contents.substr(-36,1));
@@ -932,6 +950,80 @@ function Page(debug) {
return this.preload((['vtx','tex'].indexOf(ext) !== -1) ? JSON.parse(contents) : contents,ext,width,height);
}
this.load = function(page) {
var headers;
var mb = new MsgBase(FRAMES_MSG_BASE);
try {
if (mb.open()) {
headers = mb.get_all_msg_headers(false,false) || [];
} else {
log(LOG_ERROR,'! ['+FRAMES_MSG_BASE+'] cannot be opened ['+mb.error+']');
return false;
}
// @todo It appears if the message base doesnt exist, we dont error?
} catch (e) {
log(LOG_ERROR,'! ['+FRAMES_MSG_BASE+'] cannot be opened ['+e.message+']');
return false;
}
var msg;
// Find existing message with the page number and delete it if defined
for(var x in headers) {
if ((headers[x].tags === page.toString()) && (!(headers[x].attr&MSG_DELETE)) && (headers[x].from === SESSION_EXT)) {
msg = headers[x];
break;
}
}
if (msg === undefined) {
log(LOG_DEBUG,'|- Frame not found: ['+page.toString()+'] in ['+FRAMES_MSG_BASE+']');
return false;
} else {
log(LOG_DEBUG,'|- Loading frame: ['+page.toString()+'] from msgbase ['+msg.number+']');
var contents = JSON.parse(mb.get_msg_body(false,msg.number,false,false,true,true));
return this.preload(contents,SESSION_EXT);
}
return false;
}
/**
* After page load routines
*/
this.loadcomplete = function() {
var po = pageOwner(this.name.frame);
switch (SESSION_EXT) {
case 'tex':
this.__window__.pagenum.__properties__.content = rawtoattrs(ESC+'[1;37m'+this.name.toString()).content;
this.provider = base64_decode(po.logoans);
break;
case 'vtx':
this.__window__.pagenum.__properties__.content = rawtoattrs(VIEWDATA_BIN_WHITE+this.name.toString()).content;
this.provider = base64_decode(po.logovtx);
break;
default:
throw new Error(SESSION_EXT+' hasnt been implemented');
}
// Dont show header on un-authed login frames
if (! user.number)
this.showHeader = false;
}
/**
* Process a loaded frame from either a file or message base
*
@@ -985,7 +1077,7 @@ function Page(debug) {
//if (ext === 'tex')
// var page = rawtoattrs(base64_decode(contents[index]).replace("\x0a\x0d\x0a\x0d","\x0a\x0d"),this.width,this.__window__.body.y,this.__window__.body.x);
//else if (ext === 'vtx')
var page = rawtoattrs(base64_decode(contents[index]),this.width,this.__window__.body.y,this.__window__.body.x);
var page = rawtoattrs(base64_decode(contents[index]),this.width,this.__window__.body.y,this.__window__.body.x);
this.__window__.body.__properties__.content = page.content;
this.dynamic_fields = page.dynamic_fields;
@@ -1092,80 +1184,6 @@ function Page(debug) {
return true;
}
this.load = function(page) {
var headers;
var mb = new MsgBase(FRAMES_MSG_BASE);
try {
if (mb.open()) {
headers = mb.get_all_msg_headers(false,false) || [];
} else {
log(LOG_ERROR,'! ['+FRAMES_MSG_BASE+'] cannot be opened ['+mb.error+']');
return false;
}
// @todo It appears if the message base doesnt exist, we dont error?
} catch (e) {
log(LOG_ERROR,'! ['+FRAMES_MSG_BASE+'] cannot be opened ['+e.message+']');
return false;
}
var msg;
// Find existing message with the page number and delete it if defined
for(var x in headers) {
if ((headers[x].tags === page.toString()) && (!(headers[x].attr&MSG_DELETE)) && (headers[x].from === SESSION_EXT)) {
msg = headers[x];
break;
}
}
if (msg === undefined) {
log(LOG_DEBUG,'|- Frame not found: ['+page.toString()+'] in ['+FRAMES_MSG_BASE+']');
return false;
} else {
log(LOG_DEBUG,'|- LOADING frame: ['+page.toString()+'] from ['+msg.number+']');
var contents = JSON.parse(mb.get_msg_body(false,msg.number,false,false,true,true));
return this.preload(contents,SESSION_EXT);
}
return false;
}
/**
* After page load routines
*/
this.loadcomplete = function() {
var po = pageOwner(this.name.frame);
switch (SESSION_EXT) {
case 'tex':
this.__window__.pagenum.__properties__.content = rawtoattrs(ESC+'[1;37m'+this.name.toString()).content;
this.provider = base64_decode(po.logoans);
break;
case 'vtx':
this.__window__.pagenum.__properties__.content = rawtoattrs(VIEWDATA_BIN_WHITE+this.name.toString()).content;
this.provider = base64_decode(po.logovtx);
break;
default:
throw new Error(SESSION_EXT+' hasnt been implemented');
}
// Dont show header on un-authed login frames
if (! user.number)
this.showHeader = false;
}
/**
* Save the frame to the message base
*/
@@ -1299,7 +1317,7 @@ function PageObject(frame,index) {
function init(frame,index) {
if (typeof frame === 'object') {
this.__properties__.frame = frame.frame;
this.__properties__.frame = frame.frame.toString();
this.index = frame.index;
} else {

View File

@@ -9,6 +9,7 @@ function Session() {
// Our page object
this.page = undefined;
this.previous = undefined;
/* Frame type settings */
this.settings = {};
@@ -18,15 +19,11 @@ function Session() {
*
* @param key
* @returns {null|string|*}
* @deprecated I think this has been superseded, by page.js, but I need to investigate
*/
this.fieldValue = function(key) {
for each (var k in this.frame_fields) {
log(LOG_DEBUG,' - k:'+JSON.stringify(k));
if (k.fname === key) {
return k.fvalue;
}
for each (var k in this.page.input_fields) {
if (k.name === key)
return k.value;
}
return null;
@@ -37,9 +34,20 @@ function Session() {
throw new Error('page must be a PageObject');
this.baselineSend('LOADING');
// Just in case our new page doesnt exist
this.previous = this.page;
this.page = new Page();
this.page.get(page);
var result = this.page.get(page);
// If our new page doesnt exist, reset our page back to the current
if (! result)
this.page = this.previous;
this.previous = undefined;
this.baselineClear();
return result;
}
/**
@@ -60,15 +68,15 @@ function Session() {
return false;
// @todo Search 1zzzzEE..., 1zzzz...
this.get(new PageObject(MAIL_TEMPLATE_FRAME),ext);
if (! this.get(new PageObject(MAIL_TEMPLATE_FRAME),ext)) {
this.page = new Page();
if (this.page.name.toString() === null) {
log(LOG_ERROR,'Echomail template missing :['+JSON.stringify(MAIL_TEMPLATE_FRAME)+'] ?');
msg_header = 'TO: '+msg.to.substr(0,72)+"\n\r";
msg_header += 'FROM: '+msg.from.substr(0,72)+"\n\r";
msg_header += 'DATE: '+msg.date.substr(0,72)+"\n\r";
msg_header += 'SUBJECT: '+msg.subject.substr(0,72)+"\n\r";
msg_header = 'TO: '+msg.to.substr(0,72)+"\r\n";
msg_header += 'FROM: '+msg.from.substr(0,72)+"\r\n";
msg_header += 'DATE: '+msg.date.substr(0,72)+"\r\n";
msg_header += 'SUBJECT: '+msg.subject.substr(0,72)+"\r\n";
} else {
// @todo change this to use atcode()
@@ -77,9 +85,9 @@ function Session() {
var length = code.split(':')[1];
switch(code.split(':')[0]) {
case 'DATE': return msg.date.substr(0,length);
case 'TO': return msg.to.substr(0,length);
case 'FROM': return msg.from.substr(0,length);
case 'SUBJECT': return msg.subject.substr(0,length);
case 'TO': return msg.to.substr(0,length);
}
}
);
@@ -161,6 +169,7 @@ function Session() {
// Render the page
this.render = function() {
this.gotoxy(0,0);
//console.clear(null,false);
write(so.page.display().join(''));
}
}

View File

@@ -1,12 +1,12 @@
const SESSION_ANSITEX = (1<<1);
const SESSION_EXT = 'tex';
var SESSION_EXT = 'tex';
const FRAME_WIDTH = 80;
const FRAME_HEIGHT = 22;
const FRAME_PROVIDER_LENGTH = 55;
const FRAME_PAGE_LENGTH = 13;
const FRAME_COST_LENGTH = 10;
const FRAME_ATTR_LENGTH = 0; // Space that an attribute takes
var FRAME_WIDTH = 80;
var FRAME_HEIGHT = 22;
var FRAME_PROVIDER_LENGTH = 55;
var FRAME_PAGE_LENGTH = 13;
var FRAME_COST_LENGTH = 10;
var FRAME_ATTR_LENGTH = 0; // Space that an attribute takes
/**
* This function converts ANSI text into an array of attributes
@@ -359,7 +359,7 @@ function rawtoattrs(contents,width,yoffset,xoffset,debug) {
/* parse dynamic value field */
// @todo remove the trailing ESC \ to end the field, just use a control code ie: ^E \x05 (Enquiry) or ^Z \x26 (Substitute)
var m = line.match(/^\x1bX(([a-zA-Z._:^;]+[0-9]?;-?[0-9^;]+)([;]?[^;]+)?)\x1b\\/);
var m = line.match(/^\x1bX(([a-zA-Z._:\-%^;]+[0-9]?;-?[0-9^;]+)([;]?[^;]+)?)\x1b\\/);
if (m !== null) {
// full string that matched
match = m.shift();
@@ -448,7 +448,7 @@ function SessionProtocol() {
this.settings.INACTIVE = '\1n\1h\1RINACTIVITY DISCONNECT';
this.settings.NOACTION = '\1n\1h\1RNO ACTION PERFORMED';
this.settings.BASESTAR = '\1N\1G\1H*';
this.settings.INVALID_CODE = '\1n\1h\1RINVAID CODE, PLEASE TRY AGAIN *00';
this.settings.INVALID_CODE = '\1n\1h\1RINVAID CODE, PLEASE TRY AGAIN **';
this.settings.TOKEN_EMAIL = '\1n\1h\1RTOKEN EMAILED TO YOU...';
this.settings.TOKEN_SENT = '\1n\1h\1RTOKEN SENT, PLEASE ENTER TOKEN';
this.settings.INVALID_EMAIL = '\1n\1h\1RINVAID EMAIL, PLEASE TRY AGAIN *00';

View File

@@ -1,12 +1,12 @@
const SESSION_VIEWDATA = (1<<2);
const SESSION_EXT = 'vtx';
var SESSION_EXT = 'vtx';
const FRAME_WIDTH = 40;
const FRAME_HEIGHT = 22;
const FRAME_PROVIDER_LENGTH = 23;
const FRAME_PAGE_LENGTH = 11;
const FRAME_COST_LENGTH = 6;
const FRAME_ATTR_LENGTH = 1; // Space that an attribute takes
var FRAME_WIDTH = 40;
var FRAME_HEIGHT = 22;
var FRAME_PROVIDER_LENGTH = 23;
var FRAME_PAGE_LENGTH = 11;
var FRAME_COST_LENGTH = 6;
var FRAME_ATTR_LENGTH = 1; // Space that an attribute takes
const VIEWDATA_LEFT = '\x08';
const VIEWDATA_RIGHT = '\x09';
@@ -452,7 +452,7 @@ function SessionProtocol() {
this.settings.INACTIVE = ascii(27)+'AINACTIVITY DISCONNECT';
this.settings.NOACTION = ascii(27)+'ANO ACTION PERFORMED';
this.settings.BASESTAR = ascii(27)+'B*';
this.settings.INVALID_CODE = ascii(27)+'AINVAID CODE, PLEASE TRY AGAIN *00';
this.settings.INVALID_CODE = ascii(27)+'AINVAID CODE, PLEASE TRY AGAIN **';
this.settings.TOKEN_EMAIL = ascii(27)+'ATOKEN EMAILED TO YOU...';
this.settings.TOKEN_SENT = ascii(27)+'ATOKEN SENT, PLEASE ENTER TOKEN';
this.settings.INVALID_EMAIL = ascii(27)+'AINVAID EMAIL, PLEASE TRY AGAIN *00';