Fix **, start of control methods and registration

This commit is contained in:
Deon George 2020-07-06 22:55:58 +10:00
parent 6139db24d3
commit 83f3788b68
2 changed files with 56 additions and 14 deletions

View File

@ -42,7 +42,7 @@ var ERR_ROUTE ='\1n\1h\1WMISTAKE? \1GTRY AGAIN OR TELL US ON *08';
var ERR_METHOD_NOT_EXIST ='\1n\1h\1WMISTAKE? \1GTRY AGAIN OR TELL US ON *08'; var ERR_METHOD_NOT_EXIST ='\1n\1h\1WMISTAKE? \1GTRY AGAIN OR TELL US ON *08';
var ACCESS_DENIED ='\1n\1h\1RACCESS DENIED. \1RMISTAKE? TRY AGAIN OR TELL US *08'; var ACCESS_DENIED ='\1n\1h\1RACCESS DENIED. \1RMISTAKE? TRY AGAIN OR TELL US *08';
var NO_HISTORY_FRAMES =['98b']; var NO_HISTORY_FRAMES =['980a','98b','981a'];
var SYSTEM_FRAMES =['AWgBUkEBR04BQlMBWUkBbgE3AWt0ZXgBbg==']; var SYSTEM_FRAMES =['AWgBUkEBR04BQlMBWUkBbgE3AWt0ZXgBbg=='];
@ -84,7 +84,7 @@ function Frame() {
log(LOG_DEBUG,'- FRAME User: ['+JSON.stringify(user)+']'); log(LOG_DEBUG,'- FRAME User: ['+JSON.stringify(user)+']');
// Dont show the page number on system login page // Dont show the page number on system login page
if (user.number || this.type != FRAME_TYPE_LOGIN) { if (user.number || (this.type != FRAME_TYPE_LOGIN && NO_HISTORY_FRAMES.indexOf(this.page) == -1)) {
header = '\1n'+owner+' '.repeat(FRAME_HEADER-console.strlen(owner))+'\1n '+ header = '\1n'+owner+' '.repeat(FRAME_HEADER-console.strlen(owner))+'\1n '+
'\1W\1H'+this.page+' '.repeat(FRAME_PAGENUM-this.page.length)+' '+ '\1W\1H'+this.page+' '.repeat(FRAME_PAGENUM-this.page.length)+' '+
'\1G\1H'+' '.repeat(FRAME_COST-this.cost.toString().length)+this.cost+FRAME_COSTUNIT+ '\1G\1H'+' '.repeat(FRAME_COST-this.cost.toString().length)+this.cost+FRAME_COSTUNIT+
@ -353,6 +353,7 @@ Frame.prototype.parse = function(text) {
ftype: fieldtype, ftype: fieldtype,
flength: fieldlen, flength: fieldlen,
fchar: fieldchar, fchar: fieldchar,
fname: field,
r: r, r: r,
c: c, c: c,
attribute: {i:i,f:f,b:b}, attribute: {i:i,f:f,b:b},

65
main.js
View File

@ -23,7 +23,7 @@ while(bbs.online) {
var mode = false; // Initial mode var mode = false; // Initial mode
// If the user is already on, our start page is 98b // If the user is already on, our start page is 98b
var next_page = { frame: 98,index: user.number ? 'b' : 'a' }; // Start Frame var next_page = user.number ? { frame: 98,index: 'b' } : { frame: 980,index: 'a' }; // Start Frame
var action = ACTION_GOTO; // Initial action var action = ACTION_GOTO; // Initial action
var inkey_timeout = 10000; // Timeout waiting for input @todo required? check if idle timeout occurs var inkey_timeout = 10000; // Timeout waiting for input @todo required? check if idle timeout occurs
@ -31,6 +31,9 @@ while(bbs.online) {
var fn = null; // Current Field Number for an Input Frame var fn = null; // Current Field Number for an Input Frame
var history = []; // Page history var history = []; // Page history
var cf = null; // Current Input Field
var cc = null; // Current Control Method
var control = []; // Methods that need to process input var control = []; // Methods that need to process input
ansi.send('ext_mode','clear','cursor'); ansi.send('ext_mode','clear','cursor');
@ -48,6 +51,14 @@ while(bbs.online) {
system.node_list[bbs.node_num-1].action=0xff; // to ensure our node status is updated correctly system.node_list[bbs.node_num-1].action=0xff; // to ensure our node status is updated correctly
if (mode != MODE_BL && control.length) {
cc = control[control.length-1];
log(LOG_DEBUG,'CONTROL START: ['+read+'] ('+cc+')');
read = cc.handle(read);
log(LOG_DEBUG,'CONTROL END: ['+read+']');
}
log(LOG_DEBUG,'MODE START: ['+read+']'); log(LOG_DEBUG,'MODE START: ['+read+']');
switch (mode) { switch (mode) {
case false: case false:
@ -69,8 +80,15 @@ while(bbs.online) {
case '7': case '7':
case '8': case '8':
case '9': case '9':
if (fo.key[read]) { log(LOG_DEBUG,'- false: Key ['+read+'] Route ['+fo.key[read]+']');
next_page = { frame: fo.key[read] }; if (fo.key[read] !== null) {
// If are requesting a home page
if (fo.key[read] === 0) {
next_page = { frame: user.number ? 1 : 98,index: 'a' };
} else {
next_page = { frame: fo.key[read] };
}
action = ACTION_GOTO; action = ACTION_GOTO;
log(LOG_DEBUG,'- false: Key ['+read+'] ['+pageStr(next_page)+']'); log(LOG_DEBUG,'- false: Key ['+read+'] ['+pageStr(next_page)+']');
@ -162,7 +180,19 @@ while(bbs.online) {
cmd = ''; cmd = '';
cursorOff(); cursorOff();
// @todo If we are editing a field... if (cf) {
// If there is a control for this field,
if (cc)
cc.prefield();
mode = MODE_FIELD;
console.gotoxy(cf.c,cf.r);
console.write(KEY_ESC+'['+cf.attribute.i+';'+cf.attribute.f+';'+cf.attribute.b+'m');
console.write(cf.fchar.repeat(cf.fvalue.length));
console.gotoxy(cf.c,cf.r);
ansi.send('ext_mode','set','cursor');
cf.fvalue = '';
}
} }
if (read == '#' || read == '\r') { if (read == '#' || read == '\r') {
@ -175,7 +205,7 @@ while(bbs.online) {
action = ACTION_BACKUP; action = ACTION_BACKUP;
} else if (cmd == '0') { } else if (cmd == '0') {
next_page = { frame: 1 }; // @todo specify home page in config next_page = { frame: user.number ? 1 : 98,index: 'a' }; // @todo specify home page in config
action = ACTION_GOTO; action = ACTION_GOTO;
// Edit frame // Edit frame
@ -208,14 +238,13 @@ while(bbs.online) {
case '\r': case '\r':
log(LOG_DEBUG,'- MODE_FIELD:FRAME_TYPE_LOGIN: ['+read+'] A'); log(LOG_DEBUG,'- MODE_FIELD:FRAME_TYPE_LOGIN: ['+read+'] A');
// If we are the main login screen, see if it is a new user // If we are the main login screen, see if it is a new user
//if ($this->fo->isCUG(0)) { // @todo Need to make sure this is only actioned on user login
if (fo.frame_fields[fn].ftype == 't' && fo.frame_fields[fn].fvalue == 'NEW') { if (cf.ftype == 't' && cf.fvalue.toUpperCase() == 'NEW') {
action = ACTION_GOTO; action = ACTION_GOTO;
next_page = { frame: 981,index: 'a' }; // @todo This should be in the INI. next_page = { frame: 981,index: 'a' }; // @todo This should be in the INI.
break; break;
} }
//}
break; break;
} }
@ -238,6 +267,10 @@ while(bbs.online) {
log(LOG_DEBUG,'fn:'+fn+', cf'+JSON.stringify(cf)); log(LOG_DEBUG,'fn:'+fn+', cf'+JSON.stringify(cf));
if (cf) { if (cf) {
// If there is a control for this field,
if (cc)
cc.prefield();
mode = MODE_FIELD; mode = MODE_FIELD;
console.gotoxy(cf.c,cf.r); console.gotoxy(cf.c,cf.r);
console.write(KEY_ESC+'['+cf.attribute.i+';'+cf.attribute.f+';'+cf.attribute.b+'m'); console.write(KEY_ESC+'['+cf.attribute.i+';'+cf.attribute.f+';'+cf.attribute.b+'m');
@ -654,6 +687,14 @@ while(bbs.online) {
mode = false; mode = false;
} }
// If this is the register page
// @todo this needs to be configurable
if (fo.page == '981a') {
log(LOG_DEBUG,'Adding REGISTER to control stack');
require('ansitex/load/register.js','CONTROL_REGISTER');
control.push(new register());
}
break; break;
// Standard Frame // Standard Frame