Optimised Frame::parse()
This commit is contained in:
parent
019279fcca
commit
8e2b715829
@ -1,4 +1,16 @@
|
||||
; Videotex Options
|
||||
|
||||
; Our key used to sign frames we send to other systems
|
||||
; gpg_key=516@videotex
|
||||
gpg_key=516@videotex
|
||||
|
||||
[prefix]
|
||||
key=0@videotex
|
||||
|
||||
[prefix:5161]
|
||||
key=5161@videotex
|
||||
|
||||
[prefix:51]
|
||||
key=51@videotex
|
||||
|
||||
[prefix:516]
|
||||
key=516@videotex
|
||||
|
41
load/defs.js
41
load/defs.js
@ -44,6 +44,7 @@ function Frame() {
|
||||
this.key=[ null,null,null,null,null,null,null,null,null,null ];
|
||||
|
||||
// Initialise frame array
|
||||
/*
|
||||
this.frame_data = {};
|
||||
this.frame_content = {};
|
||||
for(x=0;x<FRAME_LENGTH;x++)
|
||||
@ -51,6 +52,7 @@ function Frame() {
|
||||
this.frame_data[x] = {};
|
||||
this.frame_content[x] = {};
|
||||
}
|
||||
*/
|
||||
this.frame_fields = [];
|
||||
|
||||
this.raw=function() {
|
||||
@ -128,7 +130,6 @@ Frame.prototype.load = function(filename) {
|
||||
* Additionally, for response frames, if the cursor is moved to a field, its to determine what attributes (eg: color)
|
||||
* should apply for that field.
|
||||
*
|
||||
* @todo This function could be advanced by looking for the next KEY_ESC char, instead of progressing 1 char at a time
|
||||
* @param text
|
||||
*/
|
||||
Frame.prototype.parse = function(text) {
|
||||
@ -142,6 +143,21 @@ Frame.prototype.parse = function(text) {
|
||||
i = 0;
|
||||
|
||||
for(p=0;p<text.length;p++) {
|
||||
// Look for a special character until the end of the frame width
|
||||
cte = (r*FRAME_WIDTH - ((r-1)*FRAME_WIDTH+c));
|
||||
match = text.substr(p,cte).match(/[\r\n\x1b]/);
|
||||
log(LOG_DEBUG,'SPECIAL CHAR ['+r+'x'+c+'] ['+p+'-'+cte+'] for: '+match);
|
||||
|
||||
if (match == null || match.index) {
|
||||
advance = match ? match.index : cte;
|
||||
log(LOG_DEBUG,'INCLUDE: '+text.substr(p,advance));
|
||||
|
||||
output += text.substr(p,advance);
|
||||
p += advance;
|
||||
c += advance;
|
||||
advance = 0;
|
||||
}
|
||||
|
||||
// If the frame is not big enough, fill it with spaces.
|
||||
byte = text.charAt(p);
|
||||
advance = 0;
|
||||
@ -173,8 +189,8 @@ Frame.prototype.parse = function(text) {
|
||||
chars = '';
|
||||
|
||||
// Find our end CSI param in the next 50 chars
|
||||
matches = text.substring(p+advance,p+advance+50).match(/([0-9]+[;]?)+([a-zA-Z])/);
|
||||
log(LOG_DEBUG,'CSI ['+r+'x'+c+'] ADVANCE: '+advance+', MATCHES: '+matches+', STRING: '+text.substring(p+advance,p+advance+50));
|
||||
matches = text.substr(p+advance,50).match(/([0-9]+[;]?)+([a-zA-Z])/);
|
||||
log(LOG_DEBUG,'CSI ['+r+'x'+c+'] ADVANCE: '+advance+', MATCHES: '+matches+', STRING: '+text.substr(p+advance,50));
|
||||
|
||||
if (! matches) {
|
||||
chars += nextbyte;
|
||||
@ -235,8 +251,8 @@ Frame.prototype.parse = function(text) {
|
||||
advance++;
|
||||
|
||||
// Find our end ST param in the next 50 chars
|
||||
matches = text.substring(p+advance,p+advance+50).match(/(([A-Z]+;[0-9a-z]+)([;]?.+)?)\x1b\\/);
|
||||
log(LOG_DEBUG,'SOS ['+r+'x'+c+'] ADVANCE: '+advance+', MATCHES: '+matches+', LENGTH: '+matches[0].length+', STRING: '+text.substring(p+advance,p+advance+50));
|
||||
matches = text.substr(p+advance,50).match(/(([A-Z]+;[0-9a-z]+)([;]?.+)?)\x1b\\/);
|
||||
log(LOG_DEBUG,'SOS ['+r+'x'+c+'] ADVANCE: '+advance+', MATCHES: '+matches+', LENGTH: '+matches[0].length+', STRING: '+text.substr(p+advance,50));
|
||||
|
||||
if (! matches) {
|
||||
chars += nextbyte;
|
||||
@ -291,13 +307,14 @@ Frame.prototype.parse = function(text) {
|
||||
byte = '';
|
||||
|
||||
this.frame_fields.push({
|
||||
'type': fieldtype,
|
||||
'length': fieldlen,
|
||||
'r': r,
|
||||
'c': c,
|
||||
type: fieldtype,
|
||||
length: fieldlen,
|
||||
r: r,
|
||||
c: c,
|
||||
attribute: {i:i,f:f,b:b},
|
||||
});
|
||||
|
||||
log(LOG_DEBUG,'SOS Field found at ['+r+'x'+(c-1)+'], Type: '+fieldtype+', Length: '+fieldlen);
|
||||
log(LOG_DEBUG,'SOS Field found at ['+r+'x'+(c-1)+'], Type: '+fieldtype+', Length: '+fieldlen+', Attrs: '+JSON.stringify({i:i,f:f,b:b}));
|
||||
|
||||
break;
|
||||
|
||||
@ -308,8 +325,8 @@ Frame.prototype.parse = function(text) {
|
||||
break;
|
||||
|
||||
default:
|
||||
this.frame_data[r][c] = {i:i,f:f,b:b};
|
||||
this.frame_content[r][c] = byte;
|
||||
//this.frame_data[r][c] = {i:i,f:f,b:b};
|
||||
//this.frame_content[r][c] = byte;
|
||||
log(LOG_DEBUG,'ADD OUTPUT ['+r+'x'+c+'] for: '+byte);
|
||||
c++;
|
||||
}
|
||||
|
15
main.js
15
main.js
@ -2,6 +2,8 @@
|
||||
load('sbbsdefs.js');
|
||||
// Load text.dat defintions
|
||||
load('text.js');
|
||||
// Key definitions
|
||||
load('key_defs.js');
|
||||
// Enable to manipulate the ANSI terminal
|
||||
ansi = load({},'ansiterm_lib.js');
|
||||
|
||||
@ -61,7 +63,8 @@ while(bbs.online) {
|
||||
break;
|
||||
|
||||
case '#':
|
||||
if (frame.index !== 'z') {
|
||||
log(LOG_DEBUG,'- false: Key ['+read+'] ['+pageStr(fo)+']');
|
||||
if (fo.index !== 'z') {
|
||||
next_page = { frame: fo.frame, index: String.fromCharCode(fo.index.charCodeAt(0)+1) };
|
||||
action = ACTION_GOTO;
|
||||
|
||||
@ -323,6 +326,16 @@ while(bbs.online) {
|
||||
mode = false;
|
||||
break;
|
||||
|
||||
case FRAME_TYPE_LOGIN:
|
||||
case FRAME_TYPE_RESPONSE:
|
||||
log(LOG_DEBUG,'response frame :'+fo.page);
|
||||
console.putmsg(fo.render());
|
||||
mode = action = false;
|
||||
//fo.fields;
|
||||
//bbs.hangup();
|
||||
//exit();
|
||||
break;
|
||||
|
||||
// Standard Frame
|
||||
case FRAME_TYPE_INFO:
|
||||
default:
|
||||
|
201
mods/logon.js
201
mods/logon.js
@ -1,201 +0,0 @@
|
||||
// logon.js
|
||||
|
||||
// Synchronet v3.1 Default Logon Module
|
||||
|
||||
// $Id: logon.js,v 1.52 2019/08/16 04:15:31 rswindell Exp $
|
||||
|
||||
// @format.tab-size 4, @format.use-tabs true
|
||||
|
||||
require("sbbsdefs.js", 'SS_RLOGIN');
|
||||
require("nodedefs.js", 'NODE_QUIET');
|
||||
if (user.command_shell == 'ansitex') {
|
||||
system.settings |= (SYS_NOSYSINFO | SYS_QVALKEYS);
|
||||
exit();
|
||||
}
|
||||
|
||||
if(!bbs.mods.avatar_lib)
|
||||
bbs.mods.avatar_lib = load({}, 'avatar_lib.js');
|
||||
if(!bbs.mods.logonlist_lib)
|
||||
bbs.mods.logonlist_lib = load({}, 'logonlist_lib.js');
|
||||
load("fonts.js", "preload", "default");
|
||||
if(!bbs.mods.userprops)
|
||||
bbs.mods.userprops = load({}, "userprops.js");
|
||||
var options = load("modopts.js", "logon");
|
||||
if(!options)
|
||||
options = {};
|
||||
if(options.show_avatar === undefined)
|
||||
options.show_avatar = true;
|
||||
if(options.draw_avatar_right === undefined)
|
||||
options.draw_avatar_right = true;
|
||||
|
||||
if(user.settings & USER_ICE_COLOR) {
|
||||
var cterm = load({}, "cterm_lib.js");
|
||||
cterm.bright_background(true);
|
||||
}
|
||||
|
||||
if(options.email_validation == true) {
|
||||
load({}, "emailval.js");
|
||||
if(!bbs.online)
|
||||
exit();
|
||||
}
|
||||
|
||||
// Check if we're being asked to auto-run an external (web interface external programs section uses this)
|
||||
if ((options.rlogin_auto_xtrn) && (bbs.sys_status & SS_RLOGIN) && (console.terminal.indexOf("xtrn=") === 0)) {
|
||||
var external_code = console.terminal.substring(5);
|
||||
if (!bbs.exec_xtrn(external_code)) {
|
||||
alert(log(LOG_ERR,"!ERROR Unable to launch external: '" + external_code + "'"));
|
||||
}
|
||||
bbs.hangup();
|
||||
exit();
|
||||
}
|
||||
//Disable spinning cursor at pause prompts
|
||||
//bbs.node_settings|=NM_NOPAUSESPIN
|
||||
|
||||
if(user.security.restrictions&UFLAG_G) {
|
||||
while(bbs.online) {
|
||||
printf("\1y\1hFor our records, please enter your full name: \1w");
|
||||
name=console.getstr(LEN_NAME,K_UPRLWR);
|
||||
if(!name || !name.length)
|
||||
continue;
|
||||
bbs.log_str("Guest: " + name);
|
||||
user.name = name;
|
||||
break;
|
||||
}
|
||||
|
||||
while(bbs.online) {
|
||||
printf("\1y\1hPlease enter your e-mail address: \1w");
|
||||
email=console.getstr(LEN_NETMAIL);
|
||||
if(!email || !email.length)
|
||||
continue;
|
||||
if(bbs.trashcan("email", email)) {
|
||||
bbs.hangup();
|
||||
exit();
|
||||
}
|
||||
bbs.log_str(" " + email);
|
||||
user.netmail=email;
|
||||
user.settings|=USER_NETMAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
while(bbs.online) {
|
||||
printf("\1y\1hPlease enter your location (City, State): \1w");
|
||||
location=console.getstr(LEN_LOCATION,K_UPRLWR);
|
||||
if(!location || !location.length)
|
||||
continue;
|
||||
if(bbs.trashcan("location", location)) {
|
||||
bbs.hangup();
|
||||
exit();
|
||||
}
|
||||
bbs.log_str(" " + location);
|
||||
user.location=location;
|
||||
break;
|
||||
}
|
||||
|
||||
if(bbs.online)
|
||||
bbs.log_str("\r\n");
|
||||
while(bbs.online) {
|
||||
printf("\1y\1hWhere did you hear about this BBS?\r\n: \1w");
|
||||
ref=console.getstr(70);
|
||||
if(!ref || !ref.length)
|
||||
continue;
|
||||
bbs.log_str(ref + "\r\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Force split-screen chat on ANSI users
|
||||
if(console.term_supports(USER_ANSI))
|
||||
user.chat_settings|=CHAT_SPLITP;
|
||||
|
||||
// Inactivity exemption
|
||||
if(user.security.exemptions&UFLAG_H)
|
||||
console.status|=CON_NO_INACT;
|
||||
|
||||
/******************************
|
||||
* Replaces the 2.1 Logon stuff
|
||||
******************************/
|
||||
|
||||
if(options.fast_logon !== true || !(bbs.sys_status&SS_FASTLOGON)
|
||||
|| !user.compare_ars(options.fast_logon_requirements)) {
|
||||
|
||||
// Logon screens
|
||||
|
||||
// Print successively numbered logon screens (logon, logon1, logon2, etc.)
|
||||
var highest_printed_logon_screen=-1;
|
||||
for(var i=0;;i++) {
|
||||
var fname="logon";
|
||||
if(i)
|
||||
fname+=i;
|
||||
if(!bbs.menu_exists(fname)) {
|
||||
if(i>1)
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
bbs.menu(fname);
|
||||
highest_printed_logon_screen = i;
|
||||
}
|
||||
|
||||
// Print logon screens based on security level
|
||||
if(user.security.level > highest_printed_logon_screen
|
||||
&& bbs.menu_exists("logon" + user.security.level))
|
||||
bbs.menu("logon" + user.security.level);
|
||||
|
||||
// Print one of text/menu/random*.*, picked at random
|
||||
// e.g. random1.asc, random2.asc, random3.asc, etc.
|
||||
var random_list = directory(system.text_dir + "menu/random*.*");
|
||||
if(random_list.length)
|
||||
bbs.menu(file_getname(random_list[random(random_list.length)]).slice(0,-4));
|
||||
|
||||
console.clear(LIGHTGRAY);
|
||||
bbs.user_event(EVENT_LOGON);
|
||||
}
|
||||
|
||||
if(user.security.level==99 /* Sysop logging on */
|
||||
&& !system.matchuser("guest") /* Guest account does not yet exist */
|
||||
&& bbs.mods.userprops.get("logon", "makeguest", true) /* Sysop has not asked to stop this question */
|
||||
) {
|
||||
if(console.yesno("Create Guest/Anonymous user account (highly recommended)"))
|
||||
load("makeguest.js");
|
||||
else if(!console.yesno("Ask again later"))
|
||||
bbs.mods.userprops.set("logon", "makeguest", false);
|
||||
console.crlf();
|
||||
}
|
||||
|
||||
// Last few callers
|
||||
console.aborted=false;
|
||||
console.clear(LIGHTGRAY);
|
||||
bbs.exec("?logonlist -l");
|
||||
if(bbs.node_status != NODE_QUIET && ((system.settings&SYS_SYSSTAT) || !user.is_sysop))
|
||||
bbs.mods.logonlist_lib.add();
|
||||
|
||||
// Auto-message
|
||||
auto_msg=system.data_dir + "msgs/auto.msg"
|
||||
if(file_size(auto_msg)>0) {
|
||||
console.printfile(auto_msg,P_NOATCODES|P_WORDWRAP);
|
||||
}
|
||||
console.crlf();
|
||||
|
||||
if(options.show_avatar && console.term_supports(USER_ANSI)) {
|
||||
if(options.draw_avatar_above || options.draw_avatar_right)
|
||||
bbs.mods.avatar_lib.draw(user.number, /* name: */null, /* netaddr: */null, options.draw_avatar_above, options.draw_avatar_right);
|
||||
else
|
||||
bbs.mods.avatar_lib.show(user.number);
|
||||
console.attributes = 7; // Clear the background attribute
|
||||
}
|
||||
|
||||
// Set rlogin_xtrn_menu=true in [logon] section of ctrl/modopts.ini
|
||||
// if you want your RLogin server to act as a door game server only
|
||||
if(options.rlogin_xtrn_menu
|
||||
&& bbs.sys_status&SS_RLOGIN) {
|
||||
bbs.xtrn_sec();
|
||||
bbs.hangup();
|
||||
} else if(!(user.security.restrictions&UFLAG_G)
|
||||
&& console.term_supports(USER_ANSI)
|
||||
&& options.set_avatar == true) {
|
||||
var avatar = bbs.mods.avatar_lib.read(user.number);
|
||||
if(!avatar || (!avatar.data && !avatar.disabled)) {
|
||||
alert("You have not selected an avatar.");
|
||||
if(console.yesno("Select avatar now"))
|
||||
load("avatar_chooser.js");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user