277 lines
6.3 KiB
JavaScript
277 lines
6.3 KiB
JavaScript
// Load many SBBS definitions
|
|
load('sbbsdefs.js');
|
|
// Load text.dat defintions
|
|
load('text.js');
|
|
|
|
// Enable to manipulate the ANSI terminal
|
|
ansiterm = load({},'ansiterm_lib.js');
|
|
|
|
// Ansitex specific includes
|
|
load('texdefs.js');
|
|
load('texfuncs.js');
|
|
|
|
while(bbs.online) {
|
|
var mode = false; // Initial mode
|
|
var next_page = { frame: 1,index: 'a'}; // Start Frame
|
|
var action = ACTION_GOTO; // Initial action
|
|
var inkey_timeout = 0; // Timeout waiting for input @todo required? check if idle timetout occurs
|
|
var fo = null; // Current Frame
|
|
ansiterm.send('ext_mode','clear','cursor');
|
|
|
|
while (action != ACTION_TERMINATE) {
|
|
bbs.nodesync(false); // @todo Stop the display of telegrams
|
|
read = console.inkey(K_NONE,inkey_timeout);
|
|
system.node_list[bbs.node_num-1].action=0xff; // to ensure our node status is updated correctly
|
|
inkey_timeout = 60000; // Set our key timeout to 60s
|
|
log(LOG_DEBUG,'READ: ['+read+']');
|
|
|
|
log(LOG_DEBUG,'MODE START: ['+read+']');
|
|
switch (mode) {
|
|
case false:
|
|
log(LOG_DEBUG,'- false: ['+read+']');
|
|
cmd='';
|
|
|
|
switch (read) {
|
|
case '*': action = ACTION_STAR
|
|
break;
|
|
|
|
// Frame Routing
|
|
case '0':
|
|
case '1':
|
|
case '2':
|
|
case '3':
|
|
case '4':
|
|
case '5':
|
|
case '6':
|
|
case '7':
|
|
case '8':
|
|
case '9':
|
|
if (fo.key[read]) {
|
|
next_page = { frame: fo.key[read] };
|
|
action = ACTION_GOTO;
|
|
log(LOG_DEBUG,'- false: Key ['+read+'] ['+pageStr(next_page)+']');
|
|
|
|
} else {
|
|
sendBaseline(ERR_ROUTE,false);
|
|
}
|
|
|
|
break;
|
|
|
|
case '#':
|
|
if (frame.index !== 'z') {
|
|
next_page = { frame: fo.frame, index: String.fromCharCode(fo.index.charCodeAt(0)+1) };
|
|
action = ACTION_GOTO;
|
|
|
|
} else {
|
|
sendBaseline(ERR_ROUTE,false);
|
|
}
|
|
break;
|
|
|
|
case 'Q':
|
|
bbs.hangup();
|
|
exit();
|
|
}
|
|
|
|
break;
|
|
|
|
// Command input on bottom line
|
|
case MODE_BL:
|
|
log(LOG_DEBUG,'- MODE_BL: ['+read+']');
|
|
if (read.match(/[0-9]/)) {
|
|
cmd += read;
|
|
console.write(read);
|
|
}
|
|
|
|
// @todo check if CTRL_H is required?
|
|
if ((read == CTRL_H || read == KEY_DEL) && cmd.length) {
|
|
console.backspace();
|
|
cmd = cmd.substring(0,cmd.length-1);
|
|
}
|
|
|
|
if (cmd == '00') {
|
|
action = ACTION_RELOAD;
|
|
cmd = '';
|
|
cursorOff();
|
|
break;
|
|
}
|
|
|
|
// Edit specific frame
|
|
if (cmd.match(/^04/) && read.match(/[a-z]/)) {
|
|
// @todo
|
|
mode = action = false;
|
|
cmd = '';
|
|
cursorOff();
|
|
sendBaseline(ERR_NOT_IMPLEMENTED,false);
|
|
break;
|
|
}
|
|
|
|
// Bookmark frame
|
|
if (cmd == '05') {
|
|
// @todo
|
|
mode = action = false;
|
|
cmd = '';
|
|
cursorOff();
|
|
sendBaseline(ERR_NOT_IMPLEMENTED,false);
|
|
break;
|
|
}
|
|
|
|
// Report Problem
|
|
if (cmd == '08') {
|
|
// @todo
|
|
mode = action = false;
|
|
cmd = '';
|
|
cursorOff();
|
|
sendBaseline(ERR_NOT_IMPLEMENTED,false);
|
|
break;
|
|
}
|
|
|
|
// Reload frame
|
|
if (cmd == '09') {
|
|
// @todo
|
|
action = ACTION_GOTO;
|
|
cmd = '';
|
|
cursorOff();
|
|
next_page = { frame: fo.frame, index: fo.index};
|
|
break;
|
|
}
|
|
|
|
// Another star aborts the command
|
|
if (read == '*') {
|
|
mode = action = false;
|
|
sendBaseline('',false);
|
|
cmd = '';
|
|
cursorOff();
|
|
|
|
// @todo If we are editing a field...
|
|
}
|
|
|
|
if (read == '#' || read == '\r') {
|
|
// Nothing typed between * and #
|
|
// *# means go back
|
|
if (cmd == '') {
|
|
sendBaseline(ERR_NOT_IMPLEMENTED,false);
|
|
|
|
} else if (cmd == '0') {
|
|
next_page = { frame: 1 }; // @todo specificy home page in config
|
|
action = ACTION_GOTO;
|
|
|
|
// Edit frame
|
|
} else if (cmd == '04') {
|
|
sendBaseline(ERR_NOT_IMPLEMENTED,false);
|
|
|
|
} else {
|
|
next_page = { frame: cmd };
|
|
action = ACTION_GOTO;
|
|
}
|
|
|
|
// Clear the command we are finished processing...
|
|
cursorOff();
|
|
cmd = '';
|
|
mode = false;
|
|
}
|
|
|
|
break;
|
|
|
|
// @todo MODE_CONTROL
|
|
|
|
default:
|
|
log(LOG_DEBUG,'- SHOULDNT GET HERE: ['+read+']');
|
|
}
|
|
log(LOG_DEBUG,'MODE END: ['+read+']');
|
|
|
|
log(LOG_DEBUG,'ACTION START: ['+read+']');
|
|
switch (action) {
|
|
// Start command entry
|
|
case ACTION_STAR:
|
|
log(LOG_DEBUG,'- ACTION_STAR: ['+(next_page ? pageStr(next_page) : '')+']');
|
|
|
|
// @todo If something on the baseline preserve it
|
|
|
|
ansiterm.send('ext_mode','set','cursor');
|
|
sendBaseline('\1N\1G\1H*',true);
|
|
action = false;
|
|
mode = MODE_BL;
|
|
|
|
bbs.replace_text(NodeActionRetrieving,'\1h%s \1n\1gJumping to page');
|
|
bbs.node_action=NODE_RFSD;
|
|
|
|
break;
|
|
|
|
// Goto specific page
|
|
case ACTION_GOTO:
|
|
log(LOG_DEBUG,'- ACTION_GOTO: ['+(next_page ? pageStr(next_page) : '')+']');
|
|
|
|
if (next_page !== null) {
|
|
current = fo;
|
|
fo = getFrame(next_page);
|
|
if (! fo) {
|
|
fo = current;
|
|
// sendbaseline ERR_PAGE
|
|
sendBaseline(ERR_ROUTE,false);
|
|
mode = action = false;
|
|
break;
|
|
}
|
|
current = null;
|
|
}
|
|
|
|
if (fo.isPublic && fo.isAccessible) {
|
|
// @todo if its a login frame and the user is already member of CUG, display error
|
|
if (false) {
|
|
// baseline USER_ALREADY_MEMBER
|
|
break;
|
|
}
|
|
|
|
} else {
|
|
// @todo if user is not the owner
|
|
if (false) {
|
|
// @todo if frame is not accessible
|
|
if (false) {
|
|
// baseline ACCESS_DENIED
|
|
break;
|
|
}
|
|
|
|
// @todo if user not a member
|
|
if (false) {
|
|
// baseline ACCESS_DENIED_NOT_IN_CUG
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
// @todo if page is a new location, and we are not going backwards
|
|
// if (($history->last() != $next_page) AND ($action == ACTION_GOTO || $action == ACTION_NEXT))
|
|
if (false) {
|
|
//$history->push($next_page);
|
|
}
|
|
|
|
next_page = null;
|
|
|
|
case ACTION_RELOAD:
|
|
log(LOG_DEBUG,'- ACTION_RELOAD: ['+(next_page ? pageStr(next_page) : '')+']');
|
|
|
|
// Clear the baseline history
|
|
// $this->sendBaseline($client,'');
|
|
// $current['baseline'] = '';
|
|
|
|
switch(fo.type) {
|
|
// Standard Frame
|
|
default:
|
|
console.line_counter=0; // @todo fix to suppress a pause that is occurring before clear()
|
|
console.clear();
|
|
console.putmsg(fo.render());
|
|
mode = action = false;
|
|
|
|
// Active frame
|
|
|
|
// Terminate frame
|
|
}
|
|
|
|
// bbs.node_action=NODE_RFSD;
|
|
bbs.replace_text(NodeActionMain,'\1h%s \1nViewing \1h*'+fo.frame+'#\1n ['+fo.index+']');
|
|
bbs.node_action=NODE_MAIN;
|
|
break;
|
|
}
|
|
log(LOG_DEBUG,'ACTION END: ['+read+']');
|
|
}
|
|
}
|