Enable loading a page and overwriting its contents with a file

This commit is contained in:
Deon George 2024-01-01 22:46:53 +11:00
parent a1bcc1f5cb
commit 0625691ae5
6 changed files with 26 additions and 22 deletions

View File

@ -47,13 +47,9 @@ function MsgAreas() {
writeln('Areas that we ARE managing mail:'+this.areas.length); writeln('Areas that we ARE managing mail:'+this.areas.length);
for(var x in this.areas_excluded) { for(var x in this.areas_excluded) {
/* writeln(x+':'+((this.areas_excluded[x].area_name === undefined)
writeln(this.areas_excluded[x].area_name = undefined ? this.areas_excluded[x]
? JSON.stringify(this.areas_excluded[x]) : JSON.stringify(this.areas_excluded[x])));
: this.areas_excluded[x].area_name);
*/
writeln(JSON.stringify(this.areas_excluded[x]));
exit();
} }
} }
}); });

View File

@ -443,8 +443,7 @@ function Page(debug) {
/** /**
* Build in any input_fields with values * Build in any input_fields with values
*/ */
this.build_input_fields = function() this.build_input_fields = function() {
{
var that = this; var that = this;
var f = this.input_fields.filter(function(item) { return item.value.length; }); var f = this.input_fields.filter(function(item) { return item.value.length; });
@ -836,7 +835,7 @@ function Page(debug) {
throw new Error('page must be a PageObject'); throw new Error('page must be a PageObject');
// Load a page from disk first if it exists // Load a page from disk first if it exists
if (FRAMES_MSG_FILES && this.import(FRAMES_HOME+SESSION_EXT+'/'+page.toString())) if (FRAMES_MSG_FILES && this.import(FRAMES_HOME+SESSION_EXT+'/'+page.toString(),SESSION_EXT))
return true; return true;
// Fall back to loading from msgbase // Fall back to loading from msgbase
@ -868,7 +867,7 @@ function Page(debug) {
* @returns {boolean} * @returns {boolean}
* @todo Dont allow load() to load a Viewdata frame for an ANSItex session and visa-versa. * @todo Dont allow load() to load a Viewdata frame for an ANSItex session and visa-versa.
*/ */
this.import = function(filename,width,height) { this.import = function(filename,ext,width,height) {
log(LOG_DEBUG,'|- Importing frame: ['+filename+']'); log(LOG_DEBUG,'|- Importing frame: ['+filename+']');
var f = new File(filename); var f = new File(filename);
@ -881,7 +880,6 @@ function Page(debug) {
f.close(); f.close();
var valid_sauce = false; var valid_sauce = false;
var ext = SESSION_EXT;
if (contents.substr(-128, 7) === 'SAUCE00') { if (contents.substr(-128, 7) === 'SAUCE00') {
ext = file_getext(filename).substr(1).toLowerCase(); ext = file_getext(filename).substr(1).toLowerCase();

View File

@ -43,10 +43,12 @@ function rawtoattrs(contents,width,yoffset,xoffset,debug) {
// @todo temp hack, rework ansi variable - perhaps have a function that converts an attribute back into an ANSI sequence // @todo temp hack, rework ansi variable - perhaps have a function that converts an attribute back into an ANSI sequence
var ansi = { i: 0, f: 37, b: 40 }; var ansi = { i: 0, f: 37, b: 40 };
var line;
var x;
while (lines.length > 0) { while (lines.length > 0) {
var x = 0; x = 0;
var line = lines.shift(); line = lines.shift();
if ((debug !== undefined) && (y > debug)) { if ((debug !== undefined) && (y > debug)) {
exit(1); exit(1);

View File

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

View File

@ -102,8 +102,8 @@ if (! tex.import(FRAMES_HOME+SESSION_EXT+'/'+page)) {
// Checking keys // Checking keys
if (vtx.raw && tex.raw) { if (vtx.raw && tex.raw) {
writeln('- Checking Page: '); writeln('- Checking Page: ');
if (vtx.name.toString() !== tex.name.toString()) { if (vtx.name.toString() !== tex.name.toString()) {
writeln(' - ! VTX: '+vtx.name.toString()); writeln(' - ! VTX: '+vtx.name.toString());
writeln(' - ! TEX: '+tex.name.toString()); writeln(' - ! TEX: '+tex.name.toString());

View File

@ -1,4 +1,4 @@
load('ansitex/load/msgbases.js'); load('ansitex/load/msgbases.js');
var ma = new MsgAreas(); var ma = new MsgAreas();
writeln(JSON.stringify(ma.list)); ma.list;