2022-12-09 06:19:33 +00:00
|
|
|
/**
|
|
|
|
* This is the core of ANSItex
|
|
|
|
*
|
|
|
|
* When called as login.js, it will handle the un-authenticated user.
|
|
|
|
* When called as main.js, it's assumed that the user has been authenticated.
|
|
|
|
* (In fact the functionality between the two is no different.)
|
|
|
|
*/
|
|
|
|
|
|
|
|
log(LOG_DEBUG,'* INIT: ANSItex');
|
2023-12-27 11:39:26 +00:00
|
|
|
var debug_mode = ''; // eg: 'user/password/10010010001';
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
// SBBS Key definitions
|
2020-05-27 11:56:12 +00:00
|
|
|
require('key_defs.js','KEY_ESC');
|
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
// ANSItex specific includes
|
2020-05-27 11:56:12 +00:00
|
|
|
load('ansitex/load/funcs.js');
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
// Our page handler
|
|
|
|
load('ansitex/load/page.js');
|
|
|
|
|
2022-04-10 11:09:59 +00:00
|
|
|
// @todo Returning from chat should refresh the frame
|
2022-12-09 06:19:33 +00:00
|
|
|
// @todo Suppress displays of telegrams (but trigger when they arrive)
|
|
|
|
/**
|
|
|
|
* SBBS terminal settings init
|
|
|
|
*/
|
|
|
|
// Dont always ask for a password.
|
|
|
|
bbs.node_settings &= ~(NM_LOGON_P);
|
|
|
|
// We'll take care of inactivity
|
|
|
|
bbs.node_settings &= NM_NO_INACT;
|
|
|
|
// No spinning cursors
|
|
|
|
bbs.node_settings &= NM_NOPAUSESPIN;
|
|
|
|
// Dont allow users to login with a number
|
|
|
|
bbs.node_settings &= NM_NO_NUM;
|
2023-12-25 22:17:19 +00:00
|
|
|
// @todo Suppress "Read your mail now" at login
|
|
|
|
// @todo Update message loading to process mystic color codes - this todo shouldnt be here, but placed here so I would see it and move it
|
|
|
|
// @todo Add "time ago" for messages, as an easier visual of how old it is.
|
2022-12-09 06:19:33 +00:00
|
|
|
|
|
|
|
// Suppress some SBBS message prompts, as we handle them
|
|
|
|
bbs.replace_text(390,''); // Unknown User
|
|
|
|
bbs.replace_text(391,''); // Invalid Login
|
|
|
|
bbs.replace_text(826,''); // LoggingOn
|
|
|
|
|
|
|
|
switch (client.socket.local_port) {
|
|
|
|
case 516:
|
2023-12-24 06:44:02 +00:00
|
|
|
require('ansitex/load/session/viewdata.js','SESSION_VIEWDATA');
|
2022-12-09 06:19:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
// Assume ANSItex
|
|
|
|
default:
|
2023-12-24 06:44:02 +00:00
|
|
|
require('ansitex/load/session/ansitex.js','SESSION_ANSITEX');
|
2022-12-09 06:19:33 +00:00
|
|
|
}
|
2022-04-10 11:09:59 +00:00
|
|
|
|
|
|
|
/**
|
2022-12-09 06:19:33 +00:00
|
|
|
* This is our main event loop - where we interact with the user.
|
2022-04-10 11:09:59 +00:00
|
|
|
* This loop takes care of first connect (unauthenticated users), or after authentication (main shell).
|
|
|
|
*/
|
2022-12-09 06:19:33 +00:00
|
|
|
while (bbs.online) {
|
2022-04-10 11:09:59 +00:00
|
|
|
/**
|
2022-12-09 06:19:33 +00:00
|
|
|
* Next action to take
|
|
|
|
* - NULL means no action
|
|
|
|
* - ACTION_* is the action (as defined in defs.js)
|
|
|
|
* @type {number|null}
|
2022-04-10 11:09:59 +00:00
|
|
|
*/
|
2022-12-09 06:19:33 +00:00
|
|
|
var action = ACTION_GOTO; // Initial action
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-04-10 11:09:59 +00:00
|
|
|
/**
|
2022-12-09 06:19:33 +00:00
|
|
|
* State of the current action
|
|
|
|
* - NULL means we are not doing anything
|
|
|
|
* - MODE_* is the mode (as defined in defs.js)
|
|
|
|
* @type {number|null}
|
2022-04-10 11:09:59 +00:00
|
|
|
*/
|
2022-12-09 06:19:33 +00:00
|
|
|
var mode = null; // Initial mode
|
2022-04-10 11:09:59 +00:00
|
|
|
|
|
|
|
/**
|
2022-12-09 06:19:33 +00:00
|
|
|
* The next page to display
|
|
|
|
* @type {PageObject}
|
2022-04-10 11:09:59 +00:00
|
|
|
*/
|
2023-12-24 06:44:02 +00:00
|
|
|
var next_page = new PageObject(user.name ? FRAME_HOME_AUTH : FRAME_HOME_CONNECT); // Start Frame
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-04-10 11:09:59 +00:00
|
|
|
/**
|
|
|
|
* Variable holding our current key timeout value
|
|
|
|
* @type {number}
|
|
|
|
*/
|
2023-12-24 06:44:02 +00:00
|
|
|
var inkey_timeout = INACTIVE_TIMEOUT;
|
2022-04-10 11:09:59 +00:00
|
|
|
|
|
|
|
/**
|
2022-12-09 06:19:33 +00:00
|
|
|
* Current Session Object that describe the terminal that the user has connected on
|
|
|
|
* - SessionViewdata - for ViewData sessions
|
|
|
|
* - SessionAnsitex - for ANSItex sessions
|
2023-12-25 22:17:19 +00:00
|
|
|
* @type {SessionProtocol}
|
2022-04-10 11:09:59 +00:00
|
|
|
*/
|
2023-12-25 22:17:19 +00:00
|
|
|
var so = new SessionProtocol();
|
2022-12-09 06:19:33 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* History of PageObjects that the user has seen this session
|
|
|
|
* @type {array}
|
|
|
|
*/
|
|
|
|
var history = [];
|
2022-04-10 11:09:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Current input field being edited when a frame has input fields
|
|
|
|
* - NULL means we are not inputting on a field
|
|
|
|
* @type {number|null}
|
|
|
|
*/
|
|
|
|
var fn = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Current Input Field.
|
|
|
|
* @type {object}
|
|
|
|
*/
|
|
|
|
var cf = null;
|
2020-07-06 12:55:58 +00:00
|
|
|
|
2022-04-10 11:09:59 +00:00
|
|
|
/**
|
|
|
|
* User has hit the inactivity timeout without any input
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
var timeout = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Time the user hit the inactivity timeout
|
|
|
|
* @type {number}
|
|
|
|
*/
|
2020-07-17 14:36:49 +00:00
|
|
|
var timer = time();
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
/**
|
|
|
|
* Current Control Method
|
|
|
|
* @type {null}
|
|
|
|
*/
|
|
|
|
var cc = null;
|
|
|
|
|
2022-04-10 11:09:59 +00:00
|
|
|
/**
|
|
|
|
* Which command control methods are in play and process input
|
|
|
|
* @type {array}
|
|
|
|
*/
|
|
|
|
var control = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The command being entered on the bottom line
|
|
|
|
* @type {string}
|
|
|
|
*/
|
|
|
|
var cmd = '';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* We are receiving an extended key sequence (like a function key)
|
|
|
|
* @type {string}
|
|
|
|
*/
|
|
|
|
var extendedkey = '';
|
|
|
|
|
|
|
|
/**
|
2022-12-09 06:19:33 +00:00
|
|
|
* The current input character
|
|
|
|
* @type {string}
|
2022-04-10 11:09:59 +00:00
|
|
|
*/
|
2022-12-09 06:19:33 +00:00
|
|
|
var read = '';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ESC key sequence received
|
|
|
|
*/
|
|
|
|
var esc = false;
|
2022-04-10 11:09:59 +00:00
|
|
|
|
2022-05-06 07:41:07 +00:00
|
|
|
while (action !== ACTION_TERMINATE && action !== ACTION_EXIT && bbs.online) {
|
2022-05-06 05:32:35 +00:00
|
|
|
try {
|
2022-12-09 06:19:33 +00:00
|
|
|
log(LOG_DEBUG,'- Start ACTION is ['+action+']');
|
2022-05-06 05:32:35 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
bbs.nodesync();
|
2022-05-06 05:32:35 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
read = '';
|
|
|
|
esc = false;
|
2022-12-07 10:49:52 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// If we have no action, read from the terminal
|
2022-12-09 06:19:33 +00:00
|
|
|
if (action === null) {
|
2022-05-06 05:32:35 +00:00
|
|
|
// If a special key sequence is coming...
|
2022-05-06 07:41:07 +00:00
|
|
|
while ((esc || ! read) && (action !== ACTION_TERMINATE)) {
|
2022-12-07 10:49:52 +00:00
|
|
|
log(LOG_DEBUG,'================================================');
|
|
|
|
log(LOG_DEBUG,'- READ START : control.length='+control.length);
|
|
|
|
log(LOG_DEBUG,'- READ START : inkey_timeout='+inkey_timeout);
|
2022-12-09 06:19:33 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Wait for a key from the user
|
|
|
|
read = console.inkey(K_NONE,inkey_timeout);
|
|
|
|
|
|
|
|
// We are entering a special keyboard char.
|
|
|
|
if (read === KEY_ESC) {
|
|
|
|
log(LOG_DEBUG,'- READ SPECIAL KEY COMING');
|
|
|
|
esc = true;
|
|
|
|
// We reduce our timeout, and assume the key is a function key. If the user pressed ESC we'll process that later
|
|
|
|
inkey_timeout = 200;
|
|
|
|
|
|
|
|
// If we got the ESC, but no [ then re-put the ESC in the read, we loose the current key
|
|
|
|
// @todo We loose the current pressed key
|
|
|
|
} else if (esc && ! extendedkey && read !== '[') {
|
|
|
|
log(LOG_DEBUG,'- READ SPECIAL KEY ABANDONED: ['+read+'] ('+read.charCodeAt(0)+')');
|
|
|
|
esc = false;
|
2023-12-24 06:44:02 +00:00
|
|
|
inkey_timeout = INACTIVE_TIMEOUT;
|
2022-05-06 05:32:35 +00:00
|
|
|
read = KEY_ESC;
|
|
|
|
|
|
|
|
// Recognise when the ESC sequence has ended (with a ~ or ;)
|
|
|
|
} else if (esc && extendedkey && (read === '~' || read === ';' || ! read)) {
|
|
|
|
switch (extendedkey) {
|
|
|
|
case '[15': read = false; break; // F5
|
|
|
|
case '[17': read = false; break; // F6
|
|
|
|
case '[18': read = false; break; // F7
|
|
|
|
case '[19': read = false; break; // F8
|
|
|
|
case '[20': read = false; break; // F9
|
|
|
|
case '[21': read = ascii(26); break; // F10
|
|
|
|
case '[23': read = false; break; // F11
|
|
|
|
case '[24': read = false; break; // F12
|
|
|
|
default:
|
|
|
|
log(LOG_DEBUG,'- READ UNKNOWN KEY: ['+extendedkey+']');
|
|
|
|
read = '';
|
|
|
|
}
|
2020-07-24 13:00:35 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
esc = false;
|
|
|
|
extendedkey = '';
|
2023-12-24 06:44:02 +00:00
|
|
|
inkey_timeout = INACTIVE_TIMEOUT;
|
2020-07-24 13:00:35 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Record the character as an extended key
|
|
|
|
} else if (esc) {
|
|
|
|
log(LOG_DEBUG,'- READ SPECIAL KEY ['+read+'] ('+read.charCodeAt(0)+')');
|
2022-12-09 06:19:33 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
extendedkey += read;
|
|
|
|
read = false;
|
|
|
|
}
|
2020-07-17 14:36:49 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Calculate idle timeouts
|
|
|
|
// If the user has exemption H we dont worry about timeout
|
|
|
|
if (! read && ! (user.security.exemptions&UFLAG_H) ) {
|
2022-12-07 10:49:52 +00:00
|
|
|
log(LOG_DEBUG,'- READ empty, evaluating timeouts...');
|
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Terminate the user if they have been inactive too long.
|
2023-12-24 06:44:02 +00:00
|
|
|
if (time() > timer+((user.number ? INACTIVE_LOGIN : INACTIVE_NOLOGIN)+INACTIVE_TIMEOUT)/1000) {
|
2022-12-09 06:19:33 +00:00
|
|
|
so.baselineSend('INACTIVE',false);
|
2022-05-06 07:41:07 +00:00
|
|
|
action = ACTION_TERMINATE;
|
2022-12-09 06:19:33 +00:00
|
|
|
mode = null;
|
|
|
|
|
2022-05-06 07:41:07 +00:00
|
|
|
log(LOG_INFO,'User INACTIVE - terminating...');
|
2020-07-17 14:36:49 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Idle warning - due to inactivity.
|
|
|
|
} else if (time() > timer+(user.number ? INACTIVE_LOGIN : INACTIVE_NOLOGIN)/1000) {
|
|
|
|
timeout = true;
|
2022-12-09 06:19:33 +00:00
|
|
|
so.baselineSend('INACTIVITY',false);
|
2020-07-09 13:12:17 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
if (cf) {
|
2022-12-09 06:19:33 +00:00
|
|
|
so.gotoxy(cf.x+cf.value.length,cf.y);
|
|
|
|
so.attr(cf.attribute);
|
2022-05-06 05:32:35 +00:00
|
|
|
}
|
2020-07-31 14:01:48 +00:00
|
|
|
}
|
2020-07-09 13:12:17 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
} else {
|
|
|
|
// If the user become active during inactivity, clear the baseline message
|
|
|
|
if (timeout) {
|
2022-12-09 06:19:33 +00:00
|
|
|
so.baselineClear(false);
|
2020-07-24 13:00:35 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
if (cf) {
|
2022-12-09 06:19:33 +00:00
|
|
|
so.gotoxy(cf.x+cf.value.length,cf.y);
|
|
|
|
so.attr(cf.attribute);
|
2022-05-06 05:32:35 +00:00
|
|
|
}
|
2020-07-31 14:01:48 +00:00
|
|
|
}
|
2020-07-24 13:00:35 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
timer = time();
|
|
|
|
timeout = false;
|
|
|
|
}
|
2020-07-09 13:12:17 +00:00
|
|
|
|
2022-12-07 10:49:52 +00:00
|
|
|
// If we are in a control, we need to break here so that the control takes the input
|
|
|
|
if (control.length)
|
|
|
|
break;
|
2020-07-24 13:00:35 +00:00
|
|
|
}
|
2020-07-09 13:12:17 +00:00
|
|
|
}
|
2022-12-09 06:19:33 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
log(LOG_DEBUG,'READ: ['+read+'] ('+read.charCodeAt(0)+')');
|
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
// to ensure our node status is updated correctly
|
|
|
|
system.node_list[bbs.node_num-1].action = 0xff;
|
2022-05-06 05:32:35 +00:00
|
|
|
|
|
|
|
// After reading from the terminal, see if we need to pass that input to a control module,
|
|
|
|
// except if input is on the bottom line
|
2022-12-09 06:19:33 +00:00
|
|
|
log(LOG_DEBUG,'------------------------------------------------');
|
2022-05-06 05:32:35 +00:00
|
|
|
log(LOG_DEBUG,'CONTROL: mode ['+mode+'] ('+control.length+')');
|
|
|
|
if ((mode !== MODE_BL) && control.length) {
|
|
|
|
log(LOG_DEBUG,'CONTROL DEBUG: ['+control.length+'] ('+JSON.stringify(control)+')');
|
|
|
|
cc = control[control.length-1];
|
|
|
|
log(LOG_DEBUG,'CONTROL IS: ['+typeof cc+']');
|
|
|
|
log(LOG_DEBUG,'CONTROL START: ['+read+'] ('+cc.getName+')');
|
|
|
|
// We pass the read to the control and see if it consumes it.
|
|
|
|
read = cc.handle(read);
|
|
|
|
log(LOG_DEBUG,'CONTROL RETURN: ['+read+'] ('+cc.isComplete+')');
|
|
|
|
|
|
|
|
if (cc.isComplete) {
|
|
|
|
control.pop();
|
|
|
|
cc = null;
|
|
|
|
log(LOG_DEBUG,'CONTROL COMPLETE: ['+read+'] ('+control.length+')');
|
2022-12-07 10:49:52 +00:00
|
|
|
|
|
|
|
// If there are no more control items
|
2022-12-09 06:19:33 +00:00
|
|
|
if (control.length === 0)
|
2023-12-24 06:44:02 +00:00
|
|
|
inkey_timeout = INACTIVE_TIMEOUT;
|
2022-05-06 05:32:35 +00:00
|
|
|
}
|
2020-07-09 13:12:17 +00:00
|
|
|
}
|
2020-07-06 12:55:58 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
log(LOG_DEBUG,'CONTROL END: ['+read+']');
|
|
|
|
log(LOG_DEBUG,'------------------------------------------------');
|
|
|
|
|
|
|
|
log(LOG_DEBUG,'------------------------------------------------');
|
2022-12-07 10:49:52 +00:00
|
|
|
log(LOG_DEBUG,'MODE START: ['+read.charCodeAt(0)+'] ('+mode+')');
|
2022-05-06 05:32:35 +00:00
|
|
|
switch (mode) {
|
|
|
|
// Normal navigation
|
2022-12-09 06:19:33 +00:00
|
|
|
case null:
|
|
|
|
log(LOG_DEBUG,'- MODE NULL: ['+read+']');
|
2020-07-06 12:55:58 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
switch (read) {
|
|
|
|
case '*': action = ACTION_STAR;
|
|
|
|
break;
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Frame Routing
|
|
|
|
case '0':
|
|
|
|
case '1':
|
|
|
|
case '2':
|
|
|
|
case '3':
|
|
|
|
case '4':
|
|
|
|
case '5':
|
|
|
|
case '6':
|
|
|
|
case '7':
|
|
|
|
case '8':
|
|
|
|
case '9':
|
2022-12-09 06:19:33 +00:00
|
|
|
log(LOG_DEBUG,'- MODE null: Key ['+read+'] Route ['+so.page.key[read]+']');
|
|
|
|
|
|
|
|
if (so.page.key[read] !== null) {
|
|
|
|
// If a page routes to 0, requesting the home page
|
|
|
|
if (so.page.key[read] === 0) {
|
2023-12-24 06:44:02 +00:00
|
|
|
next_page = new PageObject(user.number ? FRAME_HOME : FRAME_LOGIN);
|
2022-12-07 10:49:52 +00:00
|
|
|
action = ACTION_GOTO;
|
2023-12-24 06:44:02 +00:00
|
|
|
log(LOG_DEBUG,'- NULL: Key ['+read+'] ['+next_page.toString()+']');
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
} else if (so.page.key[read].toString().match(/^[0-9]+/)) {
|
|
|
|
next_page = new PageObject(so.page.key[read],'a');
|
2022-12-07 10:49:52 +00:00
|
|
|
action = ACTION_GOTO;
|
2023-12-24 06:44:02 +00:00
|
|
|
log(LOG_DEBUG,'- NULL: Key ['+read+'] ['+next_page.toString()+']');
|
2022-05-06 05:32:35 +00:00
|
|
|
|
2022-12-07 10:49:52 +00:00
|
|
|
} else {
|
2022-12-09 06:19:33 +00:00
|
|
|
so.baselineSend('ERR_ROUTE',false);
|
2022-12-07 10:49:52 +00:00
|
|
|
}
|
2020-07-06 12:55:58 +00:00
|
|
|
|
|
|
|
} else {
|
2022-12-09 06:19:33 +00:00
|
|
|
so.baselineSend('ERR_ROUTE',false);
|
2020-07-06 12:55:58 +00:00
|
|
|
}
|
2022-04-10 11:09:59 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
case '_':
|
|
|
|
// Viewdata terminal's # is an _ character
|
2022-12-09 06:19:33 +00:00
|
|
|
if (SESSION_EXT === 'tex') break;
|
2022-05-06 05:32:35 +00:00
|
|
|
/* fallthrough */
|
|
|
|
case '#':
|
2023-12-24 06:44:02 +00:00
|
|
|
log(LOG_DEBUG,'- NULL: Key ['+read+'] ['+so.page.name.toString()+']');
|
2022-12-09 06:19:33 +00:00
|
|
|
next_page = so.page.pagenext;
|
|
|
|
|
|
|
|
if (next_page) {
|
2022-05-06 05:32:35 +00:00
|
|
|
action = ACTION_GOTO;
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
} else {
|
2022-12-09 06:19:33 +00:00
|
|
|
so.baselineSend('ERR_ROUTE',false);
|
2022-05-06 05:32:35 +00:00
|
|
|
}
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2020-08-12 13:23:26 +00:00
|
|
|
break;
|
2020-07-21 11:56:57 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Command input on bottom line
|
|
|
|
case MODE_BL:
|
|
|
|
log(LOG_DEBUG,'- MODE_BL: ['+read+']');
|
|
|
|
if (read.match(/[0-9]/)) {
|
|
|
|
cmd += read;
|
|
|
|
console.write(read);
|
2020-07-21 11:56:57 +00:00
|
|
|
}
|
|
|
|
|
2022-12-07 10:49:52 +00:00
|
|
|
log(LOG_DEBUG,'- MODE_BL: cmd ['+cmd+']');
|
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// If the user pressed backspace
|
|
|
|
// @todo We should get the user's configuration of backspace
|
|
|
|
if ((read === CTRL_H || read === KEY_DEL) && cmd.length) {
|
|
|
|
console.backspace();
|
|
|
|
cmd = cmd.substring(0,cmd.length-1);
|
|
|
|
}
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
if (cmd === '00') {
|
|
|
|
action = ACTION_RELOAD;
|
2020-07-21 11:56:57 +00:00
|
|
|
cmd = '';
|
2022-12-09 06:19:33 +00:00
|
|
|
so.cursorOff();
|
|
|
|
so.baselineClear();
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
2020-07-21 11:56:57 +00:00
|
|
|
}
|
|
|
|
|
2022-12-07 10:49:52 +00:00
|
|
|
// Special code to launch SQRL
|
2022-05-06 05:32:35 +00:00
|
|
|
if (cmd === '01' && ! user.number) {
|
|
|
|
action = ACTION_GOTO;
|
2022-12-07 10:49:52 +00:00
|
|
|
cmd = '';
|
2022-12-09 06:19:33 +00:00
|
|
|
so.cursorOff();
|
|
|
|
so.baselineClear();
|
2023-12-24 06:44:02 +00:00
|
|
|
next_page = new PageObject(FRAME_SQRL);
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Invalid system pages.
|
2022-12-07 10:49:52 +00:00
|
|
|
if (cmd.match(/^0[12367]/)) {
|
|
|
|
log(LOG_DEBUG,'- MODE_BL: Invalid System Page ['+cmd+']');
|
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
action = mode = null;
|
2020-07-21 11:56:57 +00:00
|
|
|
cmd = '';
|
2022-12-09 06:19:33 +00:00
|
|
|
so.cursorOff();
|
|
|
|
so.baselineSend('ERR_ROUTE',false);
|
2020-07-21 11:56:57 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Edit specific frame
|
|
|
|
if (cmd.match(/^04/) && read.match(/[a-z]/)) {
|
2022-12-07 10:49:52 +00:00
|
|
|
log(LOG_DEBUG,'- MODE_BL: Edit ['+cmd+']');
|
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// If we are not a user
|
|
|
|
if (! user.number) {
|
2022-12-09 06:19:33 +00:00
|
|
|
action = null;
|
|
|
|
so.baselineSend('ERR_ROUTE',false);
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
} else {
|
|
|
|
action = ACTION_EDIT;
|
2022-12-09 06:19:33 +00:00
|
|
|
so.baselineClear();
|
|
|
|
next_page = new PageObject(parseInt(cmd.substr(2,cmd.length-1)),read);
|
2020-07-21 11:56:57 +00:00
|
|
|
|
2023-12-24 06:44:02 +00:00
|
|
|
log(LOG_DEBUG,'- MODE_BL: EDIT ['+JSON.stringify(next_page.toString())+']');
|
2022-05-06 05:32:35 +00:00
|
|
|
}
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
mode = null;
|
2022-05-06 05:32:35 +00:00
|
|
|
cmd = '';
|
2022-12-09 06:19:33 +00:00
|
|
|
so.cursorOff();
|
2022-05-06 05:32:35 +00:00
|
|
|
|
|
|
|
break;
|
2020-07-06 12:55:58 +00:00
|
|
|
}
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Bookmark frame
|
|
|
|
if (cmd === '05') {
|
2022-12-07 10:49:52 +00:00
|
|
|
log(LOG_DEBUG,'- MODE_BL: Bookmark ['+cmd+']');
|
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
if (! user.number) {
|
2022-12-09 06:19:33 +00:00
|
|
|
so.baselineSend('ERR_ROUTE',false);
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
} else {
|
|
|
|
// @todo
|
2022-12-09 06:19:33 +00:00
|
|
|
so.baselineSend('ERR_NOT_IMPLEMENTED',false);
|
2022-05-06 05:32:35 +00:00
|
|
|
}
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
action = mode = null;
|
|
|
|
cmd = '';
|
|
|
|
so.cursorOff();
|
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Report Problem
|
|
|
|
if (cmd === '08') {
|
2023-12-24 06:44:02 +00:00
|
|
|
log(LOG_DEBUG,'- MODE_BL: Report Problem ['+cmd+'] ('+so.page.name.toString()+')');
|
2022-12-07 10:49:52 +00:00
|
|
|
|
2020-07-21 11:56:57 +00:00
|
|
|
if (! user.number) {
|
2022-12-09 06:19:33 +00:00
|
|
|
so.baselineSend('ERR_ROUTE',false);
|
2020-07-13 13:08:37 +00:00
|
|
|
|
2020-07-21 11:56:57 +00:00
|
|
|
} else {
|
2022-05-06 05:32:35 +00:00
|
|
|
// @todo
|
2022-12-09 06:19:33 +00:00
|
|
|
so.baselineSend('ERR_NOT_IMPLEMENTED',false);
|
2020-07-21 11:56:57 +00:00
|
|
|
}
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
action = mode = null;
|
|
|
|
cmd = '';
|
|
|
|
so.cursorOff();
|
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
2019-10-03 04:08:48 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Reload frame
|
|
|
|
if (cmd === '09') {
|
2023-12-24 06:44:02 +00:00
|
|
|
log(LOG_DEBUG,'- MODE_BL: Reload frame ['+cmd+'] ('+so.page.name.toString()+')');
|
2022-12-07 10:49:52 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
action = ACTION_GOTO;
|
|
|
|
cmd = '';
|
2022-12-09 06:19:33 +00:00
|
|
|
so.cursorOff();
|
|
|
|
next_page = so.page.name;
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Another star aborts the command
|
|
|
|
if (read === '*') {
|
2022-12-07 10:49:52 +00:00
|
|
|
log(LOG_DEBUG,'- MODE_BL: Abort ['+cmd+'])');
|
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
action = mode = null;
|
2022-05-06 05:32:35 +00:00
|
|
|
cmd = '';
|
2022-12-09 06:19:33 +00:00
|
|
|
so.cursorOff();
|
|
|
|
so.baselineClear(false);
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
if (cf) {
|
|
|
|
// If there is a control for this field,
|
|
|
|
if (cc)
|
|
|
|
cc.prefield();
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
mode = MODE_FIELD;
|
2022-12-09 06:19:33 +00:00
|
|
|
so.gotoxy(cf.x,cf.y);
|
|
|
|
so.attr(cf.attribute);
|
|
|
|
console.write(cf.char.repeat(cf.value.length));
|
|
|
|
so.cursorOn(cf.x,cf.y);
|
|
|
|
cf.value = '';
|
2022-05-06 05:32:35 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
if (((SESSION_EXT === 'vtx') && read === '_') || ((SESSION_EXT === 'tex') && read === '#') || ((read === "\r") && (cmd.length > 0))) {
|
2022-12-07 10:49:52 +00:00
|
|
|
log(LOG_DEBUG,'- MODE_BL: Return Received ['+cmd+'])');
|
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Nothing typed between * and #
|
|
|
|
// *# means go back
|
|
|
|
if (cmd === '') {
|
2022-12-09 06:19:33 +00:00
|
|
|
so.baselineClear(false);
|
2022-05-06 05:32:35 +00:00
|
|
|
action = ACTION_BACKUP;
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
} else if (cmd === '0') {
|
2023-12-24 06:44:02 +00:00
|
|
|
next_page = new PageObject(user.number ? FRAME_HOME : FRAME_LOGIN);
|
2022-05-06 05:32:35 +00:00
|
|
|
action = ACTION_GOTO;
|
2020-07-06 12:55:58 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Edit frame
|
|
|
|
} else if (cmd === '04') {
|
|
|
|
// If we are not a user
|
|
|
|
if (! user.number) {
|
2022-12-09 06:19:33 +00:00
|
|
|
so.baselineSend('ERR_ROUTE',false);
|
|
|
|
action = null;
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
} else {
|
|
|
|
action = ACTION_EDIT;
|
|
|
|
}
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
} else {
|
2022-12-09 06:19:33 +00:00
|
|
|
next_page = new PageObject(cmd,'a');
|
2022-05-06 05:32:35 +00:00
|
|
|
action = ACTION_GOTO;
|
|
|
|
}
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Clear the command we are finished processing...
|
|
|
|
cmd = '';
|
2022-12-09 06:19:33 +00:00
|
|
|
mode = null;
|
|
|
|
so.cursorOff();
|
2022-05-06 05:32:35 +00:00
|
|
|
}
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-12-07 10:49:52 +00:00
|
|
|
log(LOG_DEBUG,'- MODE_BL: END');
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Key presses during field input.
|
|
|
|
case MODE_FIELD:
|
2022-12-09 06:19:33 +00:00
|
|
|
action = null;
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
switch (so.page.type) {
|
2022-05-06 05:32:35 +00:00
|
|
|
// Login frame.
|
|
|
|
case FRAME_TYPE_LOGIN:
|
|
|
|
switch (read) {
|
|
|
|
case '_':
|
2022-12-09 06:19:33 +00:00
|
|
|
if (SESSION_EXT === 'tex') break;
|
2022-05-06 05:32:35 +00:00
|
|
|
/* fallthrough */
|
|
|
|
case '#':
|
|
|
|
case "\r":
|
|
|
|
log(LOG_DEBUG,'- MODE_FIELD:FRAME_TYPE_LOGIN: ['+read+'] A');
|
|
|
|
// If we are the main login screen, see if it is a new user
|
2022-12-09 06:19:33 +00:00
|
|
|
if (cf.type === 't' && cf.value.toUpperCase() === 'NEW') {
|
2022-05-06 05:32:35 +00:00
|
|
|
action = ACTION_GOTO;
|
2023-12-24 06:44:02 +00:00
|
|
|
next_page = new PageObject(FRAME_REGISTER);
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* fallthrough */
|
|
|
|
// Response frame.
|
|
|
|
case FRAME_TYPE_RESPONSE:
|
|
|
|
// If we came from FRAME_TYPE_LOGIN and the user typed NEW to register
|
|
|
|
if (action === ACTION_GOTO)
|
2020-07-09 13:12:17 +00:00
|
|
|
break;
|
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
switch (read) {
|
|
|
|
// End of field entry.
|
|
|
|
case '_':
|
2022-12-09 06:19:33 +00:00
|
|
|
if (SESSION_EXT === 'tex') break;
|
2022-05-06 05:32:35 +00:00
|
|
|
/* fallthrough */
|
|
|
|
case '#':
|
|
|
|
case "\r":
|
|
|
|
log(LOG_DEBUG,'- MODE_FIELD:FRAME_TYPE_RESPONSE: # ['+read+']');
|
|
|
|
// Next Field
|
|
|
|
fn++;
|
2020-07-09 13:12:17 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
cf = so.page.input_fields[fn];
|
2022-05-06 05:32:35 +00:00
|
|
|
log(LOG_DEBUG,'fn:'+fn+', cf'+JSON.stringify(cf));
|
2020-07-09 13:12:17 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
if (cf) {
|
|
|
|
// If there is a control for this field,
|
|
|
|
if (cc)
|
|
|
|
cc.prefield();
|
2020-07-09 13:12:17 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
mode = MODE_FIELD;
|
2022-12-09 06:19:33 +00:00
|
|
|
so.gotoxy(cf.x,cf.y);
|
|
|
|
so.attr(cf.attribute);
|
2020-07-09 13:12:17 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Finished all editable fields.
|
|
|
|
} else {
|
|
|
|
action = ACTION_SUBMITRF;
|
|
|
|
}
|
2020-07-09 13:12:17 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
2020-07-09 13:12:17 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
case '*':
|
|
|
|
log(LOG_DEBUG,'- MODE_FIELD:FRAME_TYPE_RESPONSE: ['+read+']');
|
2020-07-09 13:12:17 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
action = ACTION_STAR;
|
2020-07-09 13:12:17 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
2020-07-09 13:12:17 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Delete Key pressed
|
|
|
|
case CTRL_H:
|
|
|
|
case KEY_DEL:
|
2022-12-09 06:19:33 +00:00
|
|
|
log(LOG_DEBUG,'- MODE_FIELD:FRAME_TYPE_RESPONSE: DEL ['+read+']'+' cf:'+(cf ? cf.value.length : '{}')+' ct:'+cf.type);
|
2020-07-09 13:12:17 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
if (cf.value.length > 0) {
|
|
|
|
cf.value = cf.value.substring(0,cf.value.length-1);
|
|
|
|
so.fieldbs(cf.char);
|
2022-05-06 05:32:35 +00:00
|
|
|
}
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
case KEY_ESC:
|
|
|
|
log(LOG_DEBUG,'- MODE_FIELD:FRAME_TYPE_RESPONSE: ESC ['+read+']');
|
|
|
|
break;
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
case KEY_DOWN:
|
|
|
|
log(LOG_DEBUG,'- MODE_FIELD:FRAME_TYPE_RESPONSE: DOWN ['+read+']');
|
|
|
|
// Next Field
|
|
|
|
fn++;
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
cf = so.page.input_fields[fn];
|
2022-05-06 05:32:35 +00:00
|
|
|
log(LOG_DEBUG,'fn:'+fn+', cf'+JSON.stringify(cf));
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
if (! cf) {
|
|
|
|
fn = 0;
|
2022-12-09 06:19:33 +00:00
|
|
|
cf = so.page.input_fields[fn];
|
2022-05-06 05:32:35 +00:00
|
|
|
}
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// If there is a control for this field,
|
|
|
|
if (cc)
|
|
|
|
cc.prefield();
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
mode = MODE_FIELD;
|
2022-12-09 06:19:33 +00:00
|
|
|
so.gotoxy(cf.x+cf.value.length,cf.y);
|
|
|
|
so.attr(cf.attribute);
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
case KEY_UP:
|
|
|
|
log(LOG_DEBUG,'- MODE_FIELD:FRAME_TYPE_RESPONSE: UP ['+read+']');
|
|
|
|
// Next Field
|
|
|
|
fn--;
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
if (fn < 0) {
|
2022-12-09 06:19:33 +00:00
|
|
|
fn = so.page.input_fields.length-1;
|
2022-05-06 05:32:35 +00:00
|
|
|
}
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
cf = so.page.input_fields[fn];
|
2022-05-06 05:32:35 +00:00
|
|
|
log(LOG_DEBUG,'fn:'+fn+', cf'+JSON.stringify(cf));
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// If there is a control for this field,
|
|
|
|
if (cc)
|
|
|
|
cc.prefield();
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
mode = MODE_FIELD;
|
2022-12-09 06:19:33 +00:00
|
|
|
so.gotoxy(cf.x+cf.value.length,cf.y);
|
|
|
|
so.attr(cf.attribute);
|
2020-05-27 11:56:12 +00:00
|
|
|
|
|
|
|
break;
|
2020-07-09 13:12:17 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Record Data Entry
|
2020-07-09 13:12:17 +00:00
|
|
|
default:
|
2022-12-09 06:19:33 +00:00
|
|
|
log(LOG_DEBUG,'- MODE_FIELD:FRAME_TYPE_RESPONSE: ['+read+'] E:'+read.charCodeAt(0)+' cf:'+(cf ? cf.length : '{}'));
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
if (read.charCodeAt(0) > 31 && cf.value.length < cf.length) {
|
|
|
|
cf.value += read;
|
|
|
|
console.write((cf.type === 't') ? read : 'x');
|
2022-05-06 05:32:35 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Other Frame Types - Shouldnt get here.
|
|
|
|
default:
|
|
|
|
log(LOG_DEBUG,'- SHOULDNT GET HERE: ['+read+']');
|
|
|
|
action = ACTION_TERMINATE;
|
|
|
|
}
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Form submission: 1 to send, 2 not to send.
|
|
|
|
case MODE_SUBMITRF:
|
2022-12-09 06:19:33 +00:00
|
|
|
so.cursorOff();
|
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
switch (read) {
|
|
|
|
case '1':
|
2022-12-09 06:19:33 +00:00
|
|
|
so.baselineSend('PROCESSING');
|
|
|
|
|
|
|
|
log(LOG_DEBUG,'- MODE_SUBMITRF: Key ['+read+'] ['+pageStr(so)+']');
|
|
|
|
log(LOG_DEBUG,' - Frame fields: '+JSON.stringify(so.page.input_fields));
|
|
|
|
log(LOG_DEBUG,' - Key 1 is:'+JSON.stringify(so.page.key[1]));
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// If we are in a control method, complete it
|
2022-12-07 10:49:52 +00:00
|
|
|
if (control.length) {
|
2022-05-06 05:32:35 +00:00
|
|
|
log(LOG_DEBUG,'Last control method is:'+JSON.stringify(control[control.length-1]));
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
control[control.length-1].process();
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
} else if (so.page.key[1] === '*' || so.page.key[1].match(/[0-9]/)) {
|
|
|
|
so.baselineSend('NOACTION',false);
|
2022-05-06 05:32:35 +00:00
|
|
|
mode = MODE_RFSENT;
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
} else {
|
2022-12-09 06:19:33 +00:00
|
|
|
log(LOG_DEBUG,' - Key 1 is a METHOD check it exists: '+JSON.stringify(so.page.key[1]));
|
2022-05-06 05:32:35 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
switch(so.page.key[1]) {
|
2022-05-06 05:32:35 +00:00
|
|
|
// User is logging in to system or CUG
|
|
|
|
case 'login':
|
2022-12-09 06:19:33 +00:00
|
|
|
log(LOG_DEBUG,' - User: '+so.page.input_fields[0].value+'/'+so.page.input_fields[1].value);
|
2022-05-06 05:32:35 +00:00
|
|
|
|
2023-12-27 11:24:20 +00:00
|
|
|
// In debug mode, we'll authenticate for the user
|
|
|
|
if (debug_mode) {
|
|
|
|
log(LOG_DEBUG,' - Debug mode user'+debug_mode.split('/')[0]);
|
|
|
|
log(LOG_DEBUG,' - Debug mode pass'+debug_mode.split('/')[1]);
|
|
|
|
if (bbs.login(debug_mode.split('/')[0],'',debug_mode.split('/')[1])) {
|
|
|
|
log(LOG_DEBUG,' - User: '+JSON.stringify(user.number));
|
|
|
|
bbs.logon();
|
|
|
|
log(LOG_DEBUG,' - SEND TO EXIT:');
|
|
|
|
|
|
|
|
action = ACTION_EXIT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// If login is successful, we'll exit here
|
2022-12-09 06:19:33 +00:00
|
|
|
if (bbs.login(so.page.input_fields[0].value,'',so.page.input_fields[1].value)) {
|
2022-05-09 11:27:38 +00:00
|
|
|
log(LOG_DEBUG,' - User: '+JSON.stringify(user.number));
|
2022-05-06 05:32:35 +00:00
|
|
|
bbs.logon();
|
|
|
|
log(LOG_DEBUG,' - SEND TO EXIT:');
|
|
|
|
|
|
|
|
action = ACTION_EXIT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
log(LOG_DEBUG,' ! Login failed for User:'+JSON.stringify(so.page.input_fields[0].value));
|
2022-05-06 05:32:35 +00:00
|
|
|
action = ACTION_GOTO;
|
2023-12-24 06:44:02 +00:00
|
|
|
next_page = new PageObject(FRAME_LOGIN_FAILED);
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
default:
|
|
|
|
// Its assumed that you get here after completing a form and you have pressed 1 to submit that form.
|
2022-12-09 06:19:33 +00:00
|
|
|
log(LOG_DEBUG,' ! EVAL method:'+JSON.stringify(so.page.key));
|
2022-05-09 12:24:28 +00:00
|
|
|
if (cc.process()) {
|
|
|
|
control.pop();
|
|
|
|
log(LOG_DEBUG,' = Process Completed.');
|
|
|
|
}
|
2022-05-06 05:32:35 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
|
|
|
|
} elseif ($ao = FrameClass\Action::factory($this->fo->route(1),$this,$user,$action,$mode)) {
|
|
|
|
$ao->handle();
|
|
|
|
$mode = $ao->mode;
|
|
|
|
$action = $ao->action;
|
|
|
|
|
|
|
|
if ($ao->page)
|
|
|
|
$next_page = $ao->page;
|
2020-05-27 11:56:12 +00:00
|
|
|
|
|
|
|
} else {
|
2022-12-09 06:19:33 +00:00
|
|
|
so.baselineSend('ERR_METHOD_NOT_EXIST',false);
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
mode = MODE_RFSENT;
|
|
|
|
}
|
2022-12-09 06:19:33 +00:00
|
|
|
*/
|
2022-05-06 05:32:35 +00:00
|
|
|
}
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
case '2':
|
2022-12-09 06:19:33 +00:00
|
|
|
so.baselineClear();
|
|
|
|
|
|
|
|
log(LOG_DEBUG,'- MODE_SUBMITRF: Key ['+read+'] ['+pageStr(so)+']');
|
2022-05-06 05:32:35 +00:00
|
|
|
// @todo Check if HASH is a valid next destination
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
if (so.page.type === 'l') {
|
2022-05-06 05:32:35 +00:00
|
|
|
action = ACTION_RELOAD;
|
2022-12-09 06:19:33 +00:00
|
|
|
mode = null;
|
2020-07-09 13:12:17 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
} else {
|
2022-12-09 06:19:33 +00:00
|
|
|
so.baselineSend('MSG_NOTSENT',false);
|
2022-05-06 05:32:35 +00:00
|
|
|
mode = MODE_RFNOTSENT;
|
|
|
|
}
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
/*
|
|
|
|
// If a Control method was rejected, we can clear it
|
|
|
|
if ($control AND $method->count()) {
|
|
|
|
$save = $method->pop();
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
if ($method->count()) {
|
|
|
|
$control = $method->last()->state['control'];
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
} else {
|
|
|
|
$mode = $save->state['mode'];
|
|
|
|
$action = $save->state['action'];
|
|
|
|
$control = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
case '*':
|
|
|
|
action = ACTION_STAR;
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
2020-05-27 11:56:12 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Destroy the object.
|
|
|
|
cc = null;
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Response form after Sent processing
|
|
|
|
case MODE_RFSENT:
|
2022-12-09 06:19:33 +00:00
|
|
|
so.cursorOff();
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
switch (read) {
|
|
|
|
case '*':
|
|
|
|
action = ACTION_STAR;
|
|
|
|
break;
|
|
|
|
}
|
2020-05-27 11:56:12 +00:00
|
|
|
|
|
|
|
/*
|
2022-12-09 06:19:33 +00:00
|
|
|
// @todo to implement
|
2022-05-06 05:32:35 +00:00
|
|
|
if ($read === HASH) {
|
|
|
|
if ($x = $this->fo->route(2) AND $x !== '*' AND is_numeric($x)) {
|
|
|
|
$next_page = ['frame'=>$x];
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
} elseif (FrameModel::where('frame',$this->fo->frame())->where('index',$this->fo->index_next())->exists()) {
|
|
|
|
$next_page = ['frame'=>$this->fo->frame(),'index'=>$this->fo->index_next()];
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
} elseif ($x = $this->fo->route(0) AND $x !== '*' AND is_numeric($x)) {
|
|
|
|
$next_page = ['frame'=>$x];
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// No further routes defined, go home.
|
|
|
|
} else {
|
|
|
|
$next_page = ['frame'=>0];
|
|
|
|
}
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
$action = ACTION_GOTO;
|
|
|
|
}
|
|
|
|
*/
|
2022-12-09 06:19:33 +00:00
|
|
|
|
2020-05-27 11:56:12 +00:00
|
|
|
break;
|
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Response form after NOT sending
|
|
|
|
case MODE_RFNOTSENT:
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Response form ERROR
|
|
|
|
case MODE_RFERROR:
|
2022-12-09 06:19:33 +00:00
|
|
|
so.cursorOff();
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
if (((SESSION_EXT === 'vtx') && read === '_') || ((SESSION_EXT === 'tex') && read === '#')) {
|
2022-05-06 05:32:35 +00:00
|
|
|
/*
|
2022-12-09 06:19:33 +00:00
|
|
|
// @todo to implement
|
2022-05-06 05:32:35 +00:00
|
|
|
if ($x = $this->fo->route(2) AND $x !== '*' AND is_numeric($x)) {
|
|
|
|
$next_page = ['frame'=>$x];
|
|
|
|
|
|
|
|
} elseif (FrameModel::where('frame',$this->fo->frame())->where('index',$this->fo->index_next())->exists()) {
|
|
|
|
$next_page = ['frame'=>$this->fo->frame(),'index'=>$this->fo->index_next()];
|
|
|
|
|
|
|
|
} elseif ($x = $this->fo->route(0) AND $x !== '*' AND is_numeric($x)) {
|
|
|
|
$next_page = ['frame'=>$x];
|
|
|
|
|
|
|
|
// No further routes defined, go home.
|
|
|
|
} else {
|
|
|
|
$next_page = ['frame'=>0];
|
|
|
|
}
|
2022-12-09 06:19:33 +00:00
|
|
|
*/
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
action = ACTION_GOTO;
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
} else if (read === '*') {
|
|
|
|
action = ACTION_STAR;
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
default:
|
|
|
|
log(LOG_DEBUG,'- SHOULDNT GET HERE: ['+read+']');
|
|
|
|
action = ACTION_TERMINATE;
|
|
|
|
}
|
|
|
|
log(LOG_DEBUG,'MODE END: ['+read+']');
|
2022-12-09 06:19:33 +00:00
|
|
|
log(LOG_DEBUG,'------------------------------------------------');
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
log(LOG_DEBUG,'------------------------------------------------');
|
2022-12-07 10:49:52 +00:00
|
|
|
log(LOG_DEBUG,'ACTION START: ['+read+'] ('+action+')');
|
2022-05-06 05:32:35 +00:00
|
|
|
switch (action) {
|
|
|
|
// Start command entry
|
|
|
|
case ACTION_STAR:
|
|
|
|
log(LOG_DEBUG,'- ACTION_STAR: ['+(next_page ? pageStr(next_page) : '')+']');
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// @todo If something on the baseline preserve it
|
2022-12-09 06:19:33 +00:00
|
|
|
// @todo This should be SCREEN_LENGTH, not hard coded 24
|
|
|
|
so.cursorOn(0,24);
|
|
|
|
so.baselineSend('BASESTAR',true);
|
|
|
|
action = null;
|
2022-05-06 05:32:35 +00:00
|
|
|
mode = MODE_BL;
|
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
// 719 = NodeActionRetrieving
|
|
|
|
bbs.replace_text(719,'\1h%s \1n\1gJumping to page');
|
2022-05-06 05:32:35 +00:00
|
|
|
bbs.node_action=NODE_RFSD;
|
|
|
|
|
2020-07-21 11:56:57 +00:00
|
|
|
break;
|
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Submitting forms
|
|
|
|
case ACTION_SUBMITRF:
|
2022-12-09 06:19:33 +00:00
|
|
|
action = null;
|
2022-05-06 05:32:35 +00:00
|
|
|
mode = MODE_SUBMITRF;
|
2022-12-09 06:19:33 +00:00
|
|
|
so.cursorOff();
|
|
|
|
|
|
|
|
log(LOG_DEBUG,'- ACTION_SUBMITRF: ['+so.page.type+']');
|
|
|
|
so.baselineSend((so.page.type === 'l' ? 'MSG_LOGON' : 'MSG_SENDORNOT'),true);
|
2020-07-21 11:56:57 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
2020-07-21 11:56:57 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Edit a frame
|
|
|
|
case ACTION_EDIT:
|
|
|
|
log(LOG_DEBUG,'- ACTION_EDIT: ['+JSON.stringify(next_page)+']');
|
2020-07-22 12:37:00 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
if ((so.page.type === FRAME_TYPE_MESSAGE) || (! pageEditor(next_page ? next_page.frame : so.frame))) {
|
|
|
|
action = null;
|
|
|
|
so.cursorOff();
|
|
|
|
so.baselineSend('ACCESS_DENIED',false);
|
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-07-22 12:37:00 +00:00
|
|
|
|
2023-12-24 06:46:37 +00:00
|
|
|
require('ansitex/load/control/frameedit.js','CONTROL_FRAMEEDIT');
|
2020-07-22 12:37:00 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// If we are editing a specific frame, attempt to load it
|
|
|
|
if (next_page) {
|
2023-12-27 11:24:20 +00:00
|
|
|
// In case we need to fall back.
|
2022-12-09 06:19:33 +00:00
|
|
|
var current = so;
|
|
|
|
so.get(next_page);
|
2022-05-06 05:32:35 +00:00
|
|
|
|
|
|
|
// If the frame doesnt exist, check that the parent frame exists in case we are creating a new one
|
2023-12-24 06:44:02 +00:00
|
|
|
if (so.page.name.toString() === null) {
|
2022-05-06 05:32:35 +00:00
|
|
|
log(LOG_DEBUG,'- ACTION_EDIT: check index: '+next_page.index+' ('+String.fromCharCode(next_page.index.charCodeAt(0)-1)+')');
|
|
|
|
|
|
|
|
// We can always create an 'a' frame
|
|
|
|
if (next_page.index !== 'a') {
|
2022-12-09 06:19:33 +00:00
|
|
|
so.get(pageStr({frame: next_page.frame, index: String.fromCharCode(next_page.index.charCodeAt(0)-1)}));
|
2022-05-06 05:32:35 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
log(LOG_DEBUG,'- ACTION_EDIT: check index: '+JSON.stringify(so)+' ('+String.fromCharCode(next_page.index.charCodeAt(0)-1)+')');
|
2023-12-24 06:44:02 +00:00
|
|
|
if (so.page.name.toString() === null) {
|
2022-12-09 06:19:33 +00:00
|
|
|
so = current;
|
2023-12-27 11:24:20 +00:00
|
|
|
current = undefined;
|
2022-05-06 05:32:35 +00:00
|
|
|
// sendbaseline ERR_PAGE
|
2022-12-09 06:19:33 +00:00
|
|
|
so.baselineSend('ERR_NO_PARENT',false);
|
|
|
|
action = mode = null;
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// New frame
|
2023-12-27 11:24:20 +00:00
|
|
|
so.page.name = new PageObject({frame: next_page.frame, index: next_page.index});
|
|
|
|
so.page.cost = 0;
|
|
|
|
so.page.owner = base64_decode(pageOwner(pageStr(next_page)).logo);
|
|
|
|
so.page.content = base64_encode('Start your new page...');
|
2022-05-06 05:32:35 +00:00
|
|
|
}
|
2020-07-21 11:56:57 +00:00
|
|
|
}
|
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
control.push(new edit(so));
|
2020-07-21 11:56:57 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
action = mode = null;
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
2020-07-21 11:56:57 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// GO Backwards
|
|
|
|
case ACTION_BACKUP:
|
|
|
|
log(LOG_DEBUG,'- ACTION_BACKUP: history size - '+history.length+' with ['+history.join('|')+']');
|
|
|
|
// Do we have anywhere to go, drop the current page from the history
|
|
|
|
if (history.length > 1)
|
|
|
|
history.pop();
|
2020-07-29 14:15:48 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// @todo If in control...
|
2020-07-29 14:15:48 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
next_page = (history.length > 0) ? history[history.length-1] : null;
|
2020-07-29 14:15:48 +00:00
|
|
|
|
2023-12-24 06:44:02 +00:00
|
|
|
log(LOG_DEBUG,'- ACTION_BACKUP: Backing up to ['+JSON.stringify(next_page)+'] current ['+so.page.name.toString()+']');
|
2020-07-29 14:15:48 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// If there is no next page, we'll ignore the request.
|
2023-12-24 06:44:02 +00:00
|
|
|
if (! next_page || (next_page.toString() === so.page.name.toString())) {
|
2022-12-09 06:19:33 +00:00
|
|
|
action = null;
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-07-29 14:15:48 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Goto specific page
|
|
|
|
case ACTION_GOTO:
|
|
|
|
// Clear any controls
|
|
|
|
control = [];
|
2022-05-03 11:10:09 +00:00
|
|
|
|
2023-12-24 06:44:02 +00:00
|
|
|
log(LOG_DEBUG,'- ACTION_GOTO: ['+(next_page.toString()+']'));
|
2022-05-06 05:32:35 +00:00
|
|
|
var current = null;
|
2022-04-10 11:09:59 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// For logged in users, we'll see if this is a mail page.
|
|
|
|
if (user.number) {
|
|
|
|
// @todo consider how we do mail security.
|
2022-04-22 12:47:53 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Echoarea mail summary
|
|
|
|
if (/^1[0-9]{6}1$/.test(next_page.frame)) {
|
|
|
|
log(LOG_DEBUG,'- ACTION_GOTO - load echoarea summary: ['+next_page.frame+']');
|
2022-04-22 12:47:53 +00:00
|
|
|
|
2023-12-27 11:24:20 +00:00
|
|
|
current = so;
|
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// @todo look for a template in the area or group first
|
2023-12-27 11:24:20 +00:00
|
|
|
so.get(new PageObject(MAIL_TEMPLATE_AREA_SUMMARY));
|
2022-05-01 07:42:19 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
var ma = new MsgAreas();
|
|
|
|
var area = ma.getArea(next_page.frame);
|
2022-05-03 11:10:09 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// If the template page doesnt exist
|
2023-12-27 11:24:20 +00:00
|
|
|
if ((! so.page.raw) || (! area)) {
|
|
|
|
so = current;
|
|
|
|
current = undefined;
|
2022-12-09 06:19:33 +00:00
|
|
|
so.baselineSend('ERR_ROUTE',false);
|
|
|
|
action = mode = null;
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
|
|
|
}
|
2022-05-01 07:42:19 +00:00
|
|
|
|
2023-12-27 11:24:20 +00:00
|
|
|
// @todo Update the page details from the template
|
2022-05-06 05:32:35 +00:00
|
|
|
// Parent
|
2023-12-27 11:24:20 +00:00
|
|
|
so.page.name = new PageObject({frame: next_page.frame, index: next_page.index});
|
|
|
|
so.page.__properties__.isAccessible = true;
|
|
|
|
so.page.__properties__.isPublic = true;
|
|
|
|
so.page.build_system_fields(area);
|
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
so.page.key[0] = (''+next_page.frame).substr(0,7);
|
2022-05-06 05:32:35 +00:00
|
|
|
|
|
|
|
// First to me
|
2022-12-09 06:19:33 +00:00
|
|
|
so.page.key[1] = atcode('msg_area_msgtome_page',null,null,area);
|
2022-05-12 12:27:06 +00:00
|
|
|
// First Unread
|
2022-12-09 06:19:33 +00:00
|
|
|
so.page.key[2] = atcode('msg_area_msgunread_page',null,null,area);
|
2022-05-06 05:32:35 +00:00
|
|
|
|
|
|
|
// Oldest
|
2022-12-09 06:19:33 +00:00
|
|
|
so.page.key[3] = atcode('msg_area_msgoldest_page',null,null,area);
|
2022-05-06 05:32:35 +00:00
|
|
|
// Newest
|
2022-12-09 06:19:33 +00:00
|
|
|
so.page.key[4] = atcode('msg_area_msgnewest_page',null,null,area);
|
2022-05-01 07:42:19 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
next_page = null;
|
2022-05-01 07:42:19 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// 1zzzzEEnnnn - get a message
|
|
|
|
} else if (/^1[0-9]{10}/.test(next_page.frame)) {
|
|
|
|
log(LOG_DEBUG,'- ACTION_GOTO - load message: ['+next_page.frame+']');
|
2022-05-01 07:42:19 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
if (next_page.index === 'a') {
|
2023-12-24 06:44:02 +00:00
|
|
|
require('ansitex/load/control/echomail.js','CONTROL_ECHOMAIL');
|
2023-12-25 22:17:19 +00:00
|
|
|
control.push(new echomail(next_page.frame,so));
|
2022-12-09 06:19:33 +00:00
|
|
|
action = null;
|
2022-05-06 05:32:35 +00:00
|
|
|
next_page = null;
|
|
|
|
log(LOG_DEBUG,'- ACTION_GOTO - control message: ['+JSON.stringify(control[control.length-1])+'] ('+control.length+')');
|
2022-05-01 07:42:19 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
if (! control[control.length-1].ready()) {
|
|
|
|
log(LOG_DEBUG,'- ACTION_GOTO - control not ready aborting...');
|
|
|
|
control.pop();
|
2022-12-09 06:19:33 +00:00
|
|
|
mode = null;
|
2022-05-06 05:32:35 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
so.baselineSend('ERR_ROUTE',false);
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// @todo - Show message stats
|
|
|
|
} else if (next_page.index === 'b') {
|
2022-12-09 06:19:33 +00:00
|
|
|
action = mode = null;
|
2022-05-06 05:32:35 +00:00
|
|
|
next_page = null;
|
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
so.baselineSend('ERR_NOT_IMPLEMENTED',false);
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
} else {
|
2022-12-09 06:19:33 +00:00
|
|
|
action = mode = null;
|
2022-05-06 05:32:35 +00:00
|
|
|
next_page = null;
|
2022-05-03 11:10:09 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
so.baselineSend('ERR_ROUTE',false);
|
2022-05-03 11:10:09 +00:00
|
|
|
break;
|
|
|
|
}
|
2022-05-06 05:32:35 +00:00
|
|
|
}
|
|
|
|
}
|
2022-05-03 11:10:09 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
if (next_page !== null) {
|
2022-12-09 06:19:33 +00:00
|
|
|
current = so;
|
|
|
|
so.get(next_page);
|
2022-05-03 11:10:09 +00:00
|
|
|
|
2023-12-24 06:44:02 +00:00
|
|
|
if (so.page.name.toString() === null) {
|
|
|
|
log(LOG_DEBUG,'- Next Page: ['+(next_page.toString()+'] doesnt exist?'));
|
2022-12-09 06:19:33 +00:00
|
|
|
so = current;
|
2022-05-03 11:10:09 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// In case the frame doesnt exist
|
2023-12-25 22:17:19 +00:00
|
|
|
//if (so === null)
|
|
|
|
// so = (SESSION_EXT === 'vtx') ? new SessionViewdata() : new SessionAnsitex();
|
2022-05-01 07:42:19 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// sendbaseline ERR_PAGE
|
2022-12-09 06:19:33 +00:00
|
|
|
so.baselineSend('ERR_ROUTE',false);
|
|
|
|
action = mode = null;
|
2022-05-03 11:10:09 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
next_page = null;
|
2019-10-03 04:08:48 +00:00
|
|
|
}
|
2022-05-01 07:42:19 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// If the user has access to the frame
|
2022-12-09 06:19:33 +00:00
|
|
|
if (so.page.accessible) {
|
|
|
|
if (so.page.isMember && so.page.type === FRAME_TYPE_LOGIN) {
|
|
|
|
so.baselineSend('ALREADY_MEMBER',false);
|
|
|
|
action = mode = null;
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Check if the frame exists, and the user is the Service Provider
|
|
|
|
} else {
|
2022-12-09 06:19:33 +00:00
|
|
|
so.baselineSend('ACCESS_DENIED',false);
|
|
|
|
action = mode = null;
|
2022-05-06 05:32:35 +00:00
|
|
|
// Reset the current frame to what it was.
|
2022-12-09 06:19:33 +00:00
|
|
|
so = current;
|
2019-10-03 04:08:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
log(LOG_DEBUG,'- ACTION_GOTO: next_page ['+JSON.stringify(next_page)+'] last history ['+JSON.stringify(history[history.length-1])+']');
|
2019-10-17 13:27:51 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Record our history
|
2022-12-09 06:19:33 +00:00
|
|
|
if ((! history.length || (pageStr(history[history.length-1]) !== so.page.name)) && (so.page.type !== FRAME_TYPE_LOGIN)) {
|
2022-05-06 05:32:35 +00:00
|
|
|
// Ignore the login frames
|
2023-12-24 06:44:02 +00:00
|
|
|
if (FRAMES_NO_HISTORY.indexOf(so.page.name.toString()) === -1) {
|
2022-12-09 06:19:33 +00:00
|
|
|
history.push(so.page.name);
|
2023-12-24 06:44:02 +00:00
|
|
|
log(LOG_DEBUG,'- ACTION_GOTO: Added to history ['+so.page.name.toString()+'] now ['+history.length+']');
|
2022-05-06 05:32:35 +00:00
|
|
|
}
|
2019-10-17 13:27:51 +00:00
|
|
|
}
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Load frame
|
|
|
|
case ACTION_RELOAD:
|
2022-12-05 11:36:03 +00:00
|
|
|
// Clear our current field
|
|
|
|
cf = null;
|
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
log(LOG_DEBUG,'- ACTION_RELOAD: ['+(next_page ? pageStr(next_page) : '')+']');
|
2023-12-27 11:24:20 +00:00
|
|
|
if (debug_mode && so.page.name.toString() === '98b')
|
|
|
|
so.page.key[1] = debug_mode.split('/')[2];
|
2022-05-06 05:32:35 +00:00
|
|
|
|
|
|
|
console.line_counter = 0; // @todo fix to suppress a pause that is occurring before clear()
|
2022-12-09 06:19:33 +00:00
|
|
|
so.cursorOff();
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
// 695 = NodeActionMain
|
2023-12-24 06:44:02 +00:00
|
|
|
bbs.replace_text(695,'\1h%s \1nViewing \1h*'+so.page.name.toString()+'#\1n');
|
|
|
|
bbs.log_str(so.page.name.toString()+'|');
|
2022-05-06 05:32:35 +00:00
|
|
|
bbs.node_action=NODE_MAIN;
|
2020-07-29 14:15:48 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
switch(so.page.type) {
|
2022-05-06 05:32:35 +00:00
|
|
|
// Terminate frame
|
|
|
|
case FRAME_TYPE_MAIL_TEMPLATE:
|
2022-12-09 06:19:33 +00:00
|
|
|
log(LOG_DEBUG,'- MAIL_TEMPLATE: ['+so.frame+']');
|
2023-12-27 11:24:20 +00:00
|
|
|
so.render();
|
2022-12-09 06:19:33 +00:00
|
|
|
action = mode = null;
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
2022-05-01 07:42:19 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Terminate frame
|
|
|
|
case FRAME_TYPE_TERMINATE:
|
2022-12-09 06:19:33 +00:00
|
|
|
so.render();
|
2022-05-06 05:32:35 +00:00
|
|
|
action = ACTION_TERMINATE;
|
2022-12-09 06:19:33 +00:00
|
|
|
mode = null;
|
2022-05-01 07:42:19 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// External Frame
|
|
|
|
// @todo returning from the frame, go to the 0 key if it is set
|
|
|
|
case FRAME_TYPE_EXTERNAL:
|
2023-12-27 11:24:20 +00:00
|
|
|
var content = base64_decode(so.page.raw);
|
2022-05-06 05:32:35 +00:00
|
|
|
log(LOG_DEBUG,'- ACTION_GOTO: EXTERNAL ['+JSON.stringify(content)+']');
|
|
|
|
|
|
|
|
switch(content.replace(/\n/,'')) {
|
|
|
|
case 'bbs.user_config()':
|
|
|
|
case 'bbs.read_mail(MAIL_YOUR)':
|
|
|
|
case 'bbs.scan_subs(SCAN_NEW)':
|
|
|
|
case 'bbs.scan_posts()':
|
|
|
|
case 'bbs.post_msg()':
|
|
|
|
eval(content);
|
|
|
|
|
|
|
|
// Check and see if our shell was changed
|
|
|
|
if (user.command_shell !== 'ansitex') {
|
|
|
|
exit();
|
|
|
|
}
|
2019-10-16 05:32:43 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
action = ACTION_BACKUP;
|
|
|
|
break;
|
2019-11-03 12:42:03 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
default:
|
|
|
|
console.putmsg(JSON.stringify(content));
|
2022-12-09 06:19:33 +00:00
|
|
|
so.baselineSend('ERR_ROUTE',false);
|
|
|
|
action = null;
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-10-27 01:04:22 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
mode = null;
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
2019-11-03 12:42:03 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
case FRAME_TYPE_LOGIN:
|
2022-12-09 06:19:33 +00:00
|
|
|
action = null;
|
2022-05-06 05:32:35 +00:00
|
|
|
/* fallthrough */
|
2019-10-27 01:04:22 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
case FRAME_TYPE_RESPONSE:
|
|
|
|
fn = 0;
|
|
|
|
cf = null;
|
2022-12-09 06:19:33 +00:00
|
|
|
so.render();
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
if (so.page.input_fields.length) {
|
|
|
|
cf = so.page.input_fields[fn];
|
2022-05-06 05:32:35 +00:00
|
|
|
log(LOG_DEBUG,'cf'+JSON.stringify(cf));
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
if (cf) {
|
|
|
|
mode = MODE_FIELD;
|
2022-12-09 06:19:33 +00:00
|
|
|
so.cursorOn(cf.x,cf.y);
|
|
|
|
log(LOG_DEBUG,'- Current Field:'+JSON.stringify(cf));
|
|
|
|
log(LOG_DEBUG,'Writing attribute:'+JSON.stringify(cf.attribute));
|
|
|
|
so.attr(cf.attribute);
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// There were no editable fields.
|
|
|
|
} else {
|
|
|
|
mode = MODE_COMPLETE;
|
2022-12-09 06:19:33 +00:00
|
|
|
so.cursorOff();
|
2022-05-06 05:32:35 +00:00
|
|
|
}
|
2020-05-27 11:56:12 +00:00
|
|
|
|
|
|
|
} else {
|
2022-12-09 06:19:33 +00:00
|
|
|
mode = null;
|
2020-05-27 11:56:12 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// If this is the register page
|
2023-12-24 06:44:02 +00:00
|
|
|
if (so.page.name === new PageObject(FRAME_REGISTER)) {
|
2022-05-06 05:32:35 +00:00
|
|
|
log(LOG_DEBUG,'Adding REGISTER to control stack');
|
2023-12-24 06:46:37 +00:00
|
|
|
require('ansitex/load/control/'+so.page.key[1]+'.js','CONTROL_REGISTER');
|
2022-12-09 06:19:33 +00:00
|
|
|
control.push(eval('new '+so.page.key[1]+'();'));
|
2022-05-06 05:32:35 +00:00
|
|
|
|
2023-12-24 06:44:02 +00:00
|
|
|
} else if (so.page.name === new PageObject(FRAME_SQRL)) {
|
2022-05-06 05:32:35 +00:00
|
|
|
log(LOG_DEBUG,'Adding SQRL to control stack');
|
2023-12-24 06:46:37 +00:00
|
|
|
require('ansitex/load/control/'+so.page.key[1]+'.js','CONTROL_SQRL');
|
2022-12-09 06:19:33 +00:00
|
|
|
control.push(eval('new '+so.page.key[1]+'();'));
|
2022-12-07 10:49:52 +00:00
|
|
|
inkey_timeout = 1000;
|
2022-05-06 05:32:35 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
} else if (so.page.key[1] && (so.page.type === FRAME_TYPE_RESPONSE) && (typeof(so.page.key[1]) !== 'number')) {
|
|
|
|
log(LOG_DEBUG,'Adding METHOD to control stack: '+so.page.key[1]);
|
2023-12-24 06:46:37 +00:00
|
|
|
require('ansitex/load/control/'+so.page.key[1]+'.js','CONTROL_'+so.page.key[1].toUpperCase());
|
2022-12-09 06:19:33 +00:00
|
|
|
control.push(eval('new '+so.page.key[1]+'();'));
|
2022-05-06 05:32:35 +00:00
|
|
|
}
|
2020-05-27 11:56:12 +00:00
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
action = null;
|
2020-07-06 12:55:58 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
2020-08-12 13:23:26 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Standard Frame
|
|
|
|
case FRAME_TYPE_INFO:
|
|
|
|
default:
|
2022-12-09 06:19:33 +00:00
|
|
|
so.render();
|
|
|
|
action = mode = null;
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
2020-03-27 13:55:42 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
// Active frame
|
|
|
|
}
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
log(LOG_DEBUG,'ACTION END: ['+read+']');
|
2022-12-09 06:19:33 +00:00
|
|
|
log(LOG_DEBUG,'------------------------------------------------');
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2022-05-06 05:32:35 +00:00
|
|
|
} catch (e) {
|
|
|
|
log(LOG_ERROR,JSON.stringify(e));
|
2022-12-09 06:19:33 +00:00
|
|
|
so.baselineSend('SYS_ERROR',false);
|
|
|
|
action = mode = null;
|
2019-10-03 04:08:48 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-27 11:56:12 +00:00
|
|
|
|
|
|
|
log(LOG_DEBUG,'- FINISHED');
|
2022-04-10 11:09:59 +00:00
|
|
|
if (action === ACTION_TERMINATE) {
|
2020-05-27 11:56:12 +00:00
|
|
|
log(LOG_DEBUG,'! Hangup');
|
2022-12-09 06:19:33 +00:00
|
|
|
so.cursorOn();
|
2020-05-27 11:56:12 +00:00
|
|
|
bbs.hangup();
|
|
|
|
}
|
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
// We need to clear the baseline before we exit, esp during transition from login -> logged on
|
|
|
|
so.baselineClear();
|
2020-05-27 11:56:12 +00:00
|
|
|
exit();
|
2021-02-20 13:18:50 +00:00
|
|
|
}
|