Compare commits
No commits in common. "df1bad1c29bebcfe117942822eadb7ba19cc2111" and "4cbd37f8809b382a9f3e8c4c49f11533dde40d1b" have entirely different histories.
df1bad1c29
...
4cbd37f880
39
load/defs.js
39
load/defs.js
@ -1,8 +1,3 @@
|
||||
require('smbdefs.js','MSG_DELETE');
|
||||
require('sbbsdefs.js','SUB_FIDO');
|
||||
load('string.js');
|
||||
load('lz-string.js');
|
||||
|
||||
/**
|
||||
* ANSItex definitions
|
||||
*/
|
||||
@ -16,9 +11,6 @@ const FRAMES_MSG_BASE = 'vtx_data';
|
||||
/* Load frames from files */
|
||||
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 */
|
||||
const FRAME_COSTUNIT = 'c';
|
||||
|
||||
@ -59,22 +51,21 @@ const MODE_RFSENT = 5;
|
||||
const MODE_RFERROR = 6;
|
||||
|
||||
/** FRAME TYPES **/
|
||||
// @todo Change these to bits
|
||||
|
||||
/* Information Frame, requires no response after viewed */
|
||||
const FRAME_TYPE_INFO = 0; //'i';
|
||||
const FRAME_TYPE_INFO = 'i';
|
||||
/* Terminate Frame, contents displayed and then carrier dropped */
|
||||
const FRAME_TYPE_TERMINATE = 15; //'t';
|
||||
const FRAME_TYPE_TERMINATE = 't';
|
||||
/**
|
||||
* Frame the calls an External Method
|
||||
* Contents indicate the method to be called with arguments
|
||||
*/
|
||||
const FRAME_TYPE_EXTERNAL = 13; //'x';
|
||||
const FRAME_TYPE_EXTERNAL = 'x';
|
||||
/**
|
||||
* Frame calls a door
|
||||
* Contents indicate the name of the door
|
||||
*/
|
||||
const FRAME_TYPE_DOOR = 11; //'X';
|
||||
const FRAME_TYPE_DOOR = 'X';
|
||||
/**
|
||||
* Frame renders a BBS from sbbslist
|
||||
* Contents can be:
|
||||
@ -86,13 +77,13 @@ const FRAME_TYPE_BBS = 'b';
|
||||
* 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
|
||||
*/
|
||||
const FRAME_TYPE_RESPONSE = 1; //'r';
|
||||
const FRAME_TYPE_RESPONSE = 'r';
|
||||
/* Login frame, enables the user to authenticate to the system, or to a CUG */
|
||||
const FRAME_TYPE_LOGIN = 12; //'l';
|
||||
const FRAME_TYPE_LOGIN = 'l';
|
||||
/* Mail template frames - mail templates will have the user's stats for the area passed to render() */
|
||||
const FRAME_TYPE_MAIL_TEMPLATE = 'm';
|
||||
/* Frame is a message */
|
||||
const FRAME_TYPE_MESSAGE = 2; // 'M';
|
||||
const FRAME_TYPE_MESSAGE = 'M';
|
||||
|
||||
/* Disable *# going backwards for the following frames */
|
||||
const FRAMES_NO_HISTORY = ['980a','98b','981a','982a','983a','998a'];
|
||||
@ -129,16 +120,14 @@ const FRAME_SYSTEM_ERROR = {frame: '998',index: 'a'};
|
||||
const FRAME_SAVE_ATTRS = [
|
||||
'content', // raw source content of a frame (as stored in vtx/tex files)
|
||||
'cost', // integer, frame cost
|
||||
'date', // date, date frame created
|
||||
'dynamic_fields', // array of fields // @todo deprecate and work these out when loading and parsing a frame
|
||||
'dynamic_fields', // array of fields
|
||||
'frame', // Page ID,
|
||||
'index', // Page index,
|
||||
'input_fields', // array of fields // @todo deprecate and work these out when loading and parsing a frame
|
||||
'isAccessible', // boolean // @todo deprecate and merge into 'state'
|
||||
'isPublic', // boolean // @todo deprecate and merge into 'state'
|
||||
'key', // array, representing our key actions (0-9)
|
||||
'state', // integer, representing type, accessible and public status
|
||||
'type', // frame type // @todo deprecate and merge into 'state'
|
||||
'input_fields', // array of fields
|
||||
'isAccessible', // boolean
|
||||
'isPublic', // boolean
|
||||
'key', // array, representing our key actions
|
||||
'type', // frame type
|
||||
'version', // frame version (1)
|
||||
'window' // processed frame data
|
||||
];
|
||||
@ -149,7 +138,7 @@ const MAIL_TEMPLATE_FRAME = {frame: '199',index: 'a'};
|
||||
/* The page that has our echomail area summary template */
|
||||
const MAIL_TEMPLATE_AREA_SUMMARY = {frame: '198',index: 'a'};
|
||||
|
||||
// The maximum size (length) of embedded dynamic fields in frames
|
||||
// The maximum size of embedded dynamic fields in frames
|
||||
const DYNAMIC_FIELD_SIZE_MAX = 50;
|
||||
|
||||
/** ESCAPE CODES **/
|
||||
|
896
load/msgbases.js
896
load/msgbases.js
@ -1,189 +1,98 @@
|
||||
'use strict';
|
||||
require('ansitex/load/defs.js','ANSITEX_HOME');
|
||||
const PAGE_LENGTH = 4; // The size of our page tag as stored in the msgbase for echomail/netmail
|
||||
const PAGE_LAST_KEY = 'last_page'; // Last page which has the latest message
|
||||
const MAX_PAGE_NUM = 9999; // Maximum page number. @todo Can this be changed to '9'.repeat(PAGE_LENGTH)?
|
||||
|
||||
// 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
|
||||
*/
|
||||
// Our message bases
|
||||
function MsgAreas() {
|
||||
this.areas = []; // Message areas
|
||||
'use strict';
|
||||
|
||||
this.areas = [];
|
||||
this.areas_excluded = [];
|
||||
var zone_id;
|
||||
var zone_name;
|
||||
var ma;
|
||||
|
||||
// Load the message areas
|
||||
for (var g in msg_area.grp_list) {
|
||||
for (var a in msg_area.grp_list[g].sub_list) {
|
||||
//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 g in msg_area.grp_list) {
|
||||
if (msg_area.grp_list[g].name.indexOf(':') !== -1) {
|
||||
zone_id = msg_area.grp_list[g].name.split(':')[0];
|
||||
zone_name = msg_area.grp_list[g].name.split(':')[1];
|
||||
|
||||
for (var a in msg_area.grp_list[g].sub_list) {
|
||||
if (msg_area.grp_list[g].sub_list[a].name.indexOf(':') !== -1) {
|
||||
var sublist = msg_area.grp_list[g].sub_list[a].name.split(':');
|
||||
ma.area_id = sublist[0];
|
||||
ma.area_name = sublist[1];
|
||||
ma = new MsgArea();
|
||||
ma.zone_id = zone_id;
|
||||
ma.zone_name = zone_name;
|
||||
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;
|
||||
|
||||
/*
|
||||
writeln(' code:'+ma.code);
|
||||
writeln(' fullname:'+ma.full_name);
|
||||
writeln(' pageprefix:'+ma.page_prefix)
|
||||
writeln();
|
||||
*/
|
||||
this.areas.push(ma);
|
||||
} else {
|
||||
this.areas_excluded.push(zone_name+':'+msg_area.grp_list[g].sub_list[a].name);
|
||||
}
|
||||
}
|
||||
|
||||
this.areas.push(ma);
|
||||
} else {
|
||||
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',{
|
||||
get: function() {
|
||||
var areas = this.managed;
|
||||
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; })) {
|
||||
writeln(x+':'+areas[x].code+' prefix:'+areas[x].page_prefix);
|
||||
writeln('Areas that we are NOT managing mail:'+this.areas_excluded.length);
|
||||
writeln('Areas that we ARE managing mail:'+this.areas.length);
|
||||
|
||||
for(var x in this.areas_excluded) {
|
||||
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() {
|
||||
this.zone_id = undefined; // Zone this message area belongs to, eg: 0516
|
||||
this.zone_name = undefined; // Zone Name, eg: VIDEOTEX
|
||||
this.area_id = undefined; // Sub Area ID for this message area, eg: 01
|
||||
this.area_name = undefined; // Sub Area Name for this message area, eg: CHAT
|
||||
this.group_id = undefined; // SBBS Message Group ID
|
||||
this.sub_id = undefined; // SBBS Message Sub ID
|
||||
this.zone_id = undefined;
|
||||
this.zone_name = undefined;
|
||||
this.area_id = undefined;
|
||||
this.area_name = undefined;
|
||||
this.msgbase = undefined;
|
||||
this.headers = undefined;
|
||||
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',{
|
||||
get: function() {
|
||||
//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 = [];
|
||||
set: function(code) {
|
||||
this.msgbase = new MsgBase(code);
|
||||
|
||||
try {
|
||||
if (msgbase.open()) {
|
||||
var headers = msgbase.get_all_msg_headers(false,false) || [];
|
||||
if (this.msgbase.open()) {
|
||||
headers = this.msgbase.get_all_msg_headers(false,false) || [];
|
||||
|
||||
for (var i in headers) {
|
||||
if ((! (headers[i].attr&MSG_DELETE)) && headers[i].tags && ((! regex) || regex.test(headers[i].tags)))
|
||||
frames.push(headers[i]);
|
||||
}
|
||||
// Just take the last MAX_MESSAGES
|
||||
this.headers = Object.keys(headers).slice(-(MAX_PAGE_NUM+1)).map(function(key) { return headers[key]; });
|
||||
headers = undefined;
|
||||
|
||||
msgbase.close();
|
||||
this.msgbase.close();
|
||||
|
||||
} else {
|
||||
writeln('*** NOPE WONT OPEN msgbase:'+JSON.stringify(msgbase));
|
||||
log(LOG_ERROR,code+' cannot be opened:'+this.msgbase.error);
|
||||
this.headers = [];
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
log(LOG_ERROR,this.code+' cannot be opened (frames):'+e.message);
|
||||
|
||||
return undefined;
|
||||
log(LOG_ERROR,code+' cannot be opened:'+e.message);
|
||||
this.headers = [];
|
||||
}
|
||||
|
||||
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;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@ -194,7 +103,6 @@ function MsgArea() {
|
||||
}
|
||||
});
|
||||
|
||||
// @deprecated use frames instead
|
||||
// Total tagged messages
|
||||
Object.defineProperty(this,'list_tagged',{
|
||||
get: function() {
|
||||
@ -216,105 +124,42 @@ function MsgArea() {
|
||||
}
|
||||
});
|
||||
|
||||
// Retrieve the last tagged frame
|
||||
Object.defineProperty(this,'last_tagged_message',{
|
||||
// List untagged messages
|
||||
Object.defineProperty(this,'list_untagged',{
|
||||
get: function() {
|
||||
var last_tag = this.frames.sort(function(a,b) {
|
||||
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.untagged_list === undefined) {
|
||||
this.untagged_list = [];
|
||||
|
||||
if (last_tag === undefined)
|
||||
return undefined;
|
||||
if (! this.headers)
|
||||
return this.untagged_list;
|
||||
|
||||
var msgbase = new MsgAreas().getArea(FRAMES_MSG_BASE).msgbase;
|
||||
|
||||
try {
|
||||
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));
|
||||
for(var x in this.headers) {
|
||||
if ((! this.headers[x].tags) || (this.headers[x].tags.length !== PAGE_LENGTH)) {
|
||||
this.untagged_list.push(this.headers[x]);
|
||||
write(); // @todo This is needed for this to work?
|
||||
}
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
log(LOG_ERROR,this.code+' cannot be opened (last_tagged_message):'+e.message);
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
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);
|
||||
return this.untagged_list;
|
||||
}
|
||||
});
|
||||
|
||||
// Get Next page number
|
||||
Object.defineProperty(this,'page_next',{
|
||||
get: function() {
|
||||
if (! this.managed)
|
||||
return undefined;
|
||||
|
||||
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 f = new File(file_cfgname(system.mods_dir,'ansitex/ctrl/videotex.ini'));
|
||||
if (! f.open('r')) {
|
||||
writeln('Unable to open ini file');
|
||||
exit(2);
|
||||
}
|
||||
|
||||
return (''+next_tag).padStart(4,'0');
|
||||
var page = f.iniGetValue('prefix:'+this.page_prefix,PAGE_LAST_KEY)
|
||||
f.close();
|
||||
|
||||
return page ? page : '0'.repeat(PAGE_LENGTH);
|
||||
},
|
||||
|
||||
/*
|
||||
set: function(page) {
|
||||
var f = new File(file_cfgname(system.mods_dir,'ansitex/ctrl/videotex.ini'));
|
||||
if (! f.open('r+')) {
|
||||
@ -325,7 +170,6 @@ function MsgArea() {
|
||||
f.iniSetValue('prefix:'+this.page_prefix,PAGE_LAST_KEY,(''+page).padStart(4,'0'));
|
||||
f.close();
|
||||
}
|
||||
*/
|
||||
});
|
||||
|
||||
// Our page prefix for this msg area
|
||||
@ -334,367 +178,251 @@ function MsgArea() {
|
||||
return ''+this.zone_id+this.area_id;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// Return a REG to test if this frame is part of this msgbase
|
||||
Object.defineProperty(this,'page_prefix_regex',{
|
||||
get: function() {
|
||||
return new RegExp( '^1'+this.page_prefix);
|
||||
},
|
||||
});
|
||||
/**
|
||||
* 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));
|
||||
|
||||
// Total Messages in a msgbase
|
||||
Object.defineProperty(this,'total_msgs',{
|
||||
get: function() {
|
||||
if (! this.managed)
|
||||
return undefined;
|
||||
for(var x in this.list_tagged) {
|
||||
// Advance past our last scan_ptr
|
||||
if (this.list_tagged[x].number <= stats.last_read)
|
||||
continue;
|
||||
|
||||
var msgbase = this.msgbase;
|
||||
msgs.push(this.list_tagged[x]);
|
||||
|
||||
try {
|
||||
if (msgbase.open()) {
|
||||
var index = msgbase.get_index() || [];
|
||||
write(); // @todo This is needed for this to work?
|
||||
}
|
||||
|
||||
msgbase.close();
|
||||
return msgs;
|
||||
}
|
||||
|
||||
} else {
|
||||
writeln('*** NOPE WONT OPEN msgbase:'+JSON.stringify(msgbase));
|
||||
}
|
||||
/**
|
||||
* New Messages for the logged in user
|
||||
*/
|
||||
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));
|
||||
|
||||
} catch (e) {
|
||||
log(LOG_ERROR,this.code+' cannot be opened (total_msgs):'+e.message);
|
||||
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;
|
||||
|
||||
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;
|
||||
continue;
|
||||
}
|
||||
|
||||
return content;
|
||||
};
|
||||
|
||||
// @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;
|
||||
// Add our previous to me message
|
||||
if (msgs.length === 0)
|
||||
msgs.push(last !== null ? this.list_tagged[last] : []);
|
||||
|
||||
if ((this.list_tagged[x].to === user.name) || (this.list_tagged[x].to === user.alias))
|
||||
msgs.push(this.list_tagged[x]);
|
||||
|
||||
write(); // @todo This is needed for this to work?
|
||||
}
|
||||
|
||||
return msgs;
|
||||
write(); // @todo This is needed for this to work?
|
||||
}
|
||||
|
||||
// @todo review
|
||||
/**
|
||||
* New Messages for the logged in user
|
||||
*/
|
||||
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) {
|
||||
// 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;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// Add our previous to me message
|
||||
if (msgs.length === 0)
|
||||
msgs.push(last !== null ? this.list_tagged[last] : []);
|
||||
|
||||
if ((this.list_tagged[x].to === user.name) || (this.list_tagged[x].to === user.alias))
|
||||
msgs.push(this.list_tagged[x]);
|
||||
|
||||
write(); // @todo This is needed for this to work?
|
||||
}
|
||||
|
||||
return msgs;
|
||||
}
|
||||
|
||||
// @todo review
|
||||
/**
|
||||
* 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 (getMessage):'+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;
|
||||
}
|
||||
|
||||
// @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+']');
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// @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);
|
||||
}
|
||||
|
||||
page_next++;
|
||||
if (page_next > this.max_page)
|
||||
page_next = 0;
|
||||
|
||||
page_next = (''+page_next).padStart(4,'0');
|
||||
}
|
||||
|
||||
msgbase.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// @todo review
|
||||
MsgArea.prototype.page = function(msgid) {
|
||||
return '1'+this.page_prefix+msgid;
|
||||
}
|
||||
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?
|
||||
}
|
||||
|
||||
//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)];
|
||||
}
|
||||
|
||||
MsgArea.prototype.MessagePrev = function(page) {
|
||||
var prev = null;
|
||||
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;
|
||||
|
||||
} 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.list_untagged;
|
||||
|
||||
writeln("We have "+msgs.length+" messages to tag.");
|
||||
|
||||
// See if we need to tag something
|
||||
if (! msgs.length)
|
||||
return;
|
||||
|
||||
if (! this.msgbase.open()) {
|
||||
writeln(code+' cannot be opened:'+this.msgbase.error);
|
||||
return false;
|
||||
}
|
||||
|
||||
var page_next = this.page_next;
|
||||
|
||||
for(var x in msgs) {
|
||||
msgs[x].tags = (''+(page_next)).padStart(4,'0');
|
||||
|
||||
if(! this.msgbase.put_msg_header(msgs[x].number,msgs[x])) {
|
||||
writeln('ERROR:'+this.msgbase.error);
|
||||
|
||||
} else {
|
||||
page_next++;
|
||||
if (page_next > MAX_PAGE_NUM)
|
||||
page_next = 0;
|
||||
}
|
||||
}
|
||||
|
||||
this.msgbase.close();
|
||||
this.page_next = page_next;
|
||||
|
||||
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;
|
||||
}
|
||||
|
696
load/page.js
696
load/page.js
@ -1,4 +1,3 @@
|
||||
'use strict';
|
||||
/**
|
||||
PAGE.js handles ANSItex and ViewData page frames
|
||||
|
||||
@ -77,7 +76,7 @@
|
||||
*/
|
||||
|
||||
load('ansitex/load/windows.js'); // Our supporting window class
|
||||
load('ansitex/load/msgbases.js'); // To read/write to message bases
|
||||
require('ansitex/load/msgbases.js','MAX_PAGE_NUM'); // To read/write to message bases
|
||||
require('sbbsdefs.js','SS_USERON'); // Need for our ANSI colors eg: BG_*
|
||||
|
||||
/**
|
||||
@ -110,8 +109,6 @@ require('sbbsdefs.js','SS_USERON'); // Need for our ANSI colors eg: BG_*
|
||||
* - load - Load the frame from the msgbase
|
||||
*/
|
||||
function Page(debug) {
|
||||
const EOF_MARKER = "\r=== EOF";
|
||||
|
||||
this.__window__ = {
|
||||
layout: undefined, // Window - Full page content
|
||||
header: undefined, // Window - Page Title
|
||||
@ -125,15 +122,14 @@ function Page(debug) {
|
||||
|
||||
this.__properties__ = {
|
||||
name: new PageObject,
|
||||
//type: undefined, // Frame type (deprecated, see attrs)
|
||||
attrs: 0, // (Type 0, CUG 0 (public), Hidden=false)
|
||||
type: undefined, // Frame type
|
||||
|
||||
input_fields: [], // Array of our input fields
|
||||
dynamic_fields: [], // Array of our dynamic fields
|
||||
|
||||
//isAccessible: undefined, // Is this page visible to all users (deprecated, see attrs)
|
||||
isAccessible: undefined, // Is this page visible to all users
|
||||
// If FALSE, only the SP can view/edit the frame
|
||||
//isPublic: undefined, // Is this page visible to public (not CUG) users (deprecated, see attrs)
|
||||
isPublic: undefined, // Is this page visible to public (not CUG) users
|
||||
// If FALSE user must be a member of the CUG to view the frame
|
||||
// All users, including unauthenticated, are members of 'system' (owner = 0)
|
||||
// Frame's owned by the system where:
|
||||
@ -146,7 +142,7 @@ function Page(debug) {
|
||||
// isPublic is TRUE - can be viewed by users (if logged in)
|
||||
|
||||
key: [], // Key actions
|
||||
raw: {}, // Page raw content for each session type
|
||||
raw: undefined, // Page raw content
|
||||
};
|
||||
|
||||
this.__defaults__ = {
|
||||
@ -200,89 +196,57 @@ function Page(debug) {
|
||||
}
|
||||
}
|
||||
|
||||
// @todo change this to Object.defineProperty() - see session.js
|
||||
/**
|
||||
* Determine if this frame is accessible to the current user
|
||||
*/
|
||||
Object.defineProperty(this,'accessible',{
|
||||
get: function() {
|
||||
log(LOG_DEBUG,'- Checking if user ['+user.number+'] can access frame: '+this.name.toString());
|
||||
log(LOG_DEBUG,'|* Frame Owner: '+this.owner+', System Frame: '+this.isSystemPage);
|
||||
log(LOG_DEBUG,'|* Accessible: '+this.isAccessible);
|
||||
log(LOG_DEBUG,'|* Public: '+this.isPublic);
|
||||
log(LOG_DEBUG,'|* Member: '+this.isMember);
|
||||
Page.prototype.__defineGetter__('accessible',function() {
|
||||
log(LOG_DEBUG,'- Checking if user ['+user.number+'] can access frame: '+this.name.toString());
|
||||
log(LOG_DEBUG,'|* Frame Owner: '+JSON.stringify(this.pageowner)+', System Frame: '+(this.pageowner === SYSTEM_OWNER));
|
||||
log(LOG_DEBUG,'|* Accessible: '+JSON.stringify(this.__properties__.isAccessible));
|
||||
log(LOG_DEBUG,'|* Public: '+JSON.stringify(this.__properties__.isPublic));
|
||||
log(LOG_DEBUG,'|* Member: '+JSON.stringify(this.isMember));
|
||||
|
||||
// user.number 0 is unidentified user.
|
||||
if (user.number) {
|
||||
return (
|
||||
(this.isAccessible && this.isSystemPage && ! this.isPublic) ||
|
||||
(this.isAccessible && this.isPublic) ||
|
||||
(this.isAccessible && ! this.isPublic && this.isMember) ||
|
||||
(pageEditor(this.name.frame))
|
||||
);
|
||||
// user.number 0 is unidentified user.
|
||||
if (user.number) {
|
||||
return (
|
||||
(this.__properties__.isAccessible && this.pageowner === SYSTEM_OWNER && ! this.__properties__.isPublic) ||
|
||||
(this.__properties__.isAccessible && this.__properties__.isPublic) ||
|
||||
(this.__properties__.isAccessible && ! this.__properties__.isPublic && this.isMember) ||
|
||||
(pageEditor(this.name.frame))
|
||||
);
|
||||
|
||||
} else {
|
||||
return this.isAccessible && this.isSystemPage && this.isPublic;
|
||||
}
|
||||
} else {
|
||||
return this.__properties__.isAccessible && (this.pageowner === SYSTEM_OWNER) && this.__properties__.isPublic;
|
||||
}
|
||||
});
|
||||
|
||||
// The page attributes, which determine accessible, public, cug and frame type
|
||||
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.__defineGetter__('cost',function() {
|
||||
return Number(this.__properties__.cost);
|
||||
});
|
||||
Page.prototype.__defineSetter__('cost',function(int) {
|
||||
if (typeof int !== 'number')
|
||||
throw new Error('Cost must be a number');
|
||||
|
||||
Object.defineProperty(this,'cost',{
|
||||
get: function() {
|
||||
return Number(this.__properties__.cost);
|
||||
},
|
||||
this.__properties__.cost = int;
|
||||
|
||||
set: function(int) {
|
||||
if (int === undefined)
|
||||
int = 0;
|
||||
if ((''+int).length > FRAME_COST_LENGTH-1-FRAME_ATTR_LENGTH)
|
||||
throw new Error('Cost too large');
|
||||
|
||||
if (typeof int !== 'number')
|
||||
throw new Error('Cost must be a number');
|
||||
// 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;
|
||||
|
||||
this.__properties__.cost = int;
|
||||
break;
|
||||
|
||||
if ((''+int).length > FRAME_COST_LENGTH-1-FRAME_ATTR_LENGTH)
|
||||
throw new Error('Cost too large');
|
||||
case 'vtx':
|
||||
this.__window__.cost.__properties__.content = rawtoattrs(VIEWDATA_BIN_GREEN+padright(int,FRAME_COST_LENGTH-1-FRAME_ATTR_LENGTH,' ')+FRAME_COSTUNIT).content;
|
||||
|
||||
// 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;
|
||||
break;
|
||||
|
||||
break;
|
||||
|
||||
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);
|
||||
default:
|
||||
throw new Error(SESSION_EXT+' type not implemented');
|
||||
}
|
||||
});
|
||||
|
||||
@ -308,37 +272,28 @@ function Page(debug) {
|
||||
this.__properties__.input_fields = array;
|
||||
});
|
||||
|
||||
Object.defineProperty(this,'isAccessible',{
|
||||
get: function() {
|
||||
return (this.__properties__.attrs >> 7 !== 1);
|
||||
}
|
||||
Page.prototype.__defineSetter__('isAccessible',function(bool) {
|
||||
if (typeof bool !== 'boolean')
|
||||
throw new Error('isAccessible must be a boolean');
|
||||
|
||||
this.__properties__.isAccessible = bool;
|
||||
});
|
||||
|
||||
/**
|
||||
* Check if the user is already a member of the CUG
|
||||
*/
|
||||
Object.defineProperty(this,'isMember',{
|
||||
get: function() {
|
||||
// @todo Implement CUGs, this would be "=== SERVICE_PROVIDER" and user is a member of SERVICE_PROVIDER
|
||||
return (user.number > 0) && this.isSystemPage;
|
||||
}
|
||||
Page.prototype.__defineGetter__('isMember',function() {
|
||||
// @todo Implement CUGs, this would be "=== SERVICE_PROVIDER" and user is a member of SERVICE_PROVIDER
|
||||
return user.number && (this.pageowner === SYSTEM_OWNER);
|
||||
});
|
||||
|
||||
// Is the page public or CUG
|
||||
Object.defineProperty(this,'isPublic',{
|
||||
get: function() {
|
||||
return (this.cug === 0);
|
||||
}
|
||||
Page.prototype.__defineSetter__('isPublic',function(bool) {
|
||||
if (typeof bool !== 'boolean')
|
||||
throw new Error('isPublic must be a boolean');
|
||||
|
||||
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() {
|
||||
return this.__properties__.key;
|
||||
});
|
||||
@ -346,9 +301,6 @@ function Page(debug) {
|
||||
if (typeof array !== 'object')
|
||||
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;
|
||||
});
|
||||
|
||||
@ -380,20 +332,12 @@ 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() {
|
||||
return this.__properties__.name.next;
|
||||
});
|
||||
|
||||
/**
|
||||
* Determine who the owner of a page is
|
||||
* @deprecated use owner
|
||||
*/
|
||||
Page.prototype.__defineGetter__('pageowner',function() {
|
||||
return pageOwner(this.__properties__.name.frame).prefix;
|
||||
@ -426,14 +370,8 @@ function Page(debug) {
|
||||
this.__window__.provider.__properties__.content = provider;
|
||||
});
|
||||
|
||||
Object.defineProperty(this,'raw',{
|
||||
get: function() {
|
||||
return this.__properties__.raw
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.__properties__.raw[SESSION_EXT] = value;
|
||||
}
|
||||
Page.prototype.__defineGetter__('raw',function() {
|
||||
return this.__properties__.raw;
|
||||
});
|
||||
|
||||
Page.prototype.__defineSetter__('showHeader',function(bool) {
|
||||
@ -443,12 +381,6 @@ function Page(debug) {
|
||||
this.__window__.header.visible = bool;
|
||||
});
|
||||
|
||||
Object.defineProperty(this,'type',{
|
||||
get: function() {
|
||||
return this.__properties__.attrs & 0xf;
|
||||
},
|
||||
});
|
||||
|
||||
Page.prototype.__defineGetter__('type',function() {
|
||||
return this.__properties__.type;
|
||||
});
|
||||
@ -498,7 +430,7 @@ function Page(debug) {
|
||||
|
||||
var content = fields[i].value.split('');
|
||||
|
||||
for (var x=fields[i].x;x<fields[i].x+Math.abs(fields[i].length);x++) {
|
||||
for (x=fields[i].x;x<fields[i].x+Math.abs(fields[i].length);x++) {
|
||||
var index = x-fields[i].x;
|
||||
|
||||
if (content[index])
|
||||
@ -581,14 +513,14 @@ function Page(debug) {
|
||||
last = new_screen;
|
||||
|
||||
// Check all our dynamic fields have been placed
|
||||
var df = this.dynamic_fields.filter(function(item) { return item.value === undefined; });
|
||||
df = this.dynamic_fields.filter(function(item) { return item.value === undefined; });
|
||||
|
||||
// If our dynamic fields havent been filled in
|
||||
if (df.length > 0)
|
||||
throw new Error('Dynamic fields ['+df.length+'] without values:'+(df.map(function(item) { return item.name; }).join('|')));
|
||||
|
||||
// Render the display
|
||||
for (var y=1;y<=this.height;y++) {
|
||||
for (y=1;y<=this.height;y++) {
|
||||
var line = '';
|
||||
|
||||
if (new_line)
|
||||
@ -597,7 +529,7 @@ function Page(debug) {
|
||||
if (debug)
|
||||
writeln('============== ['+y+'] ===============');
|
||||
|
||||
for (var x=1;x<=this.width;x++) {
|
||||
for (x=1;x<=this.width;x++) {
|
||||
if (debug)
|
||||
log(LOG_DEBUG,'* CELL : y:'+y+', x:'+x);
|
||||
// The current char value
|
||||
@ -797,7 +729,7 @@ function Page(debug) {
|
||||
|
||||
// Dump Header
|
||||
write('--:');
|
||||
for (var x=0;x<this.width;x+=10) {
|
||||
for (x=0;x<this.width;x+=10) {
|
||||
write('_'.repeat(4)+'.'+'_'.repeat(4)+'|');
|
||||
}
|
||||
writeln();
|
||||
@ -817,7 +749,7 @@ function Page(debug) {
|
||||
|
||||
// Dump Header
|
||||
write('--:');
|
||||
for (var x=0;x<this.width;x+=10) {
|
||||
for (x=0;x<this.width;x+=10) {
|
||||
write('_'.repeat(4)+'.'+'_'.repeat(4)+'|');
|
||||
}
|
||||
writeln();
|
||||
@ -893,21 +825,6 @@ 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
|
||||
*
|
||||
@ -917,14 +834,12 @@ function Page(debug) {
|
||||
if (!(page instanceof PageObject))
|
||||
throw new Error('page must be a PageObject');
|
||||
|
||||
this.name = page;
|
||||
|
||||
// Load a page from disk first if it exists
|
||||
if (FRAMES_MSG_FILES && this.import(FRAMES_HOME+page.toString(),SESSION_EXT))
|
||||
if (FRAMES_MSG_FILES && this.import(FRAMES_HOME+SESSION_EXT+'/'+page.toString(),SESSION_EXT))
|
||||
return true;
|
||||
|
||||
// Fall back to loading from msgbase
|
||||
return FRAMES_MSG_BASE && this.load(page);
|
||||
return FRAMES_MSG_BASE ? this.load(page) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -947,53 +862,53 @@ function Page(debug) {
|
||||
* 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 width - Width to build window (not required for ANS)
|
||||
* @param height - Height to build window (not required for ANS)
|
||||
* @returns {boolean}
|
||||
* @todo Dont allow load() to load a Viewdata frame for an ANSItex session and visa-versa.
|
||||
*/
|
||||
Page.prototype.import = function(filename) {
|
||||
this.import = function(filename,ext,width,height) {
|
||||
log(LOG_DEBUG,'|- Importing frame: ['+filename+']');
|
||||
|
||||
var f = new File(filename);
|
||||
if (! f.exists || ! f.open('rb',true)) {
|
||||
log(LOG_ERROR,'|? File doesnt exist: ['+filename+']');
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
var contents = JSON.parse(f.read());
|
||||
contents.date = f.date;
|
||||
var contents = f.read();
|
||||
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;
|
||||
|
||||
if (contents.content.substr(-128, 7) === 'SAUCE00') {
|
||||
var sauceless_size = ascii(contents.content.substr(-35,1));
|
||||
sauceless_size <<= 8;
|
||||
sauceless_size |= ascii(contents.content.substr(-36,1));
|
||||
sauceless_size <<= 8;
|
||||
sauceless_size |= ascii(contents.content.substr(-37,1));
|
||||
sauceless_size <<= 8;
|
||||
sauceless_size |= ascii(contents.content.substr(-38,1));
|
||||
if (contents.substr(-128, 7) === 'SAUCE00') {
|
||||
ext = file_getext(filename).substr(1).toLowerCase();
|
||||
|
||||
var data_type = ascii(contents.content.substr(-34,1));
|
||||
var file_type = ascii(contents.content.substr(-33,1));
|
||||
var sauceless_size = ascii(contents.substr(-35,1));
|
||||
sauceless_size <<= 8;
|
||||
sauceless_size |= ascii(contents.substr(-36,1));
|
||||
sauceless_size <<= 8;
|
||||
sauceless_size |= ascii(contents.substr(-37,1));
|
||||
sauceless_size <<= 8;
|
||||
sauceless_size |= ascii(contents.substr(-38,1));
|
||||
|
||||
var tinfo1 = ascii(contents.content.substr(-31,1));
|
||||
var data_type = ascii(contents.substr(-34,1));
|
||||
var file_type = ascii(contents.substr(-33,1));
|
||||
|
||||
var tinfo1 = ascii(contents.substr(-31,1));
|
||||
tinfo1 <<= 8;
|
||||
tinfo1 |= ascii(contents.content.substr(-32,1));
|
||||
tinfo1 |= ascii(contents.substr(-32,1));
|
||||
|
||||
var tinfo2 = ascii(contents.content.substr(-29,1));
|
||||
var tinfo2 = ascii(contents.substr(-29,1));
|
||||
tinfo2 <<= 8;
|
||||
tinfo2 |= ascii(contents.content.substr(-30,1));
|
||||
tinfo2 |= ascii(contents.substr(-30,1));
|
||||
|
||||
switch(data_type) {
|
||||
case 1:
|
||||
switch(file_type) {
|
||||
// Plain ASCII
|
||||
case 0:
|
||||
var ext = 'TXT';
|
||||
ext = 'TXT';
|
||||
if (tinfo1)
|
||||
width = tinfo1;
|
||||
if (tinfo2)
|
||||
@ -1002,7 +917,7 @@ function Page(debug) {
|
||||
|
||||
// ANSI
|
||||
case 1:
|
||||
var ext = 'ANS';
|
||||
ext = 'ANS';
|
||||
if (tinfo1)
|
||||
width = tinfo1;
|
||||
if (tinfo2)
|
||||
@ -1011,7 +926,7 @@ function Page(debug) {
|
||||
|
||||
// Source
|
||||
case 7:
|
||||
var ext = 'TXT';
|
||||
ext = 'TXT';
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1019,7 +934,7 @@ function Page(debug) {
|
||||
break;
|
||||
|
||||
case 5:
|
||||
var ext = 'BIN';
|
||||
ext = 'BIN';
|
||||
width = file_type * 2;
|
||||
height = (sauceless_size / 2) / width;
|
||||
valid_sauce = true;
|
||||
@ -1027,39 +942,69 @@ function Page(debug) {
|
||||
}
|
||||
|
||||
if (valid_sauce)
|
||||
contents.content = contents.content.substr(0, sauceless_size);
|
||||
contents = contents.substr(0, sauceless_size);
|
||||
}
|
||||
|
||||
return this.preload(contents,SESSION_EXT);
|
||||
return this.preload((['vtx','tex'].indexOf(ext) !== -1) ? JSON.parse(contents) : contents,ext,width,height);
|
||||
}
|
||||
|
||||
// Load a frame from a message base
|
||||
this.load = function(page) {
|
||||
var page = this.name.toString();
|
||||
var mb = new MsgAreas().getArea(FRAMES_MSG_BASE)
|
||||
var msg = mb.frames
|
||||
.sort(function(a,b) {
|
||||
if (a.when_imported_time === b.when_imported_time)
|
||||
return a.number < b.number
|
||||
else
|
||||
return (a.when_imported_time < b.when_imported_time); })
|
||||
.filter(function(item) { return item.tags === page; }).pop();
|
||||
var headers;
|
||||
|
||||
var mb = new MsgBase(FRAMES_MSG_BASE);
|
||||
|
||||
try {
|
||||
if (mb.open()) {
|
||||
headers = mb.get_all_msg_headers(false,false) || [];
|
||||
|
||||
} else {
|
||||
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) {
|
||||
log(LOG_DEBUG,'|- Frame not found: ['+page.toString()+'] in ['+FRAMES_MSG_BASE+']');
|
||||
return false;
|
||||
|
||||
} else {
|
||||
log(LOG_DEBUG,'|- Loading frame: ['+page.toString()+'] from msgbase ['+msg.number+'] ['+SESSION_EXT+']');
|
||||
log(LOG_DEBUG,'|- Loading frame: ['+page.toString()+'] from msgbase ['+msg.number+']');
|
||||
|
||||
var contents = mb.getContent(msg.number);
|
||||
var contents = mb.get_msg_body(false,msg.number,false,false,true,true).split("\r\n");
|
||||
|
||||
if (contents === undefined)
|
||||
return false;
|
||||
var i;
|
||||
for (i=0; i<contents.length; i++) {
|
||||
// Echomail tag line
|
||||
if (contents[i] === '---' || contents[i].substring(0,4) === '--- ')
|
||||
break;
|
||||
}
|
||||
contents.length = i;
|
||||
|
||||
contents.content = contents.content[SESSION_EXT];
|
||||
try {
|
||||
var result = JSON.parse(contents.join(''));
|
||||
|
||||
return this.preload(contents,SESSION_EXT);
|
||||
} catch(e) {
|
||||
alert('Error ' + e + ' parsing JSON');
|
||||
}
|
||||
|
||||
return this.preload(result,SESSION_EXT);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -1102,7 +1047,7 @@ function Page(debug) {
|
||||
* @param height
|
||||
* @returns {boolean|null}
|
||||
*/
|
||||
this.preload = function(contents,ext) {
|
||||
this.preload = function(contents,ext,width,height) {
|
||||
switch (ext) {
|
||||
// Messages
|
||||
case 'txt':
|
||||
@ -1110,7 +1055,7 @@ function Page(debug) {
|
||||
var page = rawtoattrs(contents,this.width,this.__window__.body.y,this.__window__.body.x,debug);
|
||||
|
||||
this.__window__.body.__properties__.content = page.content;
|
||||
return contents;
|
||||
this.__properties__.raw = contents;
|
||||
|
||||
// ANSI files
|
||||
case 'ans':
|
||||
@ -1124,146 +1069,119 @@ function Page(debug) {
|
||||
// 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.raw = contents;
|
||||
this.__properties__.raw = contents;
|
||||
|
||||
break;
|
||||
|
||||
// ANSItex files
|
||||
case 'tex':
|
||||
case 'vtx':
|
||||
log(LOG_DEBUG,'|-- Processing FRAME file. V:'+contents.version);
|
||||
log(LOG_DEBUG,'|-- Processing FRAME file');
|
||||
|
||||
switch (contents.version) {
|
||||
case 1:
|
||||
try {
|
||||
for (var index in contents) {
|
||||
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.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));
|
||||
try {
|
||||
for (var index in contents) {
|
||||
if (FRAME_SAVE_ATTRS.indexOf(index) === -1) {
|
||||
log(LOG_ERROR,'|-! Unknown index ['+index+'] in input.');
|
||||
continue;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
case 2:
|
||||
var page = rawtoattrs(contents.content,this.width,this.__window__.body.y,this.__window__.body.x);
|
||||
this.__window__.body.__properties__.content = page.content;
|
||||
this.dynamic_fields = page.dynamic_fields;
|
||||
|
||||
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; });
|
||||
|
||||
// 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]);
|
||||
|
||||
// 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;
|
||||
|
||||
break;
|
||||
case 'cost':
|
||||
this.cost = contents[index];
|
||||
break;
|
||||
|
||||
default:
|
||||
log(LOG_ERROR,'|-! Unknown frame version : '+contents.version);
|
||||
this.get(new PageObject(FRAME_SYSTEM_ERROR));
|
||||
return null;
|
||||
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));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
this.loadcomplete();
|
||||
@ -1284,37 +1202,115 @@ function Page(debug) {
|
||||
* Save the frame to the message base
|
||||
*/
|
||||
this.save = function() {
|
||||
var msgbase = new MsgAreas().getArea(FRAMES_MSG_BASE).msgbase;
|
||||
var mb = new MsgBase(FRAMES_MSG_BASE);
|
||||
var headers;
|
||||
|
||||
if (! msgbase.open()) {
|
||||
log(LOG_ERROR,'! Message Base cannot be opened (save): ['+msgbase.error+']');
|
||||
return false;
|
||||
try {
|
||||
if (mb.open()) {
|
||||
headers = mb.get_all_msg_headers(false,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;
|
||||
}
|
||||
|
||||
var hdr = {
|
||||
to: this.name,
|
||||
from: 'SYSTEM',
|
||||
tags: this.name,
|
||||
date: strftime("%a, %d %b %Y, %I:%M:%S %Z",this.date),
|
||||
subject: 'Content',
|
||||
};
|
||||
// Build the save content
|
||||
var content = {};
|
||||
|
||||
var page = {
|
||||
'version': 2,
|
||||
'attrs': p.attrs,
|
||||
'cost': p.cost,
|
||||
'key': p.key,
|
||||
'content': p.raw,
|
||||
};
|
||||
for (var index in FRAME_SAVE_ATTRS) {
|
||||
switch (FRAME_SAVE_ATTRS[index]) {
|
||||
case 'cost':
|
||||
content[FRAME_SAVE_ATTRS[index]] = this.cost;
|
||||
break;
|
||||
|
||||
var body = LZString.compressToBase64(JSON.stringify(page))+EOF_MARKER;
|
||||
case 'dynamic_fields':
|
||||
content[FRAME_SAVE_ATTRS[index]] = this.dynamic_fields;
|
||||
break;
|
||||
|
||||
if (! msgbase.save_msg(hdr,body)) {
|
||||
case 'frame':
|
||||
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()+']');
|
||||
}
|
||||
|
||||
msgbase.close();
|
||||
return true;
|
||||
mb.close();
|
||||
}
|
||||
|
||||
this.scroll = function(x,y) {
|
||||
@ -1338,19 +1334,11 @@ function PageObject(frame,index) {
|
||||
this.__properties__.frame = frame.frame.toString();
|
||||
this.index = frame.index;
|
||||
|
||||
} else if ((frame !== undefined) && (index === undefined)) {
|
||||
if (/^\d+[a-z]$/.test(frame)) {
|
||||
var split = frame.split(/(\d+)/);
|
||||
this.__properties__.frame = split[1];
|
||||
this.index = split[2];
|
||||
|
||||
} else {
|
||||
this.__properties__.frame = frame;
|
||||
}
|
||||
|
||||
} else if ((frame !== undefined) && (index !== undefined)) {
|
||||
} else {
|
||||
this.__properties__.frame = frame;
|
||||
this.index = index;
|
||||
|
||||
if (index)
|
||||
this.index = index;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
const SESSION_ANSITEX = (1<<1);
|
||||
var CONTENT_EXT = 'ans';
|
||||
var SESSION_EXT = 'tex';
|
||||
|
||||
var FRAME_WIDTH = 80;
|
||||
var FRAME_HEIGHT = 22;
|
||||
|
@ -1,5 +1,5 @@
|
||||
const SESSION_VIEWDATA = (1<<2);
|
||||
var CONTENT_EXT = 'bin';
|
||||
var SESSION_EXT = 'vtx';
|
||||
|
||||
var FRAME_WIDTH = 40;
|
||||
var FRAME_HEIGHT = 22;
|
||||
|
@ -944,15 +944,13 @@ function Char(ch,attr) {
|
||||
ansi.push(r);
|
||||
}
|
||||
|
||||
if (debug)
|
||||
if (false && debug)
|
||||
writeln(' - ansi:'+ansi);
|
||||
|
||||
return ansi.length ? (debug ? '': '\x1b')+'['+ansi.join(';')+'m' : undefined;
|
||||
|
||||
case 'vtx':
|
||||
if (debug)
|
||||
log(LOG_DEBUG,'+ last:'+last+', attr ('+this.attr+')');
|
||||
|
||||
log(LOG_DEBUG,'+ last:'+last+', attr ('+this.attr+')');
|
||||
switch (this.attr) {
|
||||
// \x08
|
||||
case BLINK:
|
||||
@ -1041,9 +1039,7 @@ function Char(ch,attr) {
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
log(LOG_DEBUG,'= result:'+r.charCodeAt(0)+', ('+r+')');
|
||||
|
||||
log(LOG_DEBUG,'= result:'+r.charCodeAt(0)+', ('+r+')');
|
||||
return ESC+r;
|
||||
|
||||
default:
|
||||
|
2
main.js
2
main.js
@ -42,13 +42,11 @@ bbs.replace_text(826,''); // LoggingOn
|
||||
|
||||
switch (client.socket.local_port) {
|
||||
case 516:
|
||||
var SESSION_EXT = 'vtx';
|
||||
require(ANSITEX_HOME+'/load/session/viewdata.js','SESSION_VIEWDATA');
|
||||
break;
|
||||
|
||||
// Assume ANSItex
|
||||
default:
|
||||
var SESSION_EXT = 'tex';
|
||||
require(ANSITEX_HOME+'/load/session/ansitex.js','SESSION_ANSITEX');
|
||||
}
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
{"version":2,"key":[0,0,null,null,null,null,null,null,null,null]}
|
@ -1 +0,0 @@
|
||||
{"version":2,"key":[0,null,null,null,null,null,null,null,null,null]}
|
1
text/99a
1
text/99a
@ -1 +0,0 @@
|
||||
{"version":2,"key":[0,null,null,null,null,null,null,null,null,null]}
|
1
text/99b
1
text/99b
@ -1 +0,0 @@
|
||||
{"version":2,"attrs":"15","key":[null,null,null,null,null,null,null,null,null,null]}
|
1
text/tex/980a
Normal file
1
text/tex/980a
Normal file
@ -0,0 +1 @@
|
||||
{"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"}
|
1
text/tex/998a
Normal file
1
text/tex/998a
Normal file
@ -0,0 +1 @@
|
||||
{"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"}
|
1
text/tex/99a
Normal file
1
text/tex/99a
Normal file
@ -0,0 +1 @@
|
||||
{"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"}
|
1
text/tex/99b
Normal file
1
text/tex/99b
Normal file
@ -0,0 +1 @@
|
||||
{"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"}
|
1
text/vtx/980a
Normal file
1
text/vtx/980a
Normal file
@ -0,0 +1 @@
|
||||
{"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"}
|
1
text/vtx/998a
Normal file
1
text/vtx/998a
Normal file
@ -0,0 +1 @@
|
||||
{"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"}
|
1
text/vtx/99a
Normal file
1
text/vtx/99a
Normal file
@ -0,0 +1 @@
|
||||
{"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"}
|
1
text/vtx/99b
Normal file
1
text/vtx/99b
Normal file
@ -0,0 +1 @@
|
||||
{"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"}
|
@ -1,37 +0,0 @@
|
||||
/** 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();
|
@ -1,31 +0,0 @@
|
||||
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]);
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
/**
|
||||
* 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();
|
42
tools/frame_load.js
Normal file
42
tools/frame_load.js
Normal file
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* 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();
|
||||
}
|
144
tools/frames_check.js
Normal file
144
tools/frames_check.js
Normal file
@ -0,0 +1,144 @@
|
||||
/**
|
||||
* 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');
|
@ -1,26 +1,19 @@
|
||||
load('ansitex/load/funcs.js');
|
||||
load('load/string.js');
|
||||
load('load/funcs.js');
|
||||
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]);
|
||||
ma = new MsgAreas();
|
||||
area = ma.getArea(argv[0]);
|
||||
|
||||
writeln('Opening ['+argv[0]+'] - ('+area.code+')');
|
||||
writeln('Opening ['+argv[0]+'] - ('+area.msgbase.cfg.code+')');
|
||||
writeln('- First:'+area.msgbase.first_msg);
|
||||
writeln('- Last:'+area.msgbase.last_msg);
|
||||
|
||||
var msgbase = area.msgbase;
|
||||
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);
|
||||
for (var x in area.headers) {
|
||||
writeln(padright(area.headers[x].number,4,' ')+':'+area.headers[x].tags);
|
||||
}
|
||||
|
@ -1,26 +1,20 @@
|
||||
load('ansitex/load/msgbases.js');
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
const ma = new MsgAreas()
|
||||
var areas = ma.managed;
|
||||
load('load/string.js');
|
||||
load('ansitex/load/msgbases.js');
|
||||
|
||||
for (var i=0;i<areas.length;i++) {
|
||||
if (argv[0] && ((argv[0] !== areas[i].code) && (argv[0] !== areas[i].page_prefix)))
|
||||
const ma = new MsgAreas()
|
||||
for (var i=0;i<ma.areas.length;i++) {
|
||||
if (argv[0] && (argv[0] !== ma.areas[i].msgbase.cfg.code))
|
||||
continue;
|
||||
|
||||
var total = areas[i].total_msgs;
|
||||
var frames = areas[i].frames.length;
|
||||
writeln('Area : '+ma.areas[i].full_name);
|
||||
writeln('Total Messages : '+ma.areas[i].headers.length);
|
||||
writeln('- Tagged Messages : '+ma.areas[i].list_tagged.length);
|
||||
writeln('- Untagged Messages: '+ma.areas[i].list_untagged.length);
|
||||
|
||||
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();
|
||||
ma.areas[i].tag_msgs();
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
load('ansitex/load/msgbases.js');
|
||||
|
||||
/* Show a list of our message bases */
|
||||
var ma = new MsgAreas();
|
||||
ma.list;
|
||||
|
Loading…
Reference in New Issue
Block a user