Added welcome/goodbye frames and terminate pages
This commit is contained in:
@@ -12,7 +12,7 @@ load('texfuncs.js');
|
||||
|
||||
while(bbs.online) {
|
||||
var mode = false; // Initial mode
|
||||
var next_page = { frame: 1,index: 'a'}; // Start Frame
|
||||
var next_page = { frame: 98,index: 'b'}; // 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
|
||||
@@ -66,10 +66,6 @@ while(bbs.online) {
|
||||
sendBaseline(ERR_ROUTE,false);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Q':
|
||||
bbs.hangup();
|
||||
exit();
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -252,21 +248,24 @@ exit();
|
||||
// Clear the baseline history
|
||||
// $this->sendBaseline($client,'');
|
||||
// $current['baseline'] = '';
|
||||
console.line_counter=0; // @todo fix to suppress a pause that is occurring before clear()
|
||||
console.clear();
|
||||
console.putmsg(fo.render());
|
||||
|
||||
switch(fo.type) {
|
||||
// Terminate frame
|
||||
case FRAME_TYPE_TERMINATE:
|
||||
bbs.hangup();
|
||||
exit();
|
||||
|
||||
// Standard Frame
|
||||
case FRAME_TYPE_INFO:
|
||||
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;
|
||||
|
@@ -1,36 +1,50 @@
|
||||
load('texdefs.js');
|
||||
load('texfuncs.js');
|
||||
|
||||
// Import
|
||||
send = getArg('-s','Use -s 1 to send',false);
|
||||
file = getArg('-S','Use -S filename',false);
|
||||
frame = '';
|
||||
// Modes of operation:
|
||||
// -s -p x -i y = To send a stored page via the msgbase
|
||||
// {-s} -p x -i y -f file = To update (and optionally send) a page with new content
|
||||
// -all details = to create a new page
|
||||
|
||||
// Import
|
||||
send = (argv.indexOf('-s') >= 0);
|
||||
// Page
|
||||
p = getArg('-p','No page specified with -p',true);
|
||||
// Index
|
||||
i = getArg('-i','No index specified with -i',true);
|
||||
// File to convert
|
||||
file = getArg('-f','No file specified with -f',false);
|
||||
|
||||
frame = getFrame({frame: p,index: i});
|
||||
|
||||
if (! send || ! frame || file) {
|
||||
if (! frame) {
|
||||
frame = new Frame(p,i);
|
||||
}
|
||||
|
||||
if (! send || ! file) {
|
||||
// File to convert
|
||||
file = getArg('-f','No file specified with -f',true);
|
||||
// Page
|
||||
p = getArg('-p','No page specified with -p',true);
|
||||
// Index
|
||||
i = getArg('-i','No index specified with -i',false);
|
||||
// Key
|
||||
key = getArg('-k','No index specified with -k',false);
|
||||
// Cost
|
||||
cost = getArg('-c','No index specified with -c',false);
|
||||
// Owner
|
||||
owner = getArg('-o','No owner specified with -o',true);
|
||||
// Import
|
||||
send = getArg('-s','Use -s 1 to send',false);
|
||||
owner = getArg('-o','No owner specified with -o',false);
|
||||
// Owner
|
||||
type = getArg('-t','No type specified with -t',false);
|
||||
|
||||
f = new File(file);
|
||||
if (! f.exists || ! f.open('r')) {
|
||||
log(LOG_ERROR,'! ERROR: Unable to open ['+file+']');
|
||||
exit(1);
|
||||
if (file) {
|
||||
f = new File(file);
|
||||
if (! f.exists || ! f.open('r')) {
|
||||
log(LOG_ERROR,'! ERROR: Unable to open ['+file+']');
|
||||
exit(1);
|
||||
}
|
||||
|
||||
frame.content = base64_encode(f.read());
|
||||
f.close();
|
||||
}
|
||||
|
||||
frame = new Frame(p,i);
|
||||
frame.owner = base64_encode(owner.replace(/\\1/g,"\1"));
|
||||
frame.content = base64_encode(f.read());
|
||||
if (owner) {
|
||||
frame.owner = base64_encode(owner.replace(/\\1/g,"\1"));
|
||||
}
|
||||
|
||||
if (key) {
|
||||
frame.key = key.split(',').map(function(t){return parseInt(t)});
|
||||
@@ -42,14 +56,27 @@ if (! send || ! file) {
|
||||
}
|
||||
|
||||
// Public
|
||||
frame.isPublic = (argv.indexOf('-P') >= 0);
|
||||
frame.isAccessible = (argv.indexOf('-A') >= 0);
|
||||
if (argv.indexOf('-P') >= 0)
|
||||
frame.isPublic = 1;
|
||||
|
||||
if (argv.indexOf('-A') >= 0)
|
||||
frame.isAccessible = 1;
|
||||
|
||||
if (cost)
|
||||
frame.cost = cost;
|
||||
|
||||
if (type)
|
||||
frame.type = type; // @todo validate this is a valid type.
|
||||
|
||||
// Date
|
||||
frame.date = new Date().toISOString();
|
||||
|
||||
// Final validation
|
||||
if (! frame.owner) {
|
||||
log(LOG_ERROR,'! ERROR: No owner specified ['+file+']');
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Store the frame in file
|
||||
file = system.text_dir+'ansitex/'+frame.page+'.tex';
|
||||
w = new File(file);
|
||||
@@ -71,29 +98,6 @@ if (send == 1) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (! frame) {
|
||||
f = new File(file);
|
||||
if (! f.open('r')) {
|
||||
log(LOG_ERROR,'! ERROR: Unable to open '+file);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
frame = JSON.parse(f.read());
|
||||
x = new Frame(0);
|
||||
frame.render = x.render;
|
||||
|
||||
// @todo Figure out how to delete this duplicate code
|
||||
Object.defineProperty(frame,'page', {
|
||||
get: function() {return this.frame+this.index}
|
||||
});
|
||||
} catch (error) {
|
||||
log(LOG_ERROR,error);
|
||||
exit(1);
|
||||
}
|
||||
f.close();
|
||||
}
|
||||
|
||||
if (file_exists(file+'.gpg'))
|
||||
file_remove(file+'.gpg')
|
||||
|
||||
|
@@ -19,6 +19,9 @@ var FRAME_PAGENUM =12; /* Size of page number (length with a-z)
|
||||
var FRAME_COST =9; /* Size of cost (length without unit)*/
|
||||
var FRAME_COSTUNIT ='c'; /* Unit of cost */
|
||||
|
||||
var FRAME_TYPE_INFO ='i';
|
||||
var FRAME_TYPE_TERMINATE ='t';
|
||||
|
||||
var ERR_NOT_IMPLEMENTED = '\1RNOT IMPLEMENTED YET?';
|
||||
var ERR_ROUTE = '\1n\1h\1WMISTAKE? \1GTRY AGAIN OR TELL US ON *08';
|
||||
|
||||
@@ -37,6 +40,7 @@ function Frame(frame,index) {
|
||||
this.content='';
|
||||
this.isPublic=false; // @todo
|
||||
this.isAccessible=false; // @todo
|
||||
this.type = FRAME_TYPE_INFO;
|
||||
this.key=[ null,null,null,null,null,null,null,null,null,null ];
|
||||
this.render=function() {
|
||||
owner = base64_decode(this.owner);
|
||||
|
@@ -107,6 +107,7 @@ function getFrame(page) {
|
||||
Object.defineProperty(frame,'page', {
|
||||
get: function() {return this.frame+this.index}
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
log(LOG_ERROR,error);
|
||||
return null;
|
||||
|
Reference in New Issue
Block a user