2024-12-23 03:52:45 +00:00
|
|
|
'use strict';
|
2024-01-01 06:03:25 +00:00
|
|
|
require('ansitex/load/defs.js','ANSITEX_HOME'); // ANSITEX definitions
|
|
|
|
|
2020-07-17 14:36:49 +00:00
|
|
|
// Array of page owners
|
2024-12-23 03:52:45 +00:00
|
|
|
var pageowners = [];
|
2020-07-17 14:36:49 +00:00
|
|
|
|
2020-03-27 05:14:33 +00:00
|
|
|
// String repeat.
|
2019-10-03 04:08:48 +00:00
|
|
|
if (!String.prototype.repeat) {
|
2019-10-15 10:48:16 +00:00
|
|
|
String.prototype.repeat = function(count) {
|
|
|
|
'use strict';
|
2022-04-16 05:36:17 +00:00
|
|
|
if (this === null) {
|
2019-10-15 10:48:16 +00:00
|
|
|
throw new TypeError('can\'t convert ' + this + ' to object');
|
|
|
|
}
|
|
|
|
var str = '' + this;
|
|
|
|
count = +count;
|
2022-04-16 05:36:17 +00:00
|
|
|
if (count !== count) {
|
2019-10-15 10:48:16 +00:00
|
|
|
count = 0;
|
|
|
|
}
|
|
|
|
if (count < 0) {
|
2022-04-16 05:36:17 +00:00
|
|
|
throw new RangeError('repeat count must be non-negative: '+count);
|
2019-10-15 10:48:16 +00:00
|
|
|
}
|
2022-04-16 05:36:17 +00:00
|
|
|
if (count === Infinity) {
|
2019-10-15 10:48:16 +00:00
|
|
|
throw new RangeError('repeat count must be less than infinity');
|
|
|
|
}
|
|
|
|
count = Math.floor(count);
|
2022-04-16 05:36:17 +00:00
|
|
|
if (str.length === 0 || count === 0) {
|
2019-10-15 10:48:16 +00:00
|
|
|
return '';
|
|
|
|
}
|
|
|
|
// Ensuring count is a 31-bit integer allows us to heavily optimize the
|
|
|
|
// main part. But anyway, most current (August 2014) browsers can't handle
|
|
|
|
// strings 1 << 28 chars or longer, so:
|
|
|
|
if (str.length * count >= 1 << 28) {
|
|
|
|
throw new RangeError('repeat count must not overflow maximum string size');
|
|
|
|
}
|
|
|
|
var rpt = '';
|
|
|
|
for (;;) {
|
2022-04-16 05:36:17 +00:00
|
|
|
if ((count & 1) === 1) {
|
2019-10-15 10:48:16 +00:00
|
|
|
rpt += str;
|
|
|
|
}
|
|
|
|
count >>>= 1;
|
2022-04-16 05:36:17 +00:00
|
|
|
if (count === 0) {
|
2019-10-15 10:48:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
str += str;
|
|
|
|
}
|
|
|
|
return rpt;
|
|
|
|
};
|
2019-10-03 04:08:48 +00:00
|
|
|
}
|
2022-04-26 11:54:34 +00:00
|
|
|
|
2020-08-12 13:23:26 +00:00
|
|
|
/**
|
|
|
|
* Convert ANSI into BIN for loading into a Frame
|
|
|
|
*
|
|
|
|
* @param ansi
|
|
|
|
*/
|
|
|
|
function ans2bin(ansi,frame) {
|
|
|
|
var x = new Graphic;
|
|
|
|
x.ANSI = ansi;
|
|
|
|
|
|
|
|
var o = 0; // offset into 'bin'
|
|
|
|
for (var yy = 0; yy < 22; yy++) {
|
|
|
|
for (var xx = 0; xx < 80; xx++) {
|
|
|
|
frame.setData(
|
|
|
|
xx,
|
|
|
|
yy,
|
|
|
|
x.BIN.substr(o,1),
|
|
|
|
x.BIN.substr(o+1,1).charCodeAt(0) || BG_BLACK
|
|
|
|
);
|
|
|
|
|
|
|
|
o = o+2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
/**
|
|
|
|
* Dynamic Field Processing
|
|
|
|
*
|
|
|
|
* @param field field we want to get a value for
|
|
|
|
* @param length length to fill this field
|
|
|
|
* @param pad the padding character if field is less than length
|
|
|
|
* @param context a context value to determine the value from
|
|
|
|
* @returns {string|*|null}
|
|
|
|
* @note bbs.atcodes() cannot process modifiers, so this function is a replacement.
|
|
|
|
*/
|
2022-05-01 07:42:19 +00:00
|
|
|
function atcode(field,length,pad,context) {
|
|
|
|
pad = pad ? pad : ' ';
|
2024-12-23 03:52:45 +00:00
|
|
|
var result = {};
|
2022-05-13 12:31:47 +00:00
|
|
|
var args = [];
|
|
|
|
|
|
|
|
if (field.search(/:/)) {
|
|
|
|
args = field.split(':');
|
|
|
|
field = args.shift();
|
|
|
|
}
|
|
|
|
|
2024-12-23 03:52:45 +00:00
|
|
|
log(LOG_DEBUG,'Field:'+field,'Args:'+JSON.stringify(args));
|
2022-05-01 07:42:19 +00:00
|
|
|
|
|
|
|
switch(field) {
|
2024-12-23 03:52:45 +00:00
|
|
|
// Work out the key for the message area
|
|
|
|
case 'msg_area_key':
|
|
|
|
var index = args.shift();
|
|
|
|
|
|
|
|
log(LOG_DEBUG,'Context:'+context+', Index:'+index);
|
|
|
|
|
|
|
|
// If the message area exists, we'll return a key and a index
|
|
|
|
if (new MsgAreas().getArea(context+index.padStart(2,'0'))) {
|
|
|
|
result.value = index;
|
|
|
|
result.key = '1'+context+index.padStart(2,'0');
|
2022-05-01 07:42:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2024-12-23 03:52:45 +00:00
|
|
|
// Get the ECHOAREA Internal Code
|
|
|
|
case 'msg_area_tag':
|
|
|
|
var index = args.shift();
|
|
|
|
var area = new MsgAreas().getArea(context+index.padStart(2,'0'));
|
|
|
|
|
|
|
|
log(LOG_DEBUG,'Context:'+context+', Index:'+index+', Area:'+JSON.stringify(area));
|
|
|
|
|
|
|
|
// If the message area exists
|
|
|
|
if (area)
|
|
|
|
result.value = area.code.toUpperCase();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Get the ECHOAREA Name
|
|
|
|
case 'msg_area_name':
|
|
|
|
var index = args.shift();
|
|
|
|
var area = new MsgAreas().getArea(context+index.padStart(2,'0'));
|
|
|
|
|
|
|
|
if (area)
|
|
|
|
result.value = area.area_name;
|
2022-05-01 07:42:19 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
2022-05-03 11:10:09 +00:00
|
|
|
// Oldest message in msgarea
|
2022-05-12 12:27:06 +00:00
|
|
|
// Our oldest message, is the first message with a tag from the headers
|
2022-05-03 11:10:09 +00:00
|
|
|
case 'msg_area_msgoldest_date':
|
|
|
|
if (typeof context !== 'object') {
|
|
|
|
log(LOG_ERROR,'Unable to render ['+field+'], no context provided');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-05-12 12:27:06 +00:00
|
|
|
var x = context.list_tagged[0];
|
2022-05-03 11:10:09 +00:00
|
|
|
|
2024-12-23 03:52:45 +00:00
|
|
|
result.value = x ? x.date : '';
|
2022-05-03 11:10:09 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'msg_area_msgoldest_page':
|
|
|
|
if (typeof context !== 'object') {
|
|
|
|
log(LOG_ERROR,'Unable to render ['+field+'], no context provided');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-05-12 12:27:06 +00:00
|
|
|
var x = context.list_tagged[0];
|
2022-05-03 11:10:09 +00:00
|
|
|
|
2022-05-12 12:27:06 +00:00
|
|
|
return x ? context.getMessagePage(x.number) : null;
|
2022-05-03 11:10:09 +00:00
|
|
|
|
|
|
|
// Newest message in msgarea
|
2022-05-12 12:27:06 +00:00
|
|
|
// Our newest message, is the last message with a tag from the headers
|
2022-05-03 11:10:09 +00:00
|
|
|
case 'msg_area_msgnewest_date':
|
|
|
|
if (typeof context !== 'object') {
|
|
|
|
log(LOG_ERROR,'Unable to render ['+field+'], no context provided');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-05-12 12:27:06 +00:00
|
|
|
var x = context.list_tagged[context.list_tagged.length-1];
|
|
|
|
|
2024-12-23 03:52:45 +00:00
|
|
|
result.value = x ? x.date : '';
|
2022-05-03 11:10:09 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'msg_area_msgnewest_page':
|
|
|
|
if (typeof context !== 'object') {
|
|
|
|
log(LOG_ERROR,'Unable to render ['+field+'], no context provided');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-05-12 12:27:06 +00:00
|
|
|
var x = context.list_tagged[context.list_tagged.length-1];
|
|
|
|
|
|
|
|
return x ? context.getMessagePage(x.number) : null;
|
2022-05-03 11:10:09 +00:00
|
|
|
|
|
|
|
// First unread message
|
|
|
|
case 'msg_area_msgunread_date':
|
|
|
|
if (typeof context !== 'object') {
|
|
|
|
log(LOG_ERROR,'Unable to render ['+field+'], no context provided');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-05-06 07:41:07 +00:00
|
|
|
var x = context.newMsgs();
|
|
|
|
|
2024-12-23 03:52:45 +00:00
|
|
|
result.value = x.length ? x.shift().date : '';
|
2022-05-03 11:10:09 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'msg_area_msgunread_page':
|
|
|
|
if (typeof context !== 'object') {
|
|
|
|
log(LOG_ERROR,'Unable to render ['+field+'], no context provided');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-05-06 07:41:07 +00:00
|
|
|
var x = context.newMsgs();
|
|
|
|
return x.length ? context.getMessagePage(x.shift().number) : null;
|
2022-05-03 11:10:09 +00:00
|
|
|
|
|
|
|
// First unread message to me
|
|
|
|
case 'msg_area_msgotome_date':
|
|
|
|
if (typeof context !== 'object') {
|
|
|
|
log(LOG_ERROR,'Unable to render ['+field+'], no context provided');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-05-06 07:41:07 +00:00
|
|
|
var x = context.newMsgsToMe();
|
2022-05-03 11:10:09 +00:00
|
|
|
|
2024-12-23 03:52:45 +00:00
|
|
|
result.value = x.length > 1 ? x[1].date : '';
|
2022-05-03 11:10:09 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'msg_area_msgtome_page':
|
|
|
|
if (typeof context !== 'object') {
|
|
|
|
log(LOG_ERROR,'Unable to render ['+field+'], no context provided');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-05-06 07:41:07 +00:00
|
|
|
var x = context.newMsgsToMe();
|
2022-12-15 12:28:25 +00:00
|
|
|
return x.length > 1 ? context.getMessagePage(x[1].number) : null;
|
2022-05-03 11:10:09 +00:00
|
|
|
|
|
|
|
// Count of unread messages
|
|
|
|
case 'msg_area_new':
|
2022-05-13 13:32:22 +00:00
|
|
|
if (args.length === 1) {
|
|
|
|
context = new MsgArea();
|
|
|
|
context.code = args[0];
|
|
|
|
}
|
|
|
|
|
2022-05-03 11:10:09 +00:00
|
|
|
if (typeof context !== 'object') {
|
|
|
|
log(LOG_ERROR,'Unable to render ['+field+'], no context provided');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-12-23 03:52:45 +00:00
|
|
|
result.value = ''+context.newMsgs().length;
|
2022-05-03 11:10:09 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
// Count of unread messages to me
|
|
|
|
case 'msg_area_newtome':
|
|
|
|
if (typeof context !== 'object') {
|
|
|
|
log(LOG_ERROR,'Unable to render ['+field+'], no context provided');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-12-23 03:52:45 +00:00
|
|
|
result.value = ''+(context.newMsgsToMe().length > 1 ? context.newMsgsToMe().length-1 : 0);
|
2022-05-03 11:10:09 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
// Is this message area in my new scan list
|
|
|
|
case 'msg_area_newscan':
|
|
|
|
if (typeof context !== 'object') {
|
|
|
|
log(LOG_ERROR,'Unable to render ['+field+'], no context provided');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-12-23 03:52:45 +00:00
|
|
|
result.value = (context.getUserStats().scan_ptr & SCAN_CFG_TOYOU) ? 'YES' : 'NO';
|
2022-05-03 11:10:09 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
// Is this message area in my new scan list
|
|
|
|
case 'msg_area_pending':
|
|
|
|
if (typeof context !== 'object') {
|
|
|
|
log(LOG_ERROR,'Unable to render ['+field+'], no context provided');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-12-23 03:52:45 +00:00
|
|
|
result.value = ''+context.list_untagged.length;
|
2022-05-03 11:10:09 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
// Get the ECHOAREA Total Number of Messages
|
|
|
|
case 'msg_area_total':
|
|
|
|
if (typeof context !== 'object') {
|
|
|
|
log(LOG_ERROR,'Unable to render ['+field+'], no context provided');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-12-23 03:52:45 +00:00
|
|
|
result.value = ''+context.msgbase.total_msgs;
|
2022-05-03 11:10:09 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
// Get the ECHOAREA Group Name
|
|
|
|
case 'msg_grp_name':
|
|
|
|
if (typeof context !== 'object') {
|
|
|
|
log(LOG_ERROR,'Unable to render ['+field+'], no context provided');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-12-23 03:52:45 +00:00
|
|
|
result.value = context.zone_name;
|
2022-05-03 11:10:09 +00:00
|
|
|
break;
|
|
|
|
|
2022-05-01 07:42:19 +00:00
|
|
|
case 'nodeid':
|
2024-12-23 03:52:45 +00:00
|
|
|
result.value = getNodeID();
|
2022-05-01 07:42:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2024-12-23 03:52:45 +00:00
|
|
|
result.value = (typeof bbs === 'undefined') ? '*'.repeat(Math.abs(length)) : bbs.atcode(field+(args.length ? ':'+args : ''));
|
2022-05-01 07:42:19 +00:00
|
|
|
}
|
|
|
|
|
2024-12-23 03:52:45 +00:00
|
|
|
if ((result.value === null) || (result.value === undefined))
|
|
|
|
result.value = '';
|
2022-05-03 11:10:09 +00:00
|
|
|
|
2024-12-23 03:52:45 +00:00
|
|
|
length = length ? length : result.value.length;
|
2022-05-03 11:10:09 +00:00
|
|
|
|
|
|
|
//log(LOG_DEBUG,' - result length ['+result.length+'] desired ('+length+')');
|
2024-12-23 03:52:45 +00:00
|
|
|
if (result.value.length < Math.abs(length))
|
|
|
|
result.value = (length < 0) ? padright(result.value,Math.abs(length),pad) : padleft(result.value,length,pad);
|
|
|
|
else if (result.value.length > Math.abs(length))
|
|
|
|
result.value = result.value.substr(0,Math.abs(length));
|
2022-05-01 07:42:19 +00:00
|
|
|
|
2024-12-23 03:52:45 +00:00
|
|
|
log(LOG_DEBUG,'* ATCODE ['+field+'] ('+length+'|"'+pad+'") returns ['+result.value+'] key ['+result.key+']');
|
2022-05-01 07:42:19 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-10-15 10:48:16 +00:00
|
|
|
/**
|
|
|
|
* Find a message base by code
|
|
|
|
*
|
|
|
|
* @param code
|
|
|
|
* @returns {number | string|boolean}
|
2023-12-24 06:44:02 +00:00
|
|
|
* @deprecated Can this move to the msgbases.js?
|
2019-10-15 10:48:16 +00:00
|
|
|
*/
|
2020-03-27 05:14:33 +00:00
|
|
|
function findMsgBase(code) {
|
2019-10-15 10:48:16 +00:00
|
|
|
if (! code)
|
2023-12-24 06:44:02 +00:00
|
|
|
code = "vtx_data";
|
2019-10-15 10:48:16 +00:00
|
|
|
|
|
|
|
for (var s in msg_area.sub) {
|
|
|
|
var sub = msg_area.sub[s];
|
2023-12-24 06:44:02 +00:00
|
|
|
writeln('sub:'+sub.code);
|
2019-10-15 10:48:16 +00:00
|
|
|
|
2022-04-16 05:36:17 +00:00
|
|
|
if (sub.code.substr(-code.length).toLowerCase() === code)
|
2023-12-24 06:44:02 +00:00
|
|
|
return sub;
|
2019-10-15 10:48:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2019-10-03 04:08:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return an argument from argv, or an error if it doesnt exit
|
|
|
|
*
|
|
|
|
* @param key
|
|
|
|
* @param error
|
2022-04-16 05:36:17 +00:00
|
|
|
* @param abort
|
2019-10-03 04:08:48 +00:00
|
|
|
*/
|
|
|
|
function getArg(key,error,abort) {
|
2019-10-15 10:48:16 +00:00
|
|
|
index = argv.indexOf(key);
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2019-10-15 10:48:16 +00:00
|
|
|
if ((index !== -1) && (! (argv[index+1] === undefined || argv[index+1].match(/^-/)))) {
|
|
|
|
return argv[index+1];
|
|
|
|
}
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2019-10-15 10:48:16 +00:00
|
|
|
if (abort) {
|
|
|
|
log(LOG_ERROR,error);
|
|
|
|
exit(1);
|
|
|
|
}
|
2019-10-03 04:08:48 +00:00
|
|
|
}
|
|
|
|
|
2020-11-01 10:55:32 +00:00
|
|
|
/**
|
|
|
|
* Returns the current node number
|
|
|
|
*
|
|
|
|
* @returns {string}
|
|
|
|
*/
|
|
|
|
function getNodeID() {
|
|
|
|
var regex = new RegExp('^'+SYSTEM_ZONE+':');
|
2022-05-13 04:34:31 +00:00
|
|
|
var matches = [];
|
2020-11-01 10:55:32 +00:00
|
|
|
|
|
|
|
for each (var addr in system.fido_addr_list)
|
|
|
|
{
|
|
|
|
if (regex.test(addr)) {
|
|
|
|
addr = addr.replace(regex,'');
|
|
|
|
matches = addr.split('/',2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-09 06:19:33 +00:00
|
|
|
return (matches.length === 0) ? '-' : padright(matches[0],3,'0')+padright(matches[1],3,'0')+padright((typeof bbs === 'undefined') ? 0 : bbs.node_num,2,'0');
|
2020-11-01 10:55:32 +00:00
|
|
|
}
|
|
|
|
|
2020-07-21 11:56:57 +00:00
|
|
|
function getPageOwners() {
|
|
|
|
// Load the owner configuration into memory
|
|
|
|
if (! pageowners.length) {
|
2024-01-01 06:03:25 +00:00
|
|
|
var f = new File(ANSITEX_HOME+'/ctrl/videotex.ini');
|
2020-07-21 11:56:57 +00:00
|
|
|
|
2020-08-14 02:33:33 +00:00
|
|
|
if (f.open('r')) {
|
2020-07-30 13:47:40 +00:00
|
|
|
var logoans = f.iniGetValue('prefix','logoans');
|
|
|
|
var logovtx = f.iniGetValue('prefix','logovtx');
|
2020-07-21 11:56:57 +00:00
|
|
|
var users = f.iniGetValue('prefix','user');
|
2020-07-29 14:15:48 +00:00
|
|
|
//log(LOG_DEBUG,'+ pageOwner: users='+JSON.stringify(users));
|
2020-07-30 13:47:40 +00:00
|
|
|
pageowners.push({prefix: 0,logoans: logoans,logovtx: logovtx,user:users});
|
2020-07-21 11:56:57 +00:00
|
|
|
|
|
|
|
f.iniGetSections('prefix:').forEach(function (prefix) {
|
|
|
|
var p = parseInt(prefix.substr(7));
|
2020-07-30 13:47:40 +00:00
|
|
|
var logoans = f.iniGetValue(prefix,'logoans','');
|
|
|
|
var logovtx = f.iniGetValue(prefix,'logovtx','');
|
2020-07-21 11:56:57 +00:00
|
|
|
var users = f.iniGetValue(prefix,'user','');
|
2020-07-29 14:15:48 +00:00
|
|
|
//log(LOG_DEBUG,'+ pageOwner: users='+JSON.stringify(users));
|
2020-07-30 13:47:40 +00:00
|
|
|
pageowners.push({prefix: p,logoans: logoans,logovtx: logovtx,user:users});
|
2020-07-21 11:56:57 +00:00
|
|
|
});
|
2024-01-01 06:03:25 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
log(LOG_DEBUG,'getPageOwners: Couldnt open videotex.ini? :'+JSON.stringify(f));
|
2020-07-21 11:56:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
f.close();
|
|
|
|
|
|
|
|
// Sort the pageowners ascending
|
2022-04-24 12:36:47 +00:00
|
|
|
pageowners.sort(function(a,b) { return (a.prefix < b.prefix) ? 1 : ((b.prefix < a.prefix) ? -1 : 0); });
|
2020-07-21 11:56:57 +00:00
|
|
|
|
2020-07-29 14:15:48 +00:00
|
|
|
//log(LOG_DEBUG,'+ pageOwner: pageowners='+JSON.stringify(pageowners));
|
2020-07-21 11:56:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return pageowners;
|
|
|
|
}
|
|
|
|
|
2020-08-14 02:33:33 +00:00
|
|
|
function loadOptions(option) {
|
2024-01-01 06:03:25 +00:00
|
|
|
var f = new File(ANSITEX_HOME+'/ctrl/videotex.ini');
|
2019-10-20 11:31:15 +00:00
|
|
|
|
2020-08-14 02:33:33 +00:00
|
|
|
if (! f.open('r')) {
|
2024-01-01 06:03:25 +00:00
|
|
|
log(LOG_DEBUG,'loadOptions: Couldnt open videotex.ini? :'+JSON.stringify(f));
|
|
|
|
|
2019-10-20 11:31:15 +00:00
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
2020-08-14 02:33:33 +00:00
|
|
|
val = f.iniGetObject(option);
|
2019-10-20 11:31:15 +00:00
|
|
|
|
2020-08-14 02:33:33 +00:00
|
|
|
f.close();
|
2019-10-20 11:31:15 +00:00
|
|
|
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
function msgBaseImport(msgbase,page,text) {
|
2023-12-24 06:44:02 +00:00
|
|
|
var msgbase = new MsgBase(findMsgBase(msgbase).code);
|
2019-10-15 10:48:16 +00:00
|
|
|
|
|
|
|
log(LOG_DEBUG,'Sending ['+page+'] to message base ['+msgbase.cfg.code+']');
|
|
|
|
|
|
|
|
var hdr = { to:'All', from:'Videotex', subject:'Frame: '+page };
|
|
|
|
|
|
|
|
var body = '';
|
|
|
|
body += text+"\r\n";
|
|
|
|
body += "--- " + js.exec_file + " " + '1.0' + "\r\n";
|
|
|
|
|
|
|
|
return msgbase.save_msg(hdr, body);
|
|
|
|
}
|
|
|
|
|
2022-05-01 07:42:19 +00:00
|
|
|
// Right Pad a string with char c
|
|
|
|
function padright(n,width,c) {
|
|
|
|
c = c || '0';
|
|
|
|
n = n + '';
|
|
|
|
return n.length >= width ? n : new Array(width - n.length + 1).join(c) + n;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Left Pad a string with char c
|
|
|
|
function padleft(n,width,c) {
|
|
|
|
c = c || '0';
|
2020-11-01 10:55:32 +00:00
|
|
|
n = n + '';
|
2022-05-01 07:42:19 +00:00
|
|
|
return n.length >= width ? n : n+new Array(width - n.length + 1).join(c);
|
2020-11-01 10:55:32 +00:00
|
|
|
}
|
|
|
|
|
2019-10-03 04:08:48 +00:00
|
|
|
/**
|
|
|
|
* Return the frame as a string
|
|
|
|
*/
|
|
|
|
function pageStr(page) {
|
2020-03-26 06:22:46 +00:00
|
|
|
if (page.frame==null)
|
|
|
|
return null;
|
|
|
|
|
2019-10-15 10:48:16 +00:00
|
|
|
if (! page.index)
|
|
|
|
page.index = 'a';
|
2019-10-03 04:08:48 +00:00
|
|
|
|
2020-07-17 14:36:49 +00:00
|
|
|
return page.frame.toString()+page.index;
|
2019-10-03 04:08:48 +00:00
|
|
|
}
|
|
|
|
|
2019-10-22 10:57:25 +00:00
|
|
|
/**
|
2020-07-17 14:36:49 +00:00
|
|
|
* Read our videotex.ini configuration and determine who owns a page.
|
|
|
|
* If there is no prefix for the page, it is owned by the system '0'
|
2019-10-22 10:57:25 +00:00
|
|
|
*
|
2020-07-17 14:36:49 +00:00
|
|
|
* @param page
|
|
|
|
* @returns {undefined}
|
2019-10-22 10:57:25 +00:00
|
|
|
*/
|
2020-07-17 14:36:49 +00:00
|
|
|
function pageOwner(page) {
|
2020-07-21 11:56:57 +00:00
|
|
|
var BreakException = {};
|
|
|
|
var o = null;
|
2020-07-17 14:36:49 +00:00
|
|
|
|
2020-07-21 11:56:57 +00:00
|
|
|
try {
|
|
|
|
getPageOwners().forEach(function(owner) {
|
|
|
|
var p = owner.prefix.toString();
|
|
|
|
o = owner;
|
2020-07-17 14:36:49 +00:00
|
|
|
|
2020-07-21 11:56:57 +00:00
|
|
|
var re = new RegExp('^' + p, 'g');
|
|
|
|
if (page.toString().match(re)) {
|
|
|
|
//log(LOG_DEBUG,'= pageOwner: p='+p+',o: '+o);
|
|
|
|
throw BreakException;
|
|
|
|
}
|
|
|
|
});
|
2020-07-17 14:36:49 +00:00
|
|
|
|
2020-07-21 11:56:57 +00:00
|
|
|
} catch (e) {
|
|
|
|
if (e !== BreakException) throw e;
|
|
|
|
}
|
2020-07-17 14:36:49 +00:00
|
|
|
|
2020-07-29 14:15:48 +00:00
|
|
|
//log(LOG_DEBUG,'+ pageOwner: page='+page+', owner: '+JSON.stringify(o));
|
2020-07-22 12:37:00 +00:00
|
|
|
return o;
|
2020-07-21 11:56:57 +00:00
|
|
|
}
|
2020-07-17 14:36:49 +00:00
|
|
|
|
2020-07-21 11:56:57 +00:00
|
|
|
/**
|
|
|
|
* Can the user edit the frame
|
|
|
|
*
|
|
|
|
* @param page
|
|
|
|
* @param user
|
|
|
|
*/
|
|
|
|
function pageEditor(page) {
|
|
|
|
//log(LOG_DEBUG,'+ pageEditor: page='+page+', user #'+user.number);
|
2019-10-22 10:57:25 +00:00
|
|
|
|
2020-07-18 13:48:51 +00:00
|
|
|
var BreakException = {};
|
2020-07-21 11:56:57 +00:00
|
|
|
var pageditor = false;
|
2020-07-17 14:36:49 +00:00
|
|
|
|
2020-07-18 13:48:51 +00:00
|
|
|
try {
|
2020-07-21 11:56:57 +00:00
|
|
|
getPageOwners().forEach(function(owner) {
|
2020-07-18 13:48:51 +00:00
|
|
|
var p = owner.prefix.toString();
|
2020-07-21 11:56:57 +00:00
|
|
|
//log(LOG_DEBUG,' - pageEditor: '+JSON.stringify(owner));
|
|
|
|
frameusers = owner.user ? owner.user.toString().split(',') : [1];
|
2020-07-17 14:36:49 +00:00
|
|
|
|
2020-07-21 11:56:57 +00:00
|
|
|
log(LOG_DEBUG,' - pageEditor: p='+p+'('+p.length+') user ['+JSON.stringify(frameusers)+'] - :'+frameusers.indexOf(user.number.toString()));
|
2020-07-17 14:36:49 +00:00
|
|
|
|
2020-07-18 13:48:51 +00:00
|
|
|
var re = new RegExp('^' + p, 'g');
|
2020-07-24 13:00:35 +00:00
|
|
|
if (page.toString().match(re) && (frameusers.indexOf(user.number.toString()) !== -1)) {
|
2020-07-21 11:56:57 +00:00
|
|
|
pageditor = true;
|
2020-07-18 13:48:51 +00:00
|
|
|
throw BreakException;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
if (e !== BreakException) throw e;
|
|
|
|
}
|
2020-07-17 14:36:49 +00:00
|
|
|
|
2020-07-22 12:37:00 +00:00
|
|
|
log(LOG_DEBUG,'+ pageEditor: page='+page+', editor: '+JSON.stringify(pageditor));
|
2020-07-21 11:56:57 +00:00
|
|
|
return pageditor;
|
2020-07-17 14:36:49 +00:00
|
|
|
}
|
2019-10-22 10:57:25 +00:00
|
|
|
|
2022-04-18 11:27:25 +00:00
|
|
|
/**
|
|
|
|
* This function returns a list of zones used by this system.
|
|
|
|
*/
|
|
|
|
function zones() {
|
|
|
|
var z = [];
|
|
|
|
var ftn = /([0-9]+):([0-9]+)\/([0-9]+)(\.([0-9]+))?/;
|
|
|
|
|
|
|
|
for(var g=0;g<system.fido_addr_list.length;g++) {
|
|
|
|
z.push(parseInt(system.fido_addr_list[g].match(ftn)[1]));
|
|
|
|
}
|
|
|
|
|
|
|
|
return z.sort(function(a,b) {
|
|
|
|
return (a>b);
|
|
|
|
});
|
2019-10-22 10:57:25 +00:00
|
|
|
}
|
|
|
|
|
2020-11-01 10:55:32 +00:00
|
|
|
this;
|