Compare commits

..

4 Commits

27 changed files with 1082 additions and 857 deletions

View File

@ -1,3 +1,8 @@
require('smbdefs.js','MSG_DELETE');
require('sbbsdefs.js','SUB_FIDO');
load('string.js');
load('lz-string.js');
/** /**
* ANSItex definitions * ANSItex definitions
*/ */
@ -11,6 +16,9 @@ const FRAMES_MSG_BASE = 'vtx_data';
/* Load frames from files */ /* Load frames from files */
const FRAMES_MSG_FILES = true; const FRAMES_MSG_FILES = true;
const PAGE_LENGTH = 4; // The size of our page tag as stored in the msgbase for echomail/netmail
const NUMERIC_REGEX = /^[0-9]*$/;
/* Unit of cost */ /* Unit of cost */
const FRAME_COSTUNIT = 'c'; const FRAME_COSTUNIT = 'c';
@ -51,21 +59,22 @@ const MODE_RFSENT = 5;
const MODE_RFERROR = 6; const MODE_RFERROR = 6;
/** FRAME TYPES **/ /** FRAME TYPES **/
// @todo Change these to bits
/* Information Frame, requires no response after viewed */ /* Information Frame, requires no response after viewed */
const FRAME_TYPE_INFO = 'i'; const FRAME_TYPE_INFO = 0; //'i';
/* Terminate Frame, contents displayed and then carrier dropped */ /* Terminate Frame, contents displayed and then carrier dropped */
const FRAME_TYPE_TERMINATE = 't'; const FRAME_TYPE_TERMINATE = 15; //'t';
/** /**
* Frame the calls an External Method * Frame the calls an External Method
* Contents indicate the method to be called with arguments * Contents indicate the method to be called with arguments
*/ */
const FRAME_TYPE_EXTERNAL = 'x'; const FRAME_TYPE_EXTERNAL = 13; //'x';
/** /**
* Frame calls a door * Frame calls a door
* Contents indicate the name of the door * Contents indicate the name of the door
*/ */
const FRAME_TYPE_DOOR = 'X'; const FRAME_TYPE_DOOR = 11; //'X';
/** /**
* Frame renders a BBS from sbbslist * Frame renders a BBS from sbbslist
* Contents can be: * Contents can be:
@ -77,13 +86,13 @@ const FRAME_TYPE_BBS = 'b';
* Response frame, input fields are embedded in the frame and after input the * Response frame, input fields are embedded in the frame and after input the
* response will be submitted to the Service Provider, or to a method * response will be submitted to the Service Provider, or to a method
*/ */
const FRAME_TYPE_RESPONSE = 'r'; const FRAME_TYPE_RESPONSE = 1; //'r';
/* Login frame, enables the user to authenticate to the system, or to a CUG */ /* Login frame, enables the user to authenticate to the system, or to a CUG */
const FRAME_TYPE_LOGIN = 'l'; const FRAME_TYPE_LOGIN = 12; //'l';
/* Mail template frames - mail templates will have the user's stats for the area passed to render() */ /* Mail template frames - mail templates will have the user's stats for the area passed to render() */
const FRAME_TYPE_MAIL_TEMPLATE = 'm'; const FRAME_TYPE_MAIL_TEMPLATE = 'm';
/* Frame is a message */ /* Frame is a message */
const FRAME_TYPE_MESSAGE = 'M'; const FRAME_TYPE_MESSAGE = 2; // 'M';
/* Disable *# going backwards for the following frames */ /* Disable *# going backwards for the following frames */
const FRAMES_NO_HISTORY = ['980a','98b','981a','982a','983a','998a']; const FRAMES_NO_HISTORY = ['980a','98b','981a','982a','983a','998a'];
@ -120,14 +129,16 @@ const FRAME_SYSTEM_ERROR = {frame: '998',index: 'a'};
const FRAME_SAVE_ATTRS = [ const FRAME_SAVE_ATTRS = [
'content', // raw source content of a frame (as stored in vtx/tex files) 'content', // raw source content of a frame (as stored in vtx/tex files)
'cost', // integer, frame cost 'cost', // integer, frame cost
'dynamic_fields', // array of fields 'date', // date, date frame created
'dynamic_fields', // array of fields // @todo deprecate and work these out when loading and parsing a frame
'frame', // Page ID, 'frame', // Page ID,
'index', // Page index, 'index', // Page index,
'input_fields', // array of fields 'input_fields', // array of fields // @todo deprecate and work these out when loading and parsing a frame
'isAccessible', // boolean 'isAccessible', // boolean // @todo deprecate and merge into 'state'
'isPublic', // boolean 'isPublic', // boolean // @todo deprecate and merge into 'state'
'key', // array, representing our key actions 'key', // array, representing our key actions (0-9)
'type', // frame type 'state', // integer, representing type, accessible and public status
'type', // frame type // @todo deprecate and merge into 'state'
'version', // frame version (1) 'version', // frame version (1)
'window' // processed frame data 'window' // processed frame data
]; ];
@ -138,7 +149,7 @@ const MAIL_TEMPLATE_FRAME = {frame: '199',index: 'a'};
/* The page that has our echomail area summary template */ /* 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 // The maximum size (length) of embedded dynamic fields in frames
const DYNAMIC_FIELD_SIZE_MAX = 50; const DYNAMIC_FIELD_SIZE_MAX = 50;
/** ESCAPE CODES **/ /** ESCAPE CODES **/

View File

@ -1,98 +1,189 @@
const PAGE_LENGTH = 4; // The size of our page tag as stored in the msgbase for echomail/netmail 'use strict';
const PAGE_LAST_KEY = 'last_page'; // Last page which has the latest message require('ansitex/load/defs.js','ANSITEX_HOME');
const MAX_PAGE_NUM = 9999; // Maximum page number. @todo Can this be changed to '9'.repeat(PAGE_LENGTH)?
// Our message bases // Our message bases that are enabled to render Videotex Messages
/*
* If a message area doesnt have:
* + a zone_id, then the group isnt Videotex enabled
* + a area_id, then the area isnt Videotex enabled
*/
function MsgAreas() { function MsgAreas() {
'use strict'; this.areas = []; // Message areas
this.areas = [];
this.areas_excluded = [];
var zone_id; var zone_id;
var zone_name; var zone_name;
var ma; var ma;
for(var g in msg_area.grp_list) { // Load the message areas
if (msg_area.grp_list[g].name.indexOf(':') !== -1) { for (var g in msg_area.grp_list) {
zone_id = msg_area.grp_list[g].name.split(':')[0]; for (var a in msg_area.grp_list[g].sub_list) {
zone_name = msg_area.grp_list[g].name.split(':')[1]; //writeln('group:'+g+' name:'+msg_area.grp_list[g].name+' FIDO:'+JSON.stringify(msg_area.grp_list[g].sub_list[a].fidonet_addr)+' INDEX:'+JSON.stringify(msg_area.grp_list[g].sub_list[a].ptridx));
ma = new MsgArea();
ma.group_id = g;
ma.sub_id = a;
if (msg_area.grp_list[g].name.indexOf(':') === -1) {
// If the sub is enabled for FTN, and the zone < 9999, then we'll us that if zone_id is undefined
if ((msg_area.grp_list[g].sub_list[a].settings & SUB_FIDO) && msg_area.grp_list[g].sub_list[a].fidonet_addr) {
var x = msg_area.grp_list[g].sub_list[a].fidonet_addr.split(/([0-9]+):/)[1];
if ((x > 0) && (x < 9999)) {
zone_id = x.padStart(4,'0');
zone_name = msg_area.grp_list[g].name;
}
}
} else {
zone_id = msg_area.grp_list[g].name.split(':')[0];
zone_name = msg_area.grp_list[g].name.split(':')[1];
}
if (zone_id) {
ma.zone_id = zone_id;
ma.zone_name = zone_name;
for (var a in msg_area.grp_list[g].sub_list) {
if (msg_area.grp_list[g].sub_list[a].name.indexOf(':') !== -1) { if (msg_area.grp_list[g].sub_list[a].name.indexOf(':') !== -1) {
ma = new MsgArea(); var sublist = msg_area.grp_list[g].sub_list[a].name.split(':');
ma.zone_id = zone_id; ma.area_id = sublist[0];
ma.zone_name = zone_name; ma.area_name = sublist[1];
ma.area_id = msg_area.grp_list[g].sub_list[a].name.split(':')[0];
ma.area_name = msg_area.grp_list[g].sub_list[a].name.split(':')[1];
ma.code = msg_area.grp_list[g].sub_list[a].code;
this.areas.push(ma); /*
} else { writeln(' code:'+ma.code);
this.areas_excluded.push(zone_name+':'+msg_area.grp_list[g].sub_list[a].name); writeln(' fullname:'+ma.full_name);
writeln(' pageprefix:'+ma.page_prefix)
writeln();
*/
} }
} }
} else { this.areas.push(ma);
zone_name = msg_area.grp_list[g].name;
for (var a in msg_area.grp_list[g].sub_list) {
this.areas_excluded.push(zone_name+':'+msg_area.grp_list[g].sub_list[a].name);
}
} }
} }
/* List areas that we do and dont manage */
Object.defineProperty(this,'list',{ Object.defineProperty(this,'list',{
get: function() { get: function() {
writeln('Areas that we are NOT managing mail:'+this.areas_excluded.length); var areas = this.managed;
writeln('Areas that we ARE managing mail:'+this.areas.length); writeln('Areas that we ARE managing mail:'+areas.length);
for (var x in areas.sort(function(a,b) { return a.page_prefix > b.page_prefix; })) {
for(var x in this.areas_excluded) { writeln(x+':'+areas[x].code+' prefix:'+areas[x].page_prefix);
writeln(x+':'+((this.areas_excluded[x].area_name === undefined)
? this.areas_excluded[x]
: JSON.stringify(this.areas_excluded[x])));
} }
areas = this.unmanaged;
writeln('Areas that we are NOT managing mail:'+areas.length);
for (var x in areas)
writeln(x+':'+areas[x].code);
} }
}); });
/* List of message areas managed */
Object.defineProperty(this,'managed',{
get: function() {
return this.areas.filter(function(item) {
return item.managed;
});
}
});
/* List of message areas unmanaged */
Object.defineProperty(this,'unmanaged',{
get: function() {
return this.areas.filter(function(item) {
return ! item.managed;
})
}
});
/* Fetch a specific message area */
MsgAreas.prototype.getArea = function(area) {
if (area === undefined)
return undefined;
return this.areas.filter(function(x) {
// If the area is a 6 digits, then its a page prefix, otherwise its an area code name
if ((area.length === 6) && (NUMERIC_REGEX.test(area)))
return x.page_prefix === area;
else
return x.code === area;
}).pop();
}
// @todo review
MsgAreas.prototype.getMessage = function(page) {
var area = this.getArea(page);
log(LOG_DEBUG,' - msg:'+JSON.stringify(page.substr(7,4)));
return area ? area.getMessage(page.substr(7,4)) : undefined;
}
// @todo review
MsgAreas.prototype.getUserStats = function(page) {
var area = this.getArea(page);
return area ? msg_area.grp_list[area.msgbase.cfg.grp_number].sub_list[msg_area.sub[area.msgbase.cfg.code].index] : undefined;
}
} }
function MsgArea() { function MsgArea() {
this.zone_id = undefined; this.zone_id = undefined; // Zone this message area belongs to, eg: 0516
this.zone_name = undefined; this.zone_name = undefined; // Zone Name, eg: VIDEOTEX
this.area_id = undefined; this.area_id = undefined; // Sub Area ID for this message area, eg: 01
this.area_name = undefined; this.area_name = undefined; // Sub Area Name for this message area, eg: CHAT
this.msgbase = undefined; this.group_id = undefined; // SBBS Message Group ID
this.headers = undefined; this.sub_id = undefined; // SBBS Message Sub ID
this.tagged_list = undefined;
this.untagged_list = undefined;
this.grp_number = undefined;
this.subnum = undefined;
/** // MSG Base Code
* Build a MsgArea once we are given the code
*/
Object.defineProperty(this,'code',{ Object.defineProperty(this,'code',{
set: function(code) { get: function() {
this.msgbase = new MsgBase(code); //writeln('group_id:'+this.group_id+' sub_id:'+this.sub_id);
return msg_area.grp_list[this.group_id].sub_list[this.sub_id].code;
}
});
// Get all frames that are tagged
Object.defineProperty(this,'frames',{
get: function() {
var msgbase;
var regex = false;
if (this.code === FRAMES_MSG_BASE) {
msgbase = this.msgbase;
} else if (this.managed) {
msgbase = new MsgAreas().getArea(FRAMES_MSG_BASE).msgbase;
regex = this.page_prefix_regex;
} else
return undefined;
var frames = [];
try { try {
if (this.msgbase.open()) { if (msgbase.open()) {
headers = this.msgbase.get_all_msg_headers(false,false) || []; var headers = msgbase.get_all_msg_headers(false,false) || [];
// Just take the last MAX_MESSAGES for (var i in headers) {
this.headers = Object.keys(headers).slice(-(MAX_PAGE_NUM+1)).map(function(key) { return headers[key]; }); if ((! (headers[i].attr&MSG_DELETE)) && headers[i].tags && ((! regex) || regex.test(headers[i].tags)))
headers = undefined; frames.push(headers[i]);
}
this.msgbase.close(); msgbase.close();
} else { } else {
log(LOG_ERROR,code+' cannot be opened:'+this.msgbase.error); writeln('*** NOPE WONT OPEN msgbase:'+JSON.stringify(msgbase));
this.headers = [];
} }
} catch (e) { } catch (e) {
log(LOG_ERROR,code+' cannot be opened:'+e.message); log(LOG_ERROR,this.code+' cannot be opened (frames):'+e.message);
this.headers = [];
return undefined;
} }
return frames.sort(function(a,b) {
return (a.when_imported_time !== b.when_imported_time)
? a.when_imported_time > b.when_imported_time
: a.number > b.number;
});
} }
}); });
@ -103,6 +194,7 @@ function MsgArea() {
} }
}); });
// @deprecated use frames instead
// Total tagged messages // Total tagged messages
Object.defineProperty(this,'list_tagged',{ Object.defineProperty(this,'list_tagged',{
get: function() { get: function() {
@ -124,42 +216,105 @@ function MsgArea() {
} }
}); });
// List untagged messages // Retrieve the last tagged frame
Object.defineProperty(this,'list_untagged',{ Object.defineProperty(this,'last_tagged_message',{
get: function() { get: function() {
if (this.untagged_list === undefined) { var last_tag = this.frames.sort(function(a,b) {
this.untagged_list = []; if (a.when_imported_time === b.when_imported_time)
return a.number > b.number
else
return (a.when_imported_time > b.when_imported_time);
}).pop();
if (! this.headers) if (last_tag === undefined)
return this.untagged_list; return undefined;
for(var x in this.headers) { var msgbase = new MsgAreas().getArea(FRAMES_MSG_BASE).msgbase;
if ((! this.headers[x].tags) || (this.headers[x].tags.length !== PAGE_LENGTH)) {
this.untagged_list.push(this.headers[x]); try {
write(); // @todo This is needed for this to work? if (msgbase.open()) {
} var body = JSON.parse(LZString.decompressFromBase64(msgbase.get_msg_body(last_tag.number)));
msgbase.close();
} else {
writeln('*** NOPE WONT OPEN msgbase:'+JSON.stringify(msgbase));
} }
} catch (e) {
log(LOG_ERROR,this.code+' cannot be opened (last_tagged_message):'+e.message);
return undefined;
} }
return this.untagged_list; msgbase = this.msgbase;
try {
if (msgbase.open()) {
var index = msgbase.get_msg_header(body.id);
msgbase.close();
} else {
writeln('*** NOPE WONT OPEN msgbase:'+JSON.stringify(msgbase));
}
} catch (e) {
log(LOG_ERROR,this.code+' cannot be opened (last_tagged_message_base):'+e.message);
return undefined;
}
return index;
}
})
// Is this area defined for ansitex messages
Object.defineProperty(this,'managed',{
get: function() {
return (this.zone_id !== undefined) && (this.area_id !== undefined);
}
});
Object.defineProperty(this,'max_page',{
get: function() {
return parseInt('9'.repeat(PAGE_LENGTH),10);
}
});
Object.defineProperty(this,'msgbase',{
get: function() {
return new MsgBase(this.code);
} }
}); });
// Get Next page number // Get Next page number
Object.defineProperty(this,'page_next',{ Object.defineProperty(this,'page_next',{
get: function() { get: function() {
var f = new File(file_cfgname(system.mods_dir,'ansitex/ctrl/videotex.ini')); if (! this.managed)
if (! f.open('r')) { return undefined;
writeln('Unable to open ini file');
exit(2); var next_tag = this.frames.pop();
if (next_tag !== undefined) {
next_tag = next_tag.tags;
if (next_tag.indexOf('1'+this.page_prefix) === 0)
next_tag = next_tag.slice(this.page_prefix.length+1);
next_tag = parseInt(next_tag,10)+1;
if (next_tag > this.max_page)
next_tag = 0;
} else {
next_tag = 0;
} }
var page = f.iniGetValue('prefix:'+this.page_prefix,PAGE_LAST_KEY) return (''+next_tag).padStart(4,'0');
f.close();
return page ? page : '0'.repeat(PAGE_LENGTH);
}, },
/*
set: function(page) { set: function(page) {
var f = new File(file_cfgname(system.mods_dir,'ansitex/ctrl/videotex.ini')); var f = new File(file_cfgname(system.mods_dir,'ansitex/ctrl/videotex.ini'));
if (! f.open('r+')) { if (! f.open('r+')) {
@ -170,6 +325,7 @@ function MsgArea() {
f.iniSetValue('prefix:'+this.page_prefix,PAGE_LAST_KEY,(''+page).padStart(4,'0')); f.iniSetValue('prefix:'+this.page_prefix,PAGE_LAST_KEY,(''+page).padStart(4,'0'));
f.close(); f.close();
} }
*/
}); });
// Our page prefix for this msg area // Our page prefix for this msg area
@ -178,251 +334,367 @@ function MsgArea() {
return ''+this.zone_id+this.area_id; return ''+this.zone_id+this.area_id;
}, },
}); });
}
/** // Return a REG to test if this frame is part of this msgbase
* Unread messages [1..] Object.defineProperty(this,'page_prefix_regex',{
* Array key 0 returns the last read message get: function() {
* return new RegExp( '^1'+this.page_prefix);
* @returns {*[]} },
*/ });
MsgArea.prototype.newMsgs = function() {
var msgs = [];
var stats = this.getUserStats();
//log(LOG_DEBUG,'Users last_read pointer: '+JSON.stringify(stats.last_read));
for(var x in this.list_tagged) { // Total Messages in a msgbase
// Advance past our last scan_ptr Object.defineProperty(this,'total_msgs',{
if (this.list_tagged[x].number <= stats.last_read) get: function() {
continue; if (! this.managed)
return undefined;
msgs.push(this.list_tagged[x]); var msgbase = this.msgbase;
write(); // @todo This is needed for this to work? try {
} if (msgbase.open()) {
var index = msgbase.get_index() || [];
return msgs; msgbase.close();
}
/** } else {
* New Messages for the logged in user writeln('*** NOPE WONT OPEN msgbase:'+JSON.stringify(msgbase));
*/ }
MsgArea.prototype.newMsgsToMe = function() {
var msgs = [];
var stats = this.getUserStats();
var last = null;
//log(LOG_DEBUG,'Users scan_ptr pointer: '+JSON.stringify(stats.scan_ptr));
for(var x in this.list_tagged) { } catch (e) {
// Advance past our last scan_ptr log(LOG_ERROR,this.code+' cannot be opened (total_msgs):'+e.message);
if (this.list_tagged[x].number <= stats.scan_ptr) {
if ((this.list_tagged[x].to === user.name) || (this.list_tagged[x].to === user.alias))
last = x;
continue; return undefined;
}
return index.length;
}
});
// List untagged messages
Object.defineProperty(this,'untagged', {
get: function() {
if (! this.managed)
return undefined;
var msgbase = this.msgbase;
var last_tag = this.last_tagged_message;
var msgs = [];
try {
if (msgbase.open()) {
var headers = msgbase.get_all_msg_headers(false,false);
for (var x in headers) {
if (last_tag
&& ((headers[x].when_imported_time < last_tag.when_imported_time)
|| ((headers[x].when_imported_time === last_tag.when_imported_time) && (headers[x].number <= last_tag.number))))
continue;
msgs.push(headers[x]);
}
msgbase.close();
} else {
writeln('*** NOPE WONT OPEN msgbase:'+JSON.stringify(msgbase));
}
} catch (e) {
log(LOG_ERROR,this.code+' cannot be opened (untagged):'+e.message);
return undefined;
}
return msgs.sort(function(a,b) {
return (a.when_imported_time !== b.when_imported_time)
? a.when_imported_time > b.when_imported_time
: a.number > b.number;
});
}
});
// Get frame content
MsgArea.prototype.getContent = function(id) {
// @todo If this is for a echomail/netmail content, then we need to switch message bases
if (this.code !== FRAMES_MSG_BASE)
return undefined;
var msgbase = this.msgbase;
try {
if (msgbase.open()) {
var raw = msgbase.get_msg_body(false,id,false,false,true,true);
// Our messages are terminated with \r=== EOF
if (! /^(.*)\r=== EOF/.test(raw))
return undefined;
var content = JSON.parse(LZString.decompressFromBase64(raw.replace(/\r=== EOF[.\s\S]*$/,'')));
msgbase.close();
} else {
writeln('*** NOPE WONT OPEN msgbase:'+JSON.stringify(msgbase));
}
} catch (e) {
log(LOG_ERROR,this.code+' cannot be opened (frames):'+e.message);
return undefined;
} }
// Add our previous to me message return content;
if (msgs.length === 0) };
msgs.push(last !== null ? this.list_tagged[last] : []);
// @todo review
/**
* Unread messages [1..]
* Array key 0 returns the last read message
*
* @returns {*[]}
*/
MsgArea.prototype.newMsgs = function() {
var msgs = [];
var stats = this.getUserStats();
//log(LOG_DEBUG,'Users last_read pointer: '+JSON.stringify(stats.last_read));
for(var x in this.list_tagged) {
// Advance past our last scan_ptr
if (this.list_tagged[x].number <= stats.last_read)
continue;
if ((this.list_tagged[x].to === user.name) || (this.list_tagged[x].to === user.alias))
msgs.push(this.list_tagged[x]); msgs.push(this.list_tagged[x]);
write(); // @todo This is needed for this to work? write(); // @todo This is needed for this to work?
}
return msgs;
}
/**
* Get a specific message with a tag
*/
MsgArea.prototype.getMessage = function(page) {
var msg = undefined;
for(var x in this.list_tagged) {
if (this.list_tagged[x].tags === page) {
msg = this.list_tagged[x];
break;
}
write(); // @todo This is needed for this to work?
}
if (! msg)
return undefined;
if (! this.msgbase.open()) {
writeln(code+' cannot be opened:'+this.msgbase.error);
return undefined;
}
msg.grp_number = this.msgbase.cfg.grp_number;
var cfg = this.msgbase.cfg;
msg.subnum = msg_area.grp_list[cfg.grp_number].sub_list.filter(function(x) { return x.number === cfg.number; }).pop().index;
msg.content = this.msgbase.get_msg_body(false,msg.number,false,false,true,true);
this.msgbase.close();
return msg;
}
/**
* Get a message page by pointer
*
* @param number
* @returns {string}
*/
MsgArea.prototype.getMessagePage = function(number) {
log(LOG_DEBUG,'Get Message Page with number ['+number+']');
var r;
for (var x in this.list_tagged) {
if (this.list_tagged[x].number === number) {
r = this.list_tagged[x];
break;
}
}
if (! r || r.tags === undefined)
return null;
return '1'+this.zone_id+this.area_id+r.tags;
}
MsgArea.prototype.getUserStats = function() {
return this.msgbase.cfg ? msg_area.grp_list[this.msgbase.cfg.grp_number].sub_list[msg_area.sub[this.msgbase.cfg.code].index] : [];
}
MsgArea.prototype.MessageNext = function(page) {
var x = null;
if (! page)
return undefined;
var msgid = page.substr(7,4);
for(x in this.list_tagged) {
if (this.list_tagged[x].tags === msgid) {
break;
} }
write(); // @todo This is needed for this to work? return msgs;
} }
//log(LOG_DEBUG,'- Next Message is:'+JSON.stringify(this.list_tagged[(parseInt(x)+1)])+', msgid:'+msgid+', page:'+page+', x:'+x); // @todo review
/**
/* * New Messages for the logged in user
= Our next message is either
+ x+1 if x < this.list_tagged.length
+ x=0 if x == this.list_tagged.length (-1)
+ null if this.list_tagged.length == null; (thus no messages)
*/ */
MsgArea.prototype.newMsgsToMe = function() {
var msgs = [];
var stats = this.getUserStats();
var last = null;
//log(LOG_DEBUG,'Users scan_ptr pointer: '+JSON.stringify(stats.scan_ptr));
return x === null ? null : this.list_tagged[(parseInt(x) === this.list_tagged.length-1) ? 0 : (parseInt(x)+1)]; for(var x in this.list_tagged) {
} // Advance past our last scan_ptr
if (this.list_tagged[x].number <= stats.scan_ptr) {
if ((this.list_tagged[x].to === user.name) || (this.list_tagged[x].to === user.alias))
last = x;
MsgArea.prototype.MessagePrev = function(page) { continue;
var prev = null; }
var x = null;
if (! page) // Add our previous to me message
return undefined; if (msgs.length === 0)
msgs.push(last !== null ? this.list_tagged[last] : []);
var msgid = page.substr(7,4); if ((this.list_tagged[x].to === user.name) || (this.list_tagged[x].to === user.alias))
msgs.push(this.list_tagged[x]);
for(x in this.list_tagged) { write(); // @todo This is needed for this to work?
if (this.list_tagged[x].tags === msgid) {
break;
} else {
prev = x;
} }
write(); // @todo This is needed for this to work? return msgs;
} }
/* // @todo review
= Our previous message is either /**
+ prev if a tag was found, unless * Get a specific message with a tag
+ prev is null, in which case it is this.list_tagged.length -1
+ null if x is still null (thus no messages)
*/ */
MsgArea.prototype.getMessage = function(page) {
var msg = undefined;
// If prev is still null, then our last message must be the last one, unless x is null then there are no messages for(var x in this.list_tagged) {
return x === null ? null : this.list_tagged[(prev === null) ? this.list_tagged.length-1 : parseInt(prev)]; if (this.list_tagged[x].tags === page) {
} msg = this.list_tagged[x];
break;
}
write(); // @todo This is needed for this to work?
}
/** if (! msg)
* Tag messages with a frame number return undefined;
* @note: May need to run jsexec with -m 32MB to overcome memory issues
*
* @returns {boolean}
*/
MsgArea.prototype.tag_msgs = function() {
var msgs = this.list_untagged;
writeln("We have "+msgs.length+" messages to tag."); if (! this.msgbase.open()) {
writeln(code+' cannot be opened (getMessage):'+this.msgbase.error);
return undefined;
}
// See if we need to tag something msg.grp_number = this.msgbase.cfg.grp_number;
if (! msgs.length) var cfg = this.msgbase.cfg;
return; msg.subnum = msg_area.grp_list[cfg.grp_number].sub_list.filter(function(x) { return x.number === cfg.number; }).pop().index;
msg.content = this.msgbase.get_msg_body(false,msg.number,false,false,true,true);
this.msgbase.close();
if (! this.msgbase.open()) { return msg;
writeln(code+' cannot be opened:'+this.msgbase.error);
return false;
} }
var page_next = this.page_next; // @todo review
/**
* Get a message page by pointer
*
* @param number
* @returns {string}
*/
MsgArea.prototype.getMessagePage = function(number) {
log(LOG_DEBUG,'Get Message Page with number ['+number+']');
for(var x in msgs) { var r;
msgs[x].tags = (''+(page_next)).padStart(4,'0');
if(! this.msgbase.put_msg_header(msgs[x].number,msgs[x])) { for (var x in this.list_tagged) {
writeln('ERROR:'+this.msgbase.error); if (this.list_tagged[x].number === number) {
r = this.list_tagged[x];
break;
}
}
if (! r || r.tags === undefined)
return null;
return '1'+this.zone_id+this.area_id+r.tags;
}
// @todo review
MsgArea.prototype.getUserStats = function() {
return this.msgbase.cfg ? msg_area.grp_list[this.msgbase.cfg.grp_number].sub_list[msg_area.sub[this.msgbase.cfg.code].index] : [];
}
// @todo review
MsgArea.prototype.MessageNext = function(page) {
var x = null;
if (! page)
return undefined;
var msgid = page.substr(7,4);
for(var x in this.list_tagged) {
if (this.list_tagged[x].tags === msgid) {
break;
}
write(); // @todo This is needed for this to work?
}
//log(LOG_DEBUG,'- Next Message is:'+JSON.stringify(this.list_tagged[(parseInt(x)+1)])+', msgid:'+msgid+', page:'+page+', x:'+x);
/*
= Our next message is either
+ x+1 if x < this.list_tagged.length
+ x=0 if x == this.list_tagged.length (-1)
+ null if this.list_tagged.length == null; (thus no messages)
*/
return x === null ? null : this.list_tagged[(parseInt(x) === this.list_tagged.length-1) ? 0 : (parseInt(x)+1)];
}
// @todo review
MsgArea.prototype.MessagePrev = function(page) {
var prev = null;
var x = null;
if (! page)
return undefined;
var msgid = page.substr(7,4);
for(var x in this.list_tagged) {
if (this.list_tagged[x].tags === msgid) {
break;
} else {
prev = x;
}
write(); // @todo This is needed for this to work?
}
/*
= Our previous message is either
+ prev if a tag was found, unless
+ prev is null, in which case it is this.list_tagged.length -1
+ null if x is still null (thus no messages)
*/
// If prev is still null, then our last message must be the last one, unless x is null then there are no messages
return x === null ? null : this.list_tagged[(prev === null) ? this.list_tagged.length-1 : parseInt(prev)];
}
/**
* Tag messages with a frame number
* @note: May need to run jsexec with -m 32MB to overcome memory issues
*
* @returns {boolean}
*/
MsgArea.prototype.tag_msgs = function() {
var msgs = this.untagged;
var msgbase = new MsgAreas().getArea(FRAMES_MSG_BASE).msgbase;
var page_next = this.page_next;
writeln('* We have '+msgs.length+' messages to tag, starting at '+page_next);
// See if we need to tag something
if (! msgs.length)
return;
if (! msgbase.open()) {
writeln(code+' cannot be opened (tag_msgs):'+msgbase.error);
return false;
}
writeln('Starting at:'+page_next+' (max:'+this.max_page+')');
for (var x in msgs) {
//writeln('- '+msgs[x].when_imported_time+', #:'+msgs[x].number);
var frame = '1'+this.page_prefix+page_next;
var hdr = {
to: frame+'a',
from: 'SYSTEM',
tags: frame,
date: msgs[x].date,
subject: this.code+':'+msgs[x].id,
};
var page = {
id: msgs[x].number,
area_id: this.area_id,
group_id: this.group_id,
date: msgs[x].date,
msgid: msgs[x].id,
imported: msgs[x].when_imported_time,
};
var body = LZString.compressToBase64(JSON.stringify(page));
writeln('Tagging:'+page.id+' Tag:'+page_next+' MSGID:'+page.msgid);
if (! msgbase.save_msg(hdr,body)) {
writeln('! ERROR: Failed to tag '+msgs[x].number);
exit(1);
}
} else {
page_next++; page_next++;
if (page_next > MAX_PAGE_NUM) if (page_next > this.max_page)
page_next = 0; page_next = 0;
page_next = (''+page_next).padStart(4,'0');
} }
msgbase.close();
return true;
} }
this.msgbase.close(); // @todo review
this.page_next = page_next; MsgArea.prototype.page = function(msgid) {
return '1'+this.page_prefix+msgid;
return true; }
}
MsgArea.prototype.page = function(msgid) {
return '1'+this.page_prefix+msgid;
}
MsgAreas.prototype.getArea = function(area) {
log(LOG_DEBUG,'- AREA:'+JSON.stringify(area));
if (area === undefined)
return undefined;
var zone = (''+area).substr(1,4);
var echo = (''+area).substr(5,2);
log(LOG_DEBUG,' - zone:'+zone);
log(LOG_DEBUG,' - echo:'+echo);
return this.areas.filter(function(x) {
return x.zone_id === zone && x.area_id === echo;
})[0]
}
MsgAreas.prototype.getMessage = function(page) {
var area = this.getArea(page);
log(LOG_DEBUG,' - msg:'+JSON.stringify(page.substr(7,4)));
return area ? area.getMessage(page.substr(7,4)) : undefined;
}
MsgAreas.prototype.getUserStats = function(page) {
var area = this.getArea(page);
return area ? msg_area.grp_list[area.msgbase.cfg.grp_number].sub_list[msg_area.sub[area.msgbase.cfg.code].index] : undefined;
} }

View File

@ -1,3 +1,4 @@
'use strict';
/** /**
PAGE.js handles ANSItex and ViewData page frames PAGE.js handles ANSItex and ViewData page frames
@ -76,7 +77,7 @@
*/ */
load('ansitex/load/windows.js'); // Our supporting window class load('ansitex/load/windows.js'); // Our supporting window class
require('ansitex/load/msgbases.js','MAX_PAGE_NUM'); // To read/write to message bases load('ansitex/load/msgbases.js'); // To read/write to message bases
require('sbbsdefs.js','SS_USERON'); // Need for our ANSI colors eg: BG_* require('sbbsdefs.js','SS_USERON'); // Need for our ANSI colors eg: BG_*
/** /**
@ -109,6 +110,8 @@ require('sbbsdefs.js','SS_USERON'); // Need for our ANSI colors eg: BG_*
* - load - Load the frame from the msgbase * - load - Load the frame from the msgbase
*/ */
function Page(debug) { function Page(debug) {
const EOF_MARKER = "\r=== EOF";
this.__window__ = { this.__window__ = {
layout: undefined, // Window - Full page content layout: undefined, // Window - Full page content
header: undefined, // Window - Page Title header: undefined, // Window - Page Title
@ -122,14 +125,15 @@ function Page(debug) {
this.__properties__ = { this.__properties__ = {
name: new PageObject, name: new PageObject,
type: undefined, // Frame type //type: undefined, // Frame type (deprecated, see attrs)
attrs: 0, // (Type 0, CUG 0 (public), Hidden=false)
input_fields: [], // Array of our input fields input_fields: [], // Array of our input fields
dynamic_fields: [], // Array of our dynamic fields dynamic_fields: [], // Array of our dynamic fields
isAccessible: undefined, // Is this page visible to all users //isAccessible: undefined, // Is this page visible to all users (deprecated, see attrs)
// If FALSE, only the SP can view/edit the frame // If FALSE, only the SP can view/edit the frame
isPublic: undefined, // Is this page visible to public (not CUG) users //isPublic: undefined, // Is this page visible to public (not CUG) users (deprecated, see attrs)
// If FALSE user must be a member of the CUG to view the frame // If FALSE user must be a member of the CUG to view the frame
// All users, including unauthenticated, are members of 'system' (owner = 0) // All users, including unauthenticated, are members of 'system' (owner = 0)
// Frame's owned by the system where: // Frame's owned by the system where:
@ -142,7 +146,7 @@ function Page(debug) {
// isPublic is TRUE - can be viewed by users (if logged in) // isPublic is TRUE - can be viewed by users (if logged in)
key: [], // Key actions key: [], // Key actions
raw: undefined, // Page raw content raw: {}, // Page raw content for each session type
}; };
this.__defaults__ = { this.__defaults__ = {
@ -196,57 +200,89 @@ function Page(debug) {
} }
} }
// @todo change this to Object.defineProperty() - see session.js
/** /**
* Determine if this frame is accessible to the current user * Determine if this frame is accessible to the current user
*/ */
Page.prototype.__defineGetter__('accessible',function() { Object.defineProperty(this,'accessible',{
log(LOG_DEBUG,'- Checking if user ['+user.number+'] can access frame: '+this.name.toString()); get: function() {
log(LOG_DEBUG,'|* Frame Owner: '+JSON.stringify(this.pageowner)+', System Frame: '+(this.pageowner === SYSTEM_OWNER)); log(LOG_DEBUG,'- Checking if user ['+user.number+'] can access frame: '+this.name.toString());
log(LOG_DEBUG,'|* Accessible: '+JSON.stringify(this.__properties__.isAccessible)); log(LOG_DEBUG,'|* Frame Owner: '+this.owner+', System Frame: '+this.isSystemPage);
log(LOG_DEBUG,'|* Public: '+JSON.stringify(this.__properties__.isPublic)); log(LOG_DEBUG,'|* Accessible: '+this.isAccessible);
log(LOG_DEBUG,'|* Member: '+JSON.stringify(this.isMember)); log(LOG_DEBUG,'|* Public: '+this.isPublic);
log(LOG_DEBUG,'|* Member: '+this.isMember);
// user.number 0 is unidentified user. // user.number 0 is unidentified user.
if (user.number) { if (user.number) {
return ( return (
(this.__properties__.isAccessible && this.pageowner === SYSTEM_OWNER && ! this.__properties__.isPublic) || (this.isAccessible && this.isSystemPage && ! this.isPublic) ||
(this.__properties__.isAccessible && this.__properties__.isPublic) || (this.isAccessible && this.isPublic) ||
(this.__properties__.isAccessible && ! this.__properties__.isPublic && this.isMember) || (this.isAccessible && ! this.isPublic && this.isMember) ||
(pageEditor(this.name.frame)) (pageEditor(this.name.frame))
); );
} else { } else {
return this.__properties__.isAccessible && (this.pageowner === SYSTEM_OWNER) && this.__properties__.isPublic; return this.isAccessible && this.isSystemPage && this.isPublic;
}
} }
}); });
Page.prototype.__defineGetter__('cost',function() { // The page attributes, which determine accessible, public, cug and frame type
return Number(this.__properties__.cost); Object.defineProperty(this,'attrs',{
get: function() {
return this.__properties__.attrs;
},
/* Frame attributes are bit items, bits:
* 1-4 TYPE
* 5-7 CUG
* 8 accessible
*/
set: function(int) {
if (int === undefined)
int = 0;
this.__properties__.attrs = int;
}
}); });
Page.prototype.__defineSetter__('cost',function(int) {
if (typeof int !== 'number')
throw new Error('Cost must be a number');
this.__properties__.cost = int; Object.defineProperty(this,'cost',{
get: function() {
return Number(this.__properties__.cost);
},
if ((''+int).length > FRAME_COST_LENGTH-1-FRAME_ATTR_LENGTH) set: function(int) {
throw new Error('Cost too large'); if (int === undefined)
int = 0;
// Populate the cost window if (typeof int !== 'number')
switch (SESSION_EXT) { throw new Error('Cost must be a number');
case 'tex':
this.__window__.cost.__properties__.content = rawtoattrs(ESC+'[1;32m'+padright(int,FRAME_COST_LENGTH-1-FRAME_ATTR_LENGTH,' ')+FRAME_COSTUNIT).content;
break; this.__properties__.cost = int;
case 'vtx': if ((''+int).length > FRAME_COST_LENGTH-1-FRAME_ATTR_LENGTH)
this.__window__.cost.__properties__.content = rawtoattrs(VIEWDATA_BIN_GREEN+padright(int,FRAME_COST_LENGTH-1-FRAME_ATTR_LENGTH,' ')+FRAME_COSTUNIT).content; throw new Error('Cost too large');
break; // Populate the cost window
switch (SESSION_EXT) {
case 'tex':
this.__window__.cost.__properties__.content = rawtoattrs(ESC+'[1;32m'+padright(int,FRAME_COST_LENGTH-1-FRAME_ATTR_LENGTH,' ')+FRAME_COSTUNIT).content;
default: break;
throw new Error(SESSION_EXT+' type not implemented');
case 'vtx':
this.__window__.cost.__properties__.content = rawtoattrs(VIEWDATA_BIN_GREEN+padright(int,FRAME_COST_LENGTH-1-FRAME_ATTR_LENGTH,' ')+FRAME_COSTUNIT).content;
break;
default:
throw new Error(SESSION_EXT+' type not implemented');
}
}
});
Object.defineProperty(this,'cug',{
get: function() {
return ((this.__properties__.attrs >> 4) & 0x7);
} }
}); });
@ -272,28 +308,37 @@ function Page(debug) {
this.__properties__.input_fields = array; this.__properties__.input_fields = array;
}); });
Page.prototype.__defineSetter__('isAccessible',function(bool) { Object.defineProperty(this,'isAccessible',{
if (typeof bool !== 'boolean') get: function() {
throw new Error('isAccessible must be a boolean'); return (this.__properties__.attrs >> 7 !== 1);
}
this.__properties__.isAccessible = bool;
}); });
/** /**
* Check if the user is already a member of the CUG * Check if the user is already a member of the CUG
*/ */
Page.prototype.__defineGetter__('isMember',function() { Object.defineProperty(this,'isMember',{
// @todo Implement CUGs, this would be "=== SERVICE_PROVIDER" and user is a member of SERVICE_PROVIDER get: function() {
return user.number && (this.pageowner === SYSTEM_OWNER); // @todo Implement CUGs, this would be "=== SERVICE_PROVIDER" and user is a member of SERVICE_PROVIDER
return (user.number > 0) && this.isSystemPage;
}
}); });
Page.prototype.__defineSetter__('isPublic',function(bool) { // Is the page public or CUG
if (typeof bool !== 'boolean') Object.defineProperty(this,'isPublic',{
throw new Error('isPublic must be a boolean'); get: function() {
return (this.cug === 0);
this.__properties__.isPublic = bool; }
}); });
// Is this a system page
Object.defineProperty(this,'isSystemPage',{
get: function() {
return (this.owner === SYSTEM_OWNER);
}
});
// Key Array
Page.prototype.__defineGetter__('key',function() { Page.prototype.__defineGetter__('key',function() {
return this.__properties__.key; return this.__properties__.key;
}); });
@ -301,6 +346,9 @@ function Page(debug) {
if (typeof array !== 'object') if (typeof array !== 'object')
throw new Error('key must be an array :'+typeof array); throw new Error('key must be an array :'+typeof array);
if (array.length !== 10)
throw new Error('key must contain 10 items :'+array);
return this.__properties__.key = array; return this.__properties__.key = array;
}); });
@ -332,12 +380,20 @@ function Page(debug) {
} }
}); });
// Display who owns the page
Object.defineProperty(this,'owner',{
get: function() {
return pageOwner(this.__properties__.name.frame).prefix;
},
});
Page.prototype.__defineGetter__('pagenext',function() { Page.prototype.__defineGetter__('pagenext',function() {
return this.__properties__.name.next; return this.__properties__.name.next;
}); });
/** /**
* Determine who the owner of a page is * Determine who the owner of a page is
* @deprecated use owner
*/ */
Page.prototype.__defineGetter__('pageowner',function() { Page.prototype.__defineGetter__('pageowner',function() {
return pageOwner(this.__properties__.name.frame).prefix; return pageOwner(this.__properties__.name.frame).prefix;
@ -370,8 +426,14 @@ function Page(debug) {
this.__window__.provider.__properties__.content = provider; this.__window__.provider.__properties__.content = provider;
}); });
Page.prototype.__defineGetter__('raw',function() { Object.defineProperty(this,'raw',{
return this.__properties__.raw; get: function() {
return this.__properties__.raw
},
set: function(value) {
this.__properties__.raw[SESSION_EXT] = value;
}
}); });
Page.prototype.__defineSetter__('showHeader',function(bool) { Page.prototype.__defineSetter__('showHeader',function(bool) {
@ -381,6 +443,12 @@ function Page(debug) {
this.__window__.header.visible = bool; this.__window__.header.visible = bool;
}); });
Object.defineProperty(this,'type',{
get: function() {
return this.__properties__.attrs & 0xf;
},
});
Page.prototype.__defineGetter__('type',function() { Page.prototype.__defineGetter__('type',function() {
return this.__properties__.type; return this.__properties__.type;
}); });
@ -430,7 +498,7 @@ function Page(debug) {
var content = fields[i].value.split(''); var content = fields[i].value.split('');
for (x=fields[i].x;x<fields[i].x+Math.abs(fields[i].length);x++) { for (var x=fields[i].x;x<fields[i].x+Math.abs(fields[i].length);x++) {
var index = x-fields[i].x; var index = x-fields[i].x;
if (content[index]) if (content[index])
@ -513,14 +581,14 @@ function Page(debug) {
last = new_screen; last = new_screen;
// Check all our dynamic fields have been placed // Check all our dynamic fields have been placed
df = this.dynamic_fields.filter(function(item) { return item.value === undefined; }); var df = this.dynamic_fields.filter(function(item) { return item.value === undefined; });
// If our dynamic fields havent been filled in // If our dynamic fields havent been filled in
if (df.length > 0) if (df.length > 0)
throw new Error('Dynamic fields ['+df.length+'] without values:'+(df.map(function(item) { return item.name; }).join('|'))); throw new Error('Dynamic fields ['+df.length+'] without values:'+(df.map(function(item) { return item.name; }).join('|')));
// Render the display // Render the display
for (y=1;y<=this.height;y++) { for (var y=1;y<=this.height;y++) {
var line = ''; var line = '';
if (new_line) if (new_line)
@ -529,7 +597,7 @@ function Page(debug) {
if (debug) if (debug)
writeln('============== ['+y+'] ==============='); writeln('============== ['+y+'] ===============');
for (x=1;x<=this.width;x++) { for (var x=1;x<=this.width;x++) {
if (debug) if (debug)
log(LOG_DEBUG,'* CELL : y:'+y+', x:'+x); log(LOG_DEBUG,'* CELL : y:'+y+', x:'+x);
// The current char value // The current char value
@ -729,7 +797,7 @@ function Page(debug) {
// Dump Header // Dump Header
write('--:'); write('--:');
for (x=0;x<this.width;x+=10) { for (var x=0;x<this.width;x+=10) {
write('_'.repeat(4)+'.'+'_'.repeat(4)+'|'); write('_'.repeat(4)+'.'+'_'.repeat(4)+'|');
} }
writeln(); writeln();
@ -749,7 +817,7 @@ function Page(debug) {
// Dump Header // Dump Header
write('--:'); write('--:');
for (x=0;x<this.width;x+=10) { for (var x=0;x<this.width;x+=10) {
write('_'.repeat(4)+'.'+'_'.repeat(4)+'|'); write('_'.repeat(4)+'.'+'_'.repeat(4)+'|');
} }
writeln(); writeln();
@ -825,6 +893,21 @@ function Page(debug) {
} }
} }
Page.prototype.file_content = function(filename) {
log(LOG_DEBUG,'|-- Importing frame content: ['+filename+']');
var f = new File(filename);
if (! f.exists || ! f.open('rb',true)) {
log(LOG_ERROR,'|? File doesnt exist: ['+filename+']');
return false;
}
var content = f.read();
f.close();
return content;
};
/** /**
* Load a specific page * Load a specific page
* *
@ -834,12 +917,14 @@ function Page(debug) {
if (!(page instanceof PageObject)) if (!(page instanceof PageObject))
throw new Error('page must be a PageObject'); throw new Error('page must be a PageObject');
this.name = page;
// Load a page from disk first if it exists // Load a page from disk first if it exists
if (FRAMES_MSG_FILES && this.import(FRAMES_HOME+SESSION_EXT+'/'+page.toString(),SESSION_EXT)) if (FRAMES_MSG_FILES && this.import(FRAMES_HOME+page.toString(),SESSION_EXT))
return true; return true;
// Fall back to loading from msgbase // Fall back to loading from msgbase
return FRAMES_MSG_BASE ? this.load(page) : false; return FRAMES_MSG_BASE && this.load(page);
} }
/** /**
@ -862,53 +947,53 @@ function Page(debug) {
* Load a frame from a file * Load a frame from a file
* *
* @param filename - Name of file to load page from (SBBS default dir is CTRL, so relative to it) * @param filename - Name of file to load page from (SBBS default dir is CTRL, so relative to it)
* @param width - Width to build window (not required for ANS)
* @param height - Height to build window (not required for ANS)
* @returns {boolean} * @returns {boolean}
* @todo Dont allow load() to load a Viewdata frame for an ANSItex session and visa-versa.
*/ */
this.import = function(filename,ext,width,height) { Page.prototype.import = function(filename) {
log(LOG_DEBUG,'|- Importing frame: ['+filename+']'); log(LOG_DEBUG,'|- Importing frame: ['+filename+']');
var f = new File(filename); var f = new File(filename);
if (! f.exists || ! f.open('rb',true)) { if (! f.exists || ! f.open('rb',true)) {
log(LOG_ERROR,'|? File doesnt exist: ['+filename+']'); log(LOG_ERROR,'|? File doesnt exist: ['+filename+']');
return null; return false;
} }
var contents = f.read(); var contents = JSON.parse(f.read());
contents.date = f.date;
f.close(); f.close();
// Load the page content
if (contents.version === 2)
contents.content = this.file_content(FRAMES_HOME+SESSION_EXT+'/'+this.name.toString()+'.'+CONTENT_EXT);
var valid_sauce = false; var valid_sauce = false;
if (contents.substr(-128, 7) === 'SAUCE00') { if (contents.content.substr(-128, 7) === 'SAUCE00') {
ext = file_getext(filename).substr(1).toLowerCase(); var sauceless_size = ascii(contents.content.substr(-35,1));
var sauceless_size = ascii(contents.substr(-35,1));
sauceless_size <<= 8; sauceless_size <<= 8;
sauceless_size |= ascii(contents.substr(-36,1)); sauceless_size |= ascii(contents.content.substr(-36,1));
sauceless_size <<= 8; sauceless_size <<= 8;
sauceless_size |= ascii(contents.substr(-37,1)); sauceless_size |= ascii(contents.content.substr(-37,1));
sauceless_size <<= 8; sauceless_size <<= 8;
sauceless_size |= ascii(contents.substr(-38,1)); sauceless_size |= ascii(contents.content.substr(-38,1));
var data_type = ascii(contents.substr(-34,1)); var data_type = ascii(contents.content.substr(-34,1));
var file_type = ascii(contents.substr(-33,1)); var file_type = ascii(contents.content.substr(-33,1));
var tinfo1 = ascii(contents.substr(-31,1)); var tinfo1 = ascii(contents.content.substr(-31,1));
tinfo1 <<= 8; tinfo1 <<= 8;
tinfo1 |= ascii(contents.substr(-32,1)); tinfo1 |= ascii(contents.content.substr(-32,1));
var tinfo2 = ascii(contents.substr(-29,1)); var tinfo2 = ascii(contents.content.substr(-29,1));
tinfo2 <<= 8; tinfo2 <<= 8;
tinfo2 |= ascii(contents.substr(-30,1)); tinfo2 |= ascii(contents.content.substr(-30,1));
switch(data_type) { switch(data_type) {
case 1: case 1:
switch(file_type) { switch(file_type) {
// Plain ASCII // Plain ASCII
case 0: case 0:
ext = 'TXT'; var ext = 'TXT';
if (tinfo1) if (tinfo1)
width = tinfo1; width = tinfo1;
if (tinfo2) if (tinfo2)
@ -917,7 +1002,7 @@ function Page(debug) {
// ANSI // ANSI
case 1: case 1:
ext = 'ANS'; var ext = 'ANS';
if (tinfo1) if (tinfo1)
width = tinfo1; width = tinfo1;
if (tinfo2) if (tinfo2)
@ -926,7 +1011,7 @@ function Page(debug) {
// Source // Source
case 7: case 7:
ext = 'TXT'; var ext = 'TXT';
break; break;
} }
@ -934,7 +1019,7 @@ function Page(debug) {
break; break;
case 5: case 5:
ext = 'BIN'; var ext = 'BIN';
width = file_type * 2; width = file_type * 2;
height = (sauceless_size / 2) / width; height = (sauceless_size / 2) / width;
valid_sauce = true; valid_sauce = true;
@ -942,69 +1027,39 @@ function Page(debug) {
} }
if (valid_sauce) if (valid_sauce)
contents = contents.substr(0, sauceless_size); contents.content = contents.content.substr(0, sauceless_size);
} }
return this.preload((['vtx','tex'].indexOf(ext) !== -1) ? JSON.parse(contents) : contents,ext,width,height); return this.preload(contents,SESSION_EXT);
} }
// Load a frame from a message base
this.load = function(page) { this.load = function(page) {
var headers; var page = this.name.toString();
var mb = new MsgAreas().getArea(FRAMES_MSG_BASE)
var mb = new MsgBase(FRAMES_MSG_BASE); var msg = mb.frames
.sort(function(a,b) {
try { if (a.when_imported_time === b.when_imported_time)
if (mb.open()) { return a.number < b.number
headers = mb.get_all_msg_headers(false,false) || []; else
return (a.when_imported_time < b.when_imported_time); })
} else { .filter(function(item) { return item.tags === page; }).pop();
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
for(var x in headers) {
if ((!(headers[x].attr&MSG_DELETE)) && (headers[x].to === page.toString()) && (headers[x].from === SESSION_EXT)) {
msg = headers[x];
//break; @todo We'll take the last one that matches, if there are more than one.
// @todo In the case of frames coming via FTN packets, we are not currently deleting old entries
}
}
if (msg === undefined) { if (msg === undefined) {
log(LOG_DEBUG,'|- Frame not found: ['+page.toString()+'] in ['+FRAMES_MSG_BASE+']'); log(LOG_DEBUG,'|- Frame not found: ['+page.toString()+'] in ['+FRAMES_MSG_BASE+']');
return false; return false;
} else { } else {
log(LOG_DEBUG,'|- Loading frame: ['+page.toString()+'] from msgbase ['+msg.number+']'); log(LOG_DEBUG,'|- Loading frame: ['+page.toString()+'] from msgbase ['+msg.number+'] ['+SESSION_EXT+']');
var contents = mb.get_msg_body(false,msg.number,false,false,true,true).split("\r\n"); var contents = mb.getContent(msg.number);
var i; if (contents === undefined)
for (i=0; i<contents.length; i++) { return false;
// Echomail tag line
if (contents[i] === '---' || contents[i].substring(0,4) === '--- ')
break;
}
contents.length = i;
try { contents.content = contents.content[SESSION_EXT];
var result = JSON.parse(contents.join(''));
} catch(e) { return this.preload(contents,SESSION_EXT);
alert('Error ' + e + ' parsing JSON');
}
return this.preload(result,SESSION_EXT);
} }
return false; return false;
@ -1047,7 +1102,7 @@ function Page(debug) {
* @param height * @param height
* @returns {boolean|null} * @returns {boolean|null}
*/ */
this.preload = function(contents,ext,width,height) { this.preload = function(contents,ext) {
switch (ext) { switch (ext) {
// Messages // Messages
case 'txt': case 'txt':
@ -1055,7 +1110,7 @@ function Page(debug) {
var page = rawtoattrs(contents,this.width,this.__window__.body.y,this.__window__.body.x,debug); var page = rawtoattrs(contents,this.width,this.__window__.body.y,this.__window__.body.x,debug);
this.__window__.body.__properties__.content = page.content; this.__window__.body.__properties__.content = page.content;
this.__properties__.raw = contents; return contents;
// ANSI files // ANSI files
case 'ans': case 'ans':
@ -1069,119 +1124,146 @@ function Page(debug) {
// Our fields are sorted in x descending order // Our fields are sorted in x descending order
this.input_fields = page.input_fields.sort(function(a,b) { return a.x < b.x ? 1 : -1; }); this.input_fields = page.input_fields.sort(function(a,b) { return a.x < b.x ? 1 : -1; });
this.__properties__.raw = contents; this.raw = contents;
break; break;
// ANSItex files // ANSItex files
case 'tex': case 'tex':
case 'vtx': case 'vtx':
log(LOG_DEBUG,'|-- Processing FRAME file'); log(LOG_DEBUG,'|-- Processing FRAME file. V:'+contents.version);
try { switch (contents.version) {
for (var index in contents) { case 1:
if (FRAME_SAVE_ATTRS.indexOf(index) === -1) { try {
log(LOG_ERROR,'|-! Unknown index ['+index+'] in input.'); for (var index in contents) {
continue; if (FRAME_SAVE_ATTRS.indexOf(index) === -1) {
} log(LOG_ERROR,'|-! Unknown index ['+index+'] in input.');
continue;
log(LOG_DEBUG,'|-* Processing ['+index+'] with value ['+JSON.stringify(contents[index])+'].');
switch (index) {
case 'content':
//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);
this.__window__.body.__properties__.content = page.content;
this.dynamic_fields = page.dynamic_fields;
// Our fields are sorted in x descending order
if (page.input_fields.length)
this.input_fields = page.input_fields.sort(function(a,b) { return a.x < b.x ? 1 : -1; });
this.__properties__.raw = base64_decode(contents[index]);
break;
case 'cost':
this.cost = contents[index];
break;
case 'date':
log(LOG_INFO,'|-/ Frame date : '+contents[index]);
break;
case 'dynamic_fields':
this.dynamic_fields = contents[index];
break;
case 'frame':
this.name.frame = ''+contents[index];
break;
case 'index':
this.name.index = contents[index];
break;
case 'input_fields':
this.input_fields = contents[index];
break;
case 'isAccessible':
this.isAccessible = ((contents[index] === 1) || (contents[index] === true));
break;
case 'isPublic':
this.isPublic = ((contents[index] === 1) || (contents[index] === true));
break;
case 'key':
this.key = contents[index];
break;
case 'type':
this.type = contents[index];
break;
case 'version':
log(LOG_INFO,'|-/ Frame version : '+contents[index]);
break;
case 'window':
for (var y in contents[index]) {
//log(LOG_DEBUG,' - Y: '+y+', '+JSON.stringify(contents[index][y]));
if (contents[index][y] === null)
continue;
for (var x in contents[index][y]) {
//log(LOG_DEBUG,' - X: '+x+', '+JSON.stringify(contents[index][y][x]));
if (contents[index][y][x] === null)
continue;
this.__window__.body.__properties__.content[y][x] = new Char(
contents[index][y][x].__properties__.ch,
contents[index][y][x].__properties__.attr
);
}
} }
break; log(LOG_DEBUG,'|-* Processing ['+index+'] with value ['+JSON.stringify(contents[index])+'].');
switch (index) {
case 'content':
//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);
default: this.__window__.body.__properties__.content = page.content;
log(LOG_ERROR,'|-! Frame property not handled: '+index+', value:'+contents[index]); this.dynamic_fields = page.dynamic_fields;
// Our fields are sorted in x descending order
if (page.input_fields.length)
this.input_fields = page.input_fields.sort(function(a,b) { return a.x < b.x ? 1 : -1; });
this.raw = base64_decode(contents[index]);
break;
case 'cost':
this.cost = contents[index];
break;
case 'date':
log(LOG_INFO,'|-/ Frame date : '+contents[index]);
break;
case 'dynamic_fields':
this.dynamic_fields = contents[index];
break;
case 'frame':
this.name.frame = ''+contents[index];
break;
case 'index':
this.name.index = contents[index];
break;
case 'input_fields':
this.input_fields = contents[index];
break;
case 'isAccessible':
this.isAccessible = ((contents[index] === 1) || (contents[index] === true));
break;
case 'isPublic':
this.isPublic = ((contents[index] === 1) || (contents[index] === true));
break;
case 'key':
this.key = contents[index];
break;
case 'type':
this.type = contents[index];
break;
case 'version':
log(LOG_INFO,'|-/ Frame version : '+contents[index]);
break;
case 'window':
for (var y in contents[index]) {
//log(LOG_DEBUG,' - Y: '+y+', '+JSON.stringify(contents[index][y]));
if (contents[index][y] === null)
continue;
for (var x in contents[index][y]) {
//log(LOG_DEBUG,' - X: '+x+', '+JSON.stringify(contents[index][y][x]));
if (contents[index][y][x] === null)
continue;
this.__window__.body.__properties__.content[y][x] = new Char(
contents[index][y][x].__properties__.ch,
contents[index][y][x].__properties__.attr
);
}
}
break;
default:
log(LOG_ERROR,'|-! Frame property not handled: '+index+', value:'+contents[index]);
}
}
} catch (error) {
log(LOG_ERROR,'|-! Frame error : '+error);
// Load our system error frame.
// @todo If our system error page errors, then we go into a loop
this.get(new PageObject(FRAME_SYSTEM_ERROR));
} }
}
} catch (error) { break;
log(LOG_ERROR,'|-! Frame error : '+error);
// Load our system error frame. case 2:
// @todo If our system error page errors, then we go into a loop var page = rawtoattrs(contents.content,this.width,this.__window__.body.y,this.__window__.body.x);
this.get(new PageObject(FRAME_SYSTEM_ERROR));
return null; this.__window__.body.__properties__.content = page.content;
this.dynamic_fields = page.dynamic_fields;
// Our fields are sorted in x descending order
if (page.input_fields.length)
this.input_fields = page.input_fields.sort(function(a,b) { return a.x < b.x ? 1 : -1; });
// Work out frame type
this.attrs = contents.attrs;
this.cost = contents.cost;
this.key = contents.key;
this.raw = contents.content;
this.date = contents.date;
break;
default:
log(LOG_ERROR,'|-! Unknown frame version : '+contents.version);
this.get(new PageObject(FRAME_SYSTEM_ERROR));
return null;
} }
this.loadcomplete(); this.loadcomplete();
@ -1202,115 +1284,37 @@ function Page(debug) {
* Save the frame to the message base * Save the frame to the message base
*/ */
this.save = function() { this.save = function() {
var mb = new MsgBase(FRAMES_MSG_BASE); var msgbase = new MsgAreas().getArea(FRAMES_MSG_BASE).msgbase;
var headers;
try { if (! msgbase.open()) {
if (mb.open()) { log(LOG_ERROR,'! Message Base cannot be opened (save): ['+msgbase.error+']');
headers = mb.get_all_msg_headers(false,false) || []; return false;
} else {
log(LOG_ERROR,FRAMES_MSG_BASE+' cannot be opened:'+mb.error);
return;
}
} catch (e) {
log(LOG_ERROR,FRAMES_MSG_BASE+' cannot be opened:'+e.message);
return;
} }
// Build the save content var hdr = {
var content = {}; to: this.name,
from: 'SYSTEM',
tags: this.name,
date: strftime("%a, %d %b %Y, %I:%M:%S %Z",this.date),
subject: 'Content',
};
for (var index in FRAME_SAVE_ATTRS) { var page = {
switch (FRAME_SAVE_ATTRS[index]) { 'version': 2,
case 'cost': 'attrs': p.attrs,
content[FRAME_SAVE_ATTRS[index]] = this.cost; 'cost': p.cost,
break; 'key': p.key,
'content': p.raw,
};
case 'dynamic_fields': var body = LZString.compressToBase64(JSON.stringify(page))+EOF_MARKER;
content[FRAME_SAVE_ATTRS[index]] = this.dynamic_fields;
break;
case 'frame': if (! msgbase.save_msg(hdr,body)) {
content[FRAME_SAVE_ATTRS[index]] = this.name.frame;
break;
case 'index':
content[FRAME_SAVE_ATTRS[index]] = this.name.index;
break;
case 'input_fields':
content[FRAME_SAVE_ATTRS[index]] = this.input_fields;
break;
case 'isAccessible':
content[FRAME_SAVE_ATTRS[index]] = this.__properties__.isAccessible;
break;
case 'isPublic':
content[FRAME_SAVE_ATTRS[index]] = this.__properties__.isPublic;
break;
case 'key':
content[FRAME_SAVE_ATTRS[index]] = this.key;
break;
case 'type':
content[FRAME_SAVE_ATTRS[index]] = this.type;
break;
case 'version':
content[FRAME_SAVE_ATTRS[index]] = 1;
break;
case 'window':
content[FRAME_SAVE_ATTRS[index]] = this.__window__.body.__properties__.content;
break;
default:
log(LOG_ERROR,' ! NOTE Index ['+FRAME_SAVE_ATTRS[index]+'] has been ignored.');
continue;
}
log(LOG_DEBUG,' / Storing ['+FRAME_SAVE_ATTRS[index]+'] with value:'+content[FRAME_SAVE_ATTRS[index]]);
}
// Find existing message with the page number and delete it if defined
var msg;
for(var x in headers) {
if ((headers[x].tags === this.name.toString()) && (!(headers[x].attr&MSG_DELETE))) {
msg = headers[x];
break;
}
}
if (msg === undefined) {
log(LOG_DEBUG,' - Saving NEW frame: ['+this.name.toString()+'] to ['+FRAMES_MSG_BASE+']');
} else {
log(LOG_DEBUG,' - REPLACING frame: ['+this.name.toString()+'] at ['+msg.number+']');
if (! mb.remove_msg(msg.number))
log(LOG_ERROR,' ! Error removing frame: ['+this.name.toString()+'] to ['+msg.number+']');
}
log(LOG_DEBUG,'** Save frame with keys'+JSON.stringify(Object.keys(content)));
if (! mb.save_msg(
{
subject: this.name.toString(),
to: this.name.toString(),
from: SESSION_EXT,
tags: this.name.toString(),
},
JSON.stringify(content)
))
log(LOG_ERROR,' ! Error saving frame: ['+this.name.toString()+']'); log(LOG_ERROR,' ! Error saving frame: ['+this.name.toString()+']');
}
mb.close(); msgbase.close();
return true;
} }
this.scroll = function(x,y) { this.scroll = function(x,y) {
@ -1334,11 +1338,19 @@ function PageObject(frame,index) {
this.__properties__.frame = frame.frame.toString(); this.__properties__.frame = frame.frame.toString();
this.index = frame.index; this.index = frame.index;
} else { } else if ((frame !== undefined) && (index === undefined)) {
this.__properties__.frame = frame; if (/^\d+[a-z]$/.test(frame)) {
var split = frame.split(/(\d+)/);
this.__properties__.frame = split[1];
this.index = split[2];
if (index) } else {
this.index = index; this.__properties__.frame = frame;
}
} else if ((frame !== undefined) && (index !== undefined)) {
this.__properties__.frame = frame;
this.index = index;
} }
} }

View File

@ -1,5 +1,5 @@
const SESSION_ANSITEX = (1<<1); const SESSION_ANSITEX = (1<<1);
var SESSION_EXT = 'tex'; var CONTENT_EXT = 'ans';
var FRAME_WIDTH = 80; var FRAME_WIDTH = 80;
var FRAME_HEIGHT = 22; var FRAME_HEIGHT = 22;

View File

@ -1,5 +1,5 @@
const SESSION_VIEWDATA = (1<<2); const SESSION_VIEWDATA = (1<<2);
var SESSION_EXT = 'vtx'; var CONTENT_EXT = 'bin';
var FRAME_WIDTH = 40; var FRAME_WIDTH = 40;
var FRAME_HEIGHT = 22; var FRAME_HEIGHT = 22;

View File

@ -944,13 +944,15 @@ function Char(ch,attr) {
ansi.push(r); ansi.push(r);
} }
if (false && debug) if (debug)
writeln(' - ansi:'+ansi); writeln(' - ansi:'+ansi);
return ansi.length ? (debug ? '': '\x1b')+'['+ansi.join(';')+'m' : undefined; return ansi.length ? (debug ? '': '\x1b')+'['+ansi.join(';')+'m' : undefined;
case 'vtx': case 'vtx':
log(LOG_DEBUG,'+ last:'+last+', attr ('+this.attr+')'); if (debug)
log(LOG_DEBUG,'+ last:'+last+', attr ('+this.attr+')');
switch (this.attr) { switch (this.attr) {
// \x08 // \x08
case BLINK: case BLINK:
@ -1039,7 +1041,9 @@ function Char(ch,attr) {
} }
} }
log(LOG_DEBUG,'= result:'+r.charCodeAt(0)+', ('+r+')'); if (debug)
log(LOG_DEBUG,'= result:'+r.charCodeAt(0)+', ('+r+')');
return ESC+r; return ESC+r;
default: default:

View File

@ -42,11 +42,13 @@ bbs.replace_text(826,''); // LoggingOn
switch (client.socket.local_port) { switch (client.socket.local_port) {
case 516: case 516:
var SESSION_EXT = 'vtx';
require(ANSITEX_HOME+'/load/session/viewdata.js','SESSION_VIEWDATA'); require(ANSITEX_HOME+'/load/session/viewdata.js','SESSION_VIEWDATA');
break; break;
// Assume ANSItex // Assume ANSItex
default: default:
var SESSION_EXT = 'tex';
require(ANSITEX_HOME+'/load/session/ansitex.js','SESSION_ANSITEX'); require(ANSITEX_HOME+'/load/session/ansitex.js','SESSION_ANSITEX');
} }

1
text/980a Normal file
View File

@ -0,0 +1 @@
{"version":2,"key":[0,0,null,null,null,null,null,null,null,null]}

1
text/998a Normal file
View File

@ -0,0 +1 @@
{"version":2,"key":[0,null,null,null,null,null,null,null,null,null]}

1
text/99a Normal file
View File

@ -0,0 +1 @@
{"version":2,"key":[0,null,null,null,null,null,null,null,null,null]}

1
text/99b Normal file
View File

@ -0,0 +1 @@
{"version":2,"attrs":"15","key":[null,null,null,null,null,null,null,null,null,null]}

View File

@ -1 +0,0 @@
{"version":1,"frame":"980","index":"a","owner":9,"cost":0,"content":"G1swbSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIBtbMzFt2sQbWzFt3BtbMDszMm3axBtbMW3cG1swOzM0bdrEG1sxbdwbWzA7MzZtIBtbMTszM23fG1swbSAbWzMwOzQ3bdrC3NrE3Nog3CAbWzM3OzQwbQ0KIBtbMW3aIL/Cv7Pav9q/2sK/wr8bWzBtICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAbWzE7MzFtsxtbMDszMW3f2xtbMTszMm2zG1swOzM2bSAbWzMybdsbWzE7MzRtLlwbWzA7MzRt3BtbMzNt3htbMW3bG1swbSAbWzMwOzQ3bSCzIMNf3Nrf3CAbWzM3OzQwbQ0KILOzs8PZs7Mgs7OzILPD2SAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgG1sxOzMwbcTExMTExMTExMTExBtbMDszMDs0N23c3Nzc3Nzc3NzcG1szNzs0MG0NCiAbWzE7MzBtwMHZwdnAwNnA2cAg2cHZG1swbSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAbWzE7MzBtbm9kZTobWzBtIBtbMTszMm0bWG5vZGVpZDstMTEbXBtbMzRtDQobWzBtICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAbWzE7MzBtZGF0ZTobWzA7MzJtIBtbMW0bWERBVEU6JVktJWItJWQ7LTExG1wbWzBtDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIBtbMTszMG10aW1lOiAbWzMybRtYVElNRTstMTEbXBtbMG0NCg0KIBtbMW1XZWxjb21lLCB5b3UgaGF2ZSBjb25uZWN0ZWQgdG8gG1szMW1BG1szMm1OG1szNG1TG1szM21JG1swOzMwOzQ3bXRleBtbMTszNzs0MG0gYSBCQlMgdGhhdCBpcyBiYXNlZCBvbiB0aGUbWzBtDQogG1sxbTE5ODAncyBWaWRlb3RleCBzZXJ2aWNlLCBidXQgdXNpbmcgQU5TSS4bWzBtDQoNCiAbWzFtRGVwZW5kaW5nIG9uIHdoaWNoIGNvdW50cnkgeW91IGxpdmUgaW4gdGhlIFZpZGVvdGV4IHNlcnZpY2Ugd2FzIGNhbGxlZBtbMG0NCiAbWzFtVmlhdGVsIChBVSksIFByZXN0ZWwgKFVLKSwgTWluaXRleCAoRlIpLCBUZWxpZG9uIChDQSksIEliZXJ0ZXggKFNQKSwgZXRjG1swbQ0KG1sxbQ0KG1swbSAbWzFtSWYgeW91IGdvdCBoZXJlIGJ5IG1pc3Rha2UsIHlvdSBzaG91bGQgZGlzY29ubmVjdCBub3csIG90aGVyd2lzZSwgeW91IGNhbhtbMG0NChtbMW0gcHJlc3MbWzBtIBtbMTs1OzMybTAbWzA7MW0gdG8gZ2V0IHRvIHRoZSBsb2dpbiBzY3JlZW4uG1swbQ0KG1sxbQ0KG1swbQ0K","isPublic":1,"isAccessible":1,"type":"i","key":[0,982,null,null,null,null,null,null,null,null],"date":"2020-07-05T12:57:03.790Z"}

View File

@ -1 +0,0 @@
{"version":1,"frame":998,"index":"a","owner":9,"cost":0,"content":"G1swbRtbMzFt2sQbWzFt3BtbMDszMm3axBtbMW3cG1swOzM0bdrEG1sxbdwbWzA7MzZtIBtbMTszM23fG1swbSAbWzMwOzQ3bdrC3NrE3Nog3CAbWzM3OzQwbQ0KG1sxOzMxbbMbWzA7MzFt39sbWzE7MzJtsxtbMDszNm0gG1szMm3bG1sxOzM0bS5cG1swOzM0bdwbWzMzbd4bWzFt2xtbMG0gG1szMDs0N20gsyDDX9za39wgG1szNzs0MG0NChtbMTszMG3ExMTExMTExMTExMQbWzA7MzA7NDdt3Nzc3Nzc3Nzc3BtbMzc7NDBtDQoNChtbMW1IbW0sIGEgc3lzdGVtIBtbMzFtRVJST1IbWzM3bSBvY2N1cnJlZC4bWzBtDQobWzFtTm9kZSAgOiAbWzMxbRtYbm9kZWlkOzgbXBtbMG0NChtbMW1TeXN0ZW06IBtbMzFtG1hCQlM7MTAbXBtbMG0NCg0KG1sxbUlmIHRoaXMga2VlcHMgaGFwcGVuaW5nLCB5b3UgbWF5IG5lZWQgdG8gdGVsbCB0aGUgc3lzdGVtIGFkbWluaXN0cmF0b3IbWzBtDQobWzFtdmlhIHBhZ2UgG1szMm0qMDgbWzBtDQoNChtbMW1UbyB0cnkgYWdhaW4sIHBsZWFzZSBwcmVzcyAbWzMybTAbWzBtDQo=","isPublic":1,"isAccessible":1,"type":"i","key":[0,null,null,null,null,null,null,null,null,null],"date":"2021-02-18T00:52:54.117Z"}

View File

@ -1 +0,0 @@
{"version":1,"frame":99,"index":"a","owner":9,"cost":0,"content":"G1swbSAgICAgICAgG1sxbdq/G1swbSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgG1szMW3axBtbMW3cG1swOzMybdrEG1sxbdwbWzA7MzRt2sQbWzFt3BtbMDszNm0gG1sxOzMzbd8bWzBtIBtbMzA7NDdt2sLc2sTc2iDcIBtbMzc7NDBtDQogG1sxbcK/2r/av9q0w7+/2sK/G1swbSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIBtbMTszMW2zG1swOzMxbd/bG1sxOzMybbMbWzA7MzZtIBtbMzJt2xtbMTszNG0uXBtbMDszNG3cG1szM23eG1sxbdsbWzBtIBtbMzA7NDdtILMgw1/c2t/cIBtbMzc7NDBtDQogs7Ozs7Ozs7Ozs7Ozw9kgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAbWzE7MzBtxMTExMTExMTExMTEG1swOzMwOzQ3bdzc3Nzc3Nzc3NwbWzM3OzQwbQ0KIBtbMTszMG3BtMDZwNnA2cDZwLTB2RtbMG0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIBtbMTszMG1ub2RlOhtbMG0gG1sxOzMybRtYbm9kZWlkOy0xMRtcG1swbQ0KIBtbMTszMG3E2RtbMzFtICAgICAgICAbWzMwbcTZG1swbSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAbWzE7MzBtZGF0ZTobWzBtIBtbMTszMm0bWERBVEU6JVktJWItJWQ7LTExG1wbWzBtDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIBtbMTszMG10aW1lOhtbMG0gG1sxOzMybRtYVElNRTstMTEbXBtbMG0NCg0KIFlvdSBhcmUgYWJvdXQgdG8gZGlzY29ubmVjdCBmcm9tIBtbMTszMW1BG1szMm1OG1szNG1TG1szM21JG1swOzMwOzQ3bXRleBtbMzc7NDBtIBtbMW0bWFJFQUxOQU1FOzIwG1wbWzBtDQoNCiBJZiB5b3Ugd2FudGVkIHRvIHN0YXkgb25saW5lLCB5b3UgY2FuIHByZXNzIBtbMTszMm0qMCMbWzBtIHRvIGdldCBiYWNrIHRvIHRoZSBtYWluIG1lbnUNCg0KIE90aGVyd2lzZSBwcmVzcyAbWzE7NTszMm0jG1swOzE7MzNtIBtbMG10byBkaXNjb25uZWN0IG5vdy4NCg0KDQoNCg0KDQoNCg0KDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIBtbMTs1OzMybSowIxtbMDsxbSB0byBnZXQgYmFjayB0byB0aGUgTWFpbiBNZW51G1swbQ0K","isPublic":1,"isAccessible":1,"type":"i","key":[0,null,null,null,null,null,null,null,null,null],"date":"2020-07-15T12:15:47.742Z"}

View File

@ -1 +0,0 @@
{"version":1,"frame":99,"index":"b","owner":9,"cost":0,"content":"G1swbSAgICAgICAgG1sxbdq/G1swbSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgG1szMW3axBtbMW3cG1swOzMybdrEG1sxbdwbWzA7MzRt2sQbWzFt3BtbMDszNm0gG1sxOzMzbd8bWzBtIBtbMzA7NDdt2sLc2sTc2iDcIBtbMzc7NDBtDQogG1sxbcK/2r/av9q0w7+/2sK/G1swbSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIBtbMTszMW2zG1swOzMxbd/bG1sxOzMybbMbWzA7MzZtIBtbMzJt2xtbMTszNG0uXBtbMDszNG3cG1szM23eG1sxbdsbWzBtIBtbMzA7NDdtILMgw1/c2t/cIBtbMzc7NDBtDQogs7Ozs7Ozs7Ozs7Ozw9kgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAbWzE7MzBtxMTExMTExMTExMTEG1swOzMwOzQ3bdzc3Nzc3Nzc3NwbWzM3OzQwbQ0KIBtbMTszMG3BtMDZwNnA2cDZwLTB2RtbMG0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIBtbMTszMG1ub2RlOhtbMG0gG1sxOzMybRtYbm9kZWlkOy0xMRtcG1swbSAgG1sxOzMwbcTZG1szMW0gICAgICAgIBtbMzBtxNkbWzBtICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIBtbMTszMG1kYXRlOhtbMG0gG1sxOzMybRtYREFURTolWS0lYi0lZDstMTEbXBtbMG0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAbWzE7MzBtdGltZTobWzBtIBtbMTszMm0bWFRJTUU7LTExG1wbWzBtDQoNCiBUaGFua3MgZm9yIHZpc2l0aW5nIBtbMTszMW1BG1szMm1OG1szNG1TG1szM21JG1swOzMwOzQ3bXRleBtbMzc7NDBtIBtbMW0bWFJFQUxOQU1FOzIwG1wbWzBtDQoNCiBIb3BlIHRvIHNlZSB5b3UgYWdhaW4uLi4NCg==","isPublic":1,"isAccessible":1,"type":"t","key":[1,null,null,null,null,null,null,null,null,null],"date":"2020-07-08T01:48:01.797Z"}

View File

@ -1 +0,0 @@
{"version":1,"frame":"980","index":"a","owner":9,"cost":0,"content":"ESxsEnxsFHwsEywXN2t/IzM3ayM1ICAgICAgICAgICAgICAgICAgIBF/axJ/ahQvfBN/FzVobyA8PSQsNSAgICAgICAgICAgICAgICAgICARLy4SLyoULC8TLxd1cHpwcXV6cDUgICAgICAgICAgICAgICAgICAgIFZpZGVvdGV4ICAgICAgICAgICAgICAgICAgICAgIA1XZWxjb21lICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFdlbGNvbWUsIHlvdSBoYXZlIGNvbm5lY3RlZCB0byAgICAgICAgIAFBAk4DUwRJB3RleCBhIEJCUyB0aGF0IGlzIGJhc2VkIG9uIHRoZSAgMTk4MCdzIFZpZGVvdGV4IHNlcnZpY2UuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBEZXBlbmRpbmcgb24gd2hpY2ggY291bnRyeSB5b3UgbGl2ZSBpbiAgdGhlIFZpZGVvdGV4IHNlcnZpY2Ugd2FzIGNhbGxlZCBWaWF0ZWwgIChBVSksIFByZXN0ZWwgKFVLKSwgTWluaXRlbCAoRlIpLCAgICAgICBUZWxpZG9uIChDQSksIEliZXJ0ZXggKFNQKSwgZXRjICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIElmIHlvdSBnb3QgaGVyZSBieSBtaXN0YWtlLCB5b3Ugc2hvdWxkICBkaXNjb25uZWN0IG5vdywgb3RoZXJ3aXNlIHlvdSBjYW4gICAgICAgcHJlc3MCMAd0byBnZXQgdG8gdGhlIGxvZ2luIHNjcmVlbi4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBUbyBsb2dpbiB1c2luZyBTUVJMLCBwcmVzcwIx","isPublic":1,"isAccessible":1,"type":"i","key":[0,982,null,null,null,null,null,null,null,null],"date":"2020-07-05T12:57:03.790Z"}

View File

@ -1 +0,0 @@
{"version":1,"frame":998,"index":"a","owner":9,"cost":0,"content":"ICARLGwSfGwUfCwTLBc3a38jMzdrIzUgICAgICACMDAwMTAwMDEwMSAgEX9rEn9qFC98E38XNWhvIDw9JCw1ByAgICAgICAgICAgICAgICAgIBEvLhIvKhQsLxMvF3VwenBxdXpwNSAgICAgICAgICAgICAgICAgICAgVmlkZW90ZXggICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBIbW0sIGFuAQ1FcnJvcgwHb2NjdXJyZWQuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIElmIHRoaXMga2VlcHMgaGFwcGVuaW5nLCB5b3UgbWF5IGxpa2UgICB0byB0ZWxsIHRoZSBzeXN0ZW0gYWRtaW5pc3RyYXRvciB2aWEgICAgcGFnZQIqMDggICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUHJlc3MCMAd0byByZXR1cm4gdG8gdGhlIG1haW4gbWVudS4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIA==","isPublic":1,"isAccessible":1,"type":"i","key":[0,null,null,null,null,null,null,null,null,null],"frame_fields": [],"date":"2020-08-09T11:42:40.643Z"}

View File

@ -1 +0,0 @@
{"version":1,"frame":99,"index":"a","owner":9,"cost":0,"content":"Fzcrby8/Py9vICAgICAgICAgIBEsbBJ8bBR8LBMsFzdrfyMzN2sjNRc1amogJTVzeiAgICAgICAgICARf2sSf2oUL3wTfxc1aG8gPD0kLDUXdXJ6c3F1c3ogICAgICAgICAgES8uEi8qFCwvEy8XdXB6cHF1enA1ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFZpZGVvdGV4ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgWW91IGFyZSBhYm91dCB0bwFkaXNjb25uZWN0B2Zyb20gICAgICAgAUECTgRTA0kHdGV4LiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVG8gaGVhZCBiYWNrIHRvIHRoZSBtYWluIG1lbnUsIHBsZWFzZSAgIHVzZQIqMF8HICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgT3RoZXJ3aXNlIHRvIGRpc2Nvbm5lY3QgcHJlc3MCXyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIA1UaGFua3MgZm9yIGNhbGxpbmcgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIA==","isPublic":1,"isAccessible":1,"type":"i","key":[0,null,null,null,null,null,null,null,null,null],"date":"2020-07-15T12:15:47.742Z"}

View File

@ -1 +0,0 @@
{"version":1,"frame":99,"index":"b","owner":9,"cost":0,"content":"Fzcrby8/Py9vICAgICAgICAgIBEsbBJ8bBR8LBMsFzdrfyMzN2sjNRc1amogJTVzeiAgICAgICAgICARf2sSf2oUL3wTfxc1aG8gPD0kLDUXdXJ6c3F1c3ogICAgICAgICAgES8uEi8qFCwvEy8XdXB6cHF1enA1ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFZpZGVvdGV4ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICANVGhhbmtzIGZvciBjYWxsaW5nICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgSG9wZSB0byBzZWUgeW91IGFnYWluLiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAo=","isPublic":1,"isAccessible":1,"type":"t","key":[1,null,null,null,null,null,null,null,null,null],"date":"2020-07-08T01:48:01.797Z"}

37
tools/clear_tags.js Normal file
View File

@ -0,0 +1,37 @@
/** CLEAR ALL THE TAGS IN A MESSAGE BASE */
load('ansitex/load/msgbases.js');
if (argv.length !== 1) {
writeln('ERROR: Need a msgbase page prefix');
exit(1);
} else {
writeln('Showing frames in:'+argv[0]);
}
var ma = new MsgAreas();
var area = ma.getArea(argv[0]);
writeln('Opening ['+argv[0]+'] - ('+area.code+')');
var msgbase = area.msgbase;
msgbase.open();
writeln('- First:'+msgbase.first_msg);
writeln('- Last:'+msgbase.last_msg);
var msgs = msgbase.get_all_msg_headers(false,false) || [];
for (var x in msgs) {
if (! msgs[x].tags)
continue;
writeln('TAG was:'+msgs[x].tags);
msgs[x].tags = '';
if (! msgbase.put_msg_header(msgs[x].number,msgs[x]))
writeln('ERROR:'+msgbase.error);
}
msgbase.close();

31
tools/frame_get.js Normal file
View File

@ -0,0 +1,31 @@
load('ansitex/load/page.js');
load('ansitex/load/funcs.js');
load('ansitex/load/session/ansitex.js');
load('lz-string.js');
if (argv.length !== 1) {
writeln('ERROR: Need a frame ID');
exit(1);
} else {
writeln('Showing frame:'+argv[0]);
}
const SESSION_EXT = 'tex';
var p = new Page();
var po = new PageObject(argv[0]);
if (p.get(po)) {
writeln('Page : '+p.name);
writeln('- Cost : '+p.cost);
writeln('- Owner : '+p.owner);
writeln('- Key : '+p.key);
writeln('- Type : '+p.type);
writeln('- CUG : '+p.cug);
writeln('- isPublic: '+p.isPublic);
writeln('- isAccess: '+p.accessible);
} else {
writeln('Failed to load:'+argv[0]);
}

32
tools/frame_import.js Normal file
View File

@ -0,0 +1,32 @@
/**
* Load a frame, and store it in the message base
*/
load('ansitex/load/page.js');
load('ansitex/load/funcs.js');
load('lz-string.js');
/* parse command arguments */
if (argv.length !== 1) {
writeln('ERROR: Need a frame ID');
exit(1);
} else {
writeln('Importing frame:'+argv[0]);
}
var po = new PageObject(argv[0]);
// Load ANSItex frame
var SESSION_EXT = 'tex';
require('ansitex/load/session/ansitex.js','SESSION_ANSITEX');
var p = new Page();
p.get(po);
// Load Viewdata frame
var SESSION_EXT = 'vtx';
require('ansitex/load/session/viewdata.js','SESSION_VIEWDATA');
p.raw = p.file_content(FRAMES_HOME+SESSION_EXT+'/'+po.toString()+'.'+CONTENT_EXT);
p.save();

View File

@ -1,42 +0,0 @@
/**
* Load a frame, optionally with a new ANSI/BIN and load it into the msgbase.
*/
load('ansitex/load/funcs.js');
// Our page handler
load('ansitex/load/page.js');
/* parse command arguments */
if (argv.length !== 3) {
writeln('! ERROR: Need 3 arguments only');
exit(1);
}
var frame = argv.shift();
var index = argv.shift();
var file = argv.shift();
var ext = file_getext(file).substr(1).toLowerCase();
// Type of frame to load
switch (ext) {
case 'tex':
case 'ans':
require('ansitex/load/session/ansitex.js','SESSION_ANSITEX');
break;
case 'vtx':
case 'bin':
require('ansitex/load/session/viewdata.js','SESSION_VIEWDATA');
break;
}
var page = new Page();
if (page.get(new PageObject(frame,index))) {
page.import(file,ext);
page.save();
} else if (['vtx','tex'].indexOf(ext) !== -1) {
page.import(file,ext);
page.save();
}

View File

@ -1,144 +0,0 @@
/**
* This will go through our videotex and ansitex frames and check for inconsistencies.
*
* We'll check for:
* + Mismatched metadata items
* + Out of sync content
*/
load('ansitex/load/funcs.js');
// Our page handler
load('ansitex/load/page.js');
/* parse command arguments */
if (argv.length !== 1) {
writeln('! ERROR: Need only 1 argument');
exit(1);
}
//const vtx_ext = 'tex';
const vtx_src = 'bin';
const tex_src = 'ans';
const page = argv.shift();
const vtx_srcname = page+'.'+vtx_src;
const tex_srcname = page+'.'+tex_src;
var errors = false;
PAGE_FILE_PREFX = /^[0-9]+[a-z]$/;
if (! PAGE_FILE_PREFX.test(page)) {
writeln('PAGE is not a frame: '+page);
exit(2);
}
writeln('Comparing Frame: '+page);
// Load frame
require(ANSITEX_HOME+'/load/session/viewdata.js','SESSION_VIEWDATA');
vtx = new Page();
if (! vtx.import(FRAMES_HOME+SESSION_EXT+'/'+page)) {
writeln('- ! ERROR: VTX File doesnt exist? :'+page);
errors = true;
} else {
// Check content between TEX/ANS & VTX/BIN
vtx_srcfile = new File(FRAMES_HOME+SESSION_EXT+'/'+vtx_srcname);
if (! vtx_srcfile.exists || ! vtx_srcfile.open('r')) {
writeln('- ! ERROR: VTX SRC File doesnt exist? :'+vtx_srcname);
errors = true;
} else {
writeln('- LOADING: VTX Source :'+vtx_srcname);
var x = md5_calc(vtx.raw);
var y = md5_calc(vtx_srcfile.read());
// Check Content
if (x !== y) {
writeln(' - Page Content :'+x);
writeln(' - Source Content :'+y);
writeln('- ! WARNING: Content Differs.');
errors = true;
} else {
writeln('= Source matches.');
}
}
}
require(ANSITEX_HOME+'/load/session/ansitex.js','SESSION_ANSITEX');
tex = new Page();
if (! tex.import(FRAMES_HOME+SESSION_EXT+'/'+page)) {
writeln('- ! ERROR: TEX File doesnt exist? :'+page);
errors = true;
} else {
// Check content between TEX/ANS & VTX/BIN
tex_srcfile = new File(FRAMES_HOME+SESSION_EXT+'/'+tex_srcname);
if (! tex_srcfile.exists || ! tex_srcfile.open('r')) {
writeln('- ! ERROR: TEX SRC File doesnt exist? :'+tex_srcname);
errors = true;
} else {
writeln('- LOADING: TEX Source :'+tex_srcname);
var x = md5_calc(tex.raw);
var y = md5_calc(tex_srcfile.read());
if (x !== y) {
// Check Content
writeln(' - Page Content :'+x);
writeln(' - Source Content :'+y);
writeln('- ! WARNING: Content Differs.');
errors = true;
} else {
writeln('= Source matches.');
}
}
}
// Checking keys
if (vtx.raw && tex.raw) {
writeln('- Checking Page: ');
if (vtx.name.toString() !== tex.name.toString()) {
writeln(' - ! VTX: '+vtx.name.toString());
writeln(' - ! TEX: '+tex.name.toString());
} else {
writeln(' = PAGE: '+vtx.name.toString());
}
for each (var k in ['key','cost','type']) {
writeln('- Checking KEY: '+k);
if (JSON.stringify(vtx[k]) !== JSON.stringify(tex[k])) {
writeln(' - ! VTX: '+vtx[k]);
writeln(' - ! TEX: '+tex[k]);
errors = true;
} else {
writeln(' = KEY: '+vtx[k]);
}
}
for each (var k in ['isAccessible','isPublic']) {
writeln('- Checking Property: '+k);
if (JSON.stringify(vtx.__properties__[k]) !== JSON.stringify(tex.__properties__[k])) {
writeln(' - ! VTX: '+vtx.__properties__[k]);
writeln(' - ! TEX: '+tex.__properties__[k]);
errors = true;
} else {
writeln(' = KEY: '+vtx.__properties__[k]);
}
}
}
if (errors)
exit(1);
else
writeln('= OK');

View File

@ -1,19 +1,26 @@
load('load/string.js'); load('ansitex/load/funcs.js');
load('load/funcs.js');
load('ansitex/load/msgbases.js'); load('ansitex/load/msgbases.js');
if (argv.length !== 1) { if (argv.length !== 1) {
writeln('ERROR: Need a msgbase page prefix'); writeln('ERROR: Need a msgbase page prefix');
exit(1); exit(1);
} else {
writeln('Showing frames in:'+argv[0]);
} }
ma = new MsgAreas(); var ma = new MsgAreas();
area = ma.getArea(argv[0]); var area = ma.getArea(argv[0]);
writeln('Opening ['+argv[0]+'] - ('+area.msgbase.cfg.code+')'); writeln('Opening ['+argv[0]+'] - ('+area.code+')');
writeln('- First:'+area.msgbase.first_msg);
writeln('- Last:'+area.msgbase.last_msg);
for (var x in area.headers) { var msgbase = area.msgbase;
writeln(padright(area.headers[x].number,4,' ')+':'+area.headers[x].tags); msgbase.open();
} writeln('- First:'+msgbase.first_msg);
writeln('- Last:'+msgbase.last_msg);
writeln('- Next:'+area.page_next);
msgbase.close();
var frames = area.frames;
for (var x in frames)
writeln(padright(frames[x].number,4,' ')+':'+frames[x].tags);

View File

@ -1,20 +1,26 @@
load('ansitex/load/msgbases.js');
/** /**
* Go through our messages and tag a frame id for messages without one. * Go through our messages and tag a frame id for messages without one.
* @note: May need to run jsexec with -m 32MB to overcome memory issues * @note: May need to run jsexec with -m 32MB to overcome memory issues
*/ */
load('load/string.js');
load('ansitex/load/msgbases.js');
const ma = new MsgAreas() const ma = new MsgAreas()
for (var i=0;i<ma.areas.length;i++) { var areas = ma.managed;
if (argv[0] && (argv[0] !== ma.areas[i].msgbase.cfg.code))
for (var i=0;i<areas.length;i++) {
if (argv[0] && ((argv[0] !== areas[i].code) && (argv[0] !== areas[i].page_prefix)))
continue; continue;
writeln('Area : '+ma.areas[i].full_name); var total = areas[i].total_msgs;
writeln('Total Messages : '+ma.areas[i].headers.length); var frames = areas[i].frames.length;
writeln('- Tagged Messages : '+ma.areas[i].list_tagged.length);
writeln('- Untagged Messages: '+ma.areas[i].list_untagged.length);
ma.areas[i].tag_msgs(); writeln('Area : '+areas[i].full_name);
writeln('- Total Messages : '+total);
writeln('- Page Prefix : '+areas[i].page_prefix);
writeln('- Tagged Messages : '+frames);
writeln('- Untagged Messages: '+(total-frames));
writeln('- Next Tag : '+areas[i].page_next);
areas[i].tag_msgs();
} }

View File

@ -1,4 +1,5 @@
load('ansitex/load/msgbases.js'); load('ansitex/load/msgbases.js');
/* Show a list of our message bases */
var ma = new MsgAreas(); var ma = new MsgAreas();
ma.list; ma.list;