55 lines
2.4 KiB
JavaScript
55 lines
2.4 KiB
JavaScript
/**
|
|
* ANSItex definitions
|
|
*/
|
|
|
|
var ACTION_RELOAD =1; /* Reload the current frame */
|
|
var ACTION_GOTO =2; /* Goto a specific frame */
|
|
var ACTION_BACKUP =3; /* Goto previous frame */
|
|
var ACTION_NEXT =4; /* Goto next frame */
|
|
var ACTION_TERMINATE =6; /* Terminate the session */
|
|
var ACTION_SUBMITRF =7; /* Submit form contents */
|
|
var ACTION_STAR =7; /* Star command entry */
|
|
|
|
var MODE_BL =1; /* Typing * command on baseline */
|
|
|
|
var FRAME_LENGTH =22; /* Length of a frame */
|
|
var FRAME_WIDTH =80; /* Width of a frame */
|
|
var FRAME_HEADER =56; /* Size of page owner (length) */
|
|
var FRAME_PAGENUM =12; /* Size of page number (length with a-z) */
|
|
var FRAME_COST =9; /* Size of cost (length without unit)*/
|
|
var FRAME_COSTUNIT ='c'; /* Unit of cost */
|
|
|
|
var ERR_NOT_IMPLEMENTED = '\1RNOT IMPLEMENTED';
|
|
var ERR_ROUTE = '\1WMISTAKE? \1GTRY AGAIN OR TELL US ON *08';
|
|
|
|
// Our frame object
|
|
function Frame(frame,index) {
|
|
if (frame === undefined) {
|
|
print('ERROR: frame not defined.');
|
|
exit(1);
|
|
}
|
|
|
|
this.version=1;
|
|
this.frame=parseInt(frame);
|
|
this.index=index ? index : 'a';
|
|
this.owner=''; // @todo
|
|
this.cost=0; // @todo
|
|
this.content='';
|
|
this.isPublic=false; // @todo
|
|
this.isAccessible=false; // @todo
|
|
this.key=[ null,null,null,null,null,null,null,null,null,null ];
|
|
this.render=function() {
|
|
owner = base64_decode(this.owner);
|
|
|
|
return owner+' '.repeat(FRAME_HEADER-console.strlen(owner))+' '+
|
|
'\1W\1H'+this.page+' '.repeat(FRAME_PAGENUM-this.page.length)+' '+
|
|
'\1G\1H'+' '.repeat(FRAME_COST-this.cost.toString().length)+this.cost+FRAME_COSTUNIT+
|
|
(console.screen_columns > 80 ? '\n\r' : '') +
|
|
base64_decode(this.content);
|
|
}
|
|
|
|
Object.defineProperty(this,'page', {
|
|
get: function() {return pageStr({frame: this.frame, index: this.index }); }
|
|
});
|
|
}
|