Minor fixes with register, start on frame edit

This commit is contained in:
Deon George 2020-07-13 23:08:37 +10:00
parent 141382c499
commit 0aab42f51b
4 changed files with 156 additions and 24 deletions

View File

@ -49,7 +49,7 @@ var NO_HISTORY_FRAMES =['980a','98b','981a'];
var SYSTEM_FRAMES =['AWgBUkEBR04BQlMBWUkBbgE3AWt0ZXgBbg==']; var SYSTEM_FRAMES =['AWgBUkEBR04BQlMBWUkBbgE3AWt0ZXgBbg=='];
// Our frame object // Our frame object
function Frame() { function TexFrame() {
this.version=1; // The version of this frame - in case we update functionality and we need to be this.version=1; // The version of this frame - in case we update functionality and we need to be
// backwards compatible // backwards compatible
this.frame=null; // Frame Number [0-9]+ this.frame=null; // Frame Number [0-9]+
@ -148,7 +148,7 @@ function Frame() {
} }
// Load a frame from disk (.tex file) // Load a frame from disk (.tex file)
Frame.prototype.load = function(filename) { TexFrame.prototype.load = function(filename) {
log(LOG_DEBUG,'Loading frame from: '+filename); log(LOG_DEBUG,'Loading frame from: '+filename);
f = new File(system.mods_dir+'ansitex/text/'+filename+'.tex'); f = new File(system.mods_dir+'ansitex/text/'+filename+'.tex');
@ -187,7 +187,7 @@ Frame.prototype.load = function(filename) {
* *
* @param text * @param text
*/ */
Frame.prototype.parse = function(text) { TexFrame.prototype.parse = function(text) {
var c = 1; // column var c = 1; // column
var r = 2; // row (row 1 is the header) var r = 2; // row (row 1 is the header)
var output = ''; var output = '';

122
load/edit.js Normal file
View File

@ -0,0 +1,122 @@
load("ansiedit.js");
load('frame.js');
load('tree.js');
load('scrollbar.js');
load('event-timer.js');
load('graphic.js');
const sauce_lib = load({}, 'sauce_lib.js');
if (bbs.mods.avatar_lib) {
avatar_lib = bbs.mods.avatar_lib;
} else {
avatar_lib = load({}, 'avatar_lib.js');
}
var CONTROL_EDIT = '1';
function edit(fo) {
log(LOG_DEBUG,'+ Control EDIT loaded');
var complete = false;
Object.defineProperty(this,'getName', {
get: function() {
return 'Frame Edit';
}
});
Object.defineProperty(this,'isComplete', {
get: function() {
return complete;
}
});
const frames = {
parent : null,
container : null,
highlight : null,
scrollbar : null
};
owner = '\1h\1RA\1GN\1BS\1YI\1n\1'+'7\1ktex\1'+'0\1n';
const frame = new Frame(1,1,console.screen_columns,console.screen_rows,BG_BLACK|LIGHTGRAY);
frame.gotoxy(1,1);
header = '\1n'+owner+' '.repeat(FRAME_HEADER-console.strlen(owner))+'\1n '+
'\1W\1H'+fo.page+' '.repeat(FRAME_PAGENUM-fo.page.length)+' '+
'\1G\1H'+' Edit';
frame.putmsg(header);
frame.open();
var ansiEdit = new ANSIEdit({
x: 1,
y: 2,
width: 80,
height: 23,
attr: WHITE,
//showPosition: true,
menuHeading: 'Frame Edit '+fo.page,
parentFrame: frame,
});
ansiEdit.open();
ansiEdit.menu.addItem('Save', _save);
ansiEdit.menu.addItem('Exit', on_exit);
ansiEdit.menu.addItem('Save & Exit', save_and_exit);
x = new Graphic;
x.ANSI = fo.content;
log(LOG_DEBUG,JSON.stringify(x));
const bin = x.BIN;
var o = 0; // offset into 'bin'
for (var yy = 0; yy < 22; yy++) {
for (var xx = 0; xx < 80; xx++) {
ansiEdit.putChar({
x : xx,
y : yy,
ch : bin.substr(o, 1),
attr : bin.substr(o + 1, 1).charCodeAt(0) || BG_BLACK
});
o = o + 2;
}
}
ansiEdit.cycle();
frame.cycle();
this.handle=function(read) {
if (! js.terminated && ascii(read) != 27) {
ansiEdit.getcmd(read);
ansiEdit.cycle();
frame.cycle();
return '';
}
ansiEdit.close();
frame.close();
complete = true;
console.clear(LIGHTGRAY);
console.putmsg(fo.render());
return '';
}
function _save() {
log(LOG_DEBUG, '+ FrameEdit save()');
}
function on_exit() {
log(LOG_DEBUG, '+ FrameEdit on_exit()');
complete = true;
console.clear(LIGHTGRAY);
console.putmsg(fo.render());
}
function save_and_exit() {
_save();
on_exit();
}
}
this;

View File

@ -11,7 +11,7 @@
* + PCODE THe user's postal code * + PCODE THe user's postal code
*/ */
var CONTROL_REGISTER ='1'; var CONTROL_REGISTER = '1';
var EMAIL_REGEX = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; var EMAIL_REGEX = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
var cValChars='ACDEFHJKLMNPQRTUVWXY23456789!@$%&'; var cValChars='ACDEFHJKLMNPQRTUVWXY23456789!@$%&';
@ -21,6 +21,19 @@ function register() {
var code = ''; var code = '';
var complete = false; var complete = false;
// Called before processing for a field
Object.defineProperty(this, 'getName', {
get: function () {
return 'Control-Registration';
}
});
Object.defineProperty(this, 'isComplete', {
get: function () {
return complete;
}
});
this.handle=function(read) { this.handle=function(read) {
log(LOG_DEBUG,'Control REGISTER handle() start. ('+read+')'); log(LOG_DEBUG,'Control REGISTER handle() start. ('+read+')');
log(LOG_DEBUG,'- Field '+cf.fname+'('+JSON.stringify(cf)+')'); log(LOG_DEBUG,'- Field '+cf.fname+'('+JSON.stringify(cf)+')');
@ -41,7 +54,7 @@ function register() {
return read; return read;
} }
// Called before processing for a field // Make sure we got an email
this.prefield=function() { this.prefield=function() {
log(LOG_DEBUG,'- Field '+cf.fname+'('+JSON.stringify(cf)+')'); log(LOG_DEBUG,'- Field '+cf.fname+'('+JSON.stringify(cf)+')');
@ -55,14 +68,14 @@ function register() {
var name = fo.fieldValue('FULLNAME'); var name = fo.fieldValue('FULLNAME');
log(LOG_DEBUG,'- VALIDATE EMAIL TO ('+system.matchuserdata(U_NETMAIL,email)+')'); log(LOG_DEBUG,'- VALIDATE EMAIL TO ('+system.matchuserdata(U_NETMAIL,email)+')');
// Make sure we got an email
// Validate Email hasnt been used // Validate Email hasnt been used
// Validate USER_ID hasnt been used
if ((email.indexOf('@') === -1) || ! EMAIL_REGEX.test(email) || (system.matchuserdata(U_NETMAIL,email) !== 0)) { if ((email.indexOf('@') === -1) || ! EMAIL_REGEX.test(email) || (system.matchuserdata(U_NETMAIL,email) !== 0)) {
sendBaseline('\1n\1h\1RINVAID EMAIL, PLEASE TRY AGAIN *00',false); sendBaseline('\1n\1h\1RINVAID EMAIL, PLEASE TRY AGAIN *00',false);
return; return;
} }
// Validate USER_ID hasnt been used
if (! system.check_name(user)) { if (! system.check_name(user)) {
log(LOG_DEBUG,'Cannot use user_id: ('+user+')'); log(LOG_DEBUG,'Cannot use user_id: ('+user+')');
sendBaseline('\1n\1h\1RINVAID USER ID, PLEASE TRY AGAIN *00',false); sendBaseline('\1n\1h\1RINVAID USER ID, PLEASE TRY AGAIN *00',false);
@ -70,8 +83,9 @@ function register() {
} }
var msgbase = new MsgBase('mail'); var msgbase = new MsgBase('mail');
for (var i=0;i<6;i++) for (var i=0;i<6;i++) {
code+=cValChars.substr(parseInt(Math.random() * cValChars.length), 1); code += cValChars.substr(parseInt(Math.random()*cValChars.length),1);
}
var hdrs = new Object(); var hdrs = new Object();
hdrs.to=name; hdrs.to=name;
@ -92,6 +106,7 @@ function register() {
console.pause(); console.pause();
msgbase.close(); msgbase.close();
bbs.hangup(); bbs.hangup();
return; return;
} }
@ -105,6 +120,7 @@ function register() {
bbs.hangup(); bbs.hangup();
return; return;
} }
msgbase.close(); msgbase.close();
} }
@ -143,6 +159,7 @@ function register() {
user.netmail = fo.fieldValue('EMAIL'); user.netmail = fo.fieldValue('EMAIL');
bbs.user_sync(); bbs.user_sync();
bbs.logon(); bbs.logon();
log(LOG_INFO,"Created user record #"+user.number+": "+user.alias); log(LOG_INFO,"Created user record #"+user.number+": "+user.alias);
action = ACTION_EXIT; action = ACTION_EXIT;
@ -154,23 +171,12 @@ function register() {
user.comment = 'Initial login failed!'; user.comment = 'Initial login failed!';
newuser.settings |= USER_DELETED; newuser.settings |= USER_DELETED;
delete newuser; delete newuser;
return; return;
} }
return 'processed'; return 'processed';
} }
Object.defineProperty(this,'getName', {
get: function() {
return 'Control-Registration';
}
});
Object.defineProperty(this,'isComplete', {
get: function() {
return complete;
}
});
} }
this; this;

10
main.js
View File

@ -80,8 +80,9 @@ while(bbs.online) {
log(LOG_DEBUG,'CONTROL RETURN: ['+read+'] ('+cc.isComplete+')'); log(LOG_DEBUG,'CONTROL RETURN: ['+read+'] ('+cc.isComplete+')');
if (cc.isComplete) { if (cc.isComplete) {
control = control.pop(); control.pop();
log(LOG_DEBUG,'CONTROL COMPLETE: ['+read+'] ('+control.length+')'); log(LOG_DEBUG,'CONTROL COMPLETE: ['+read+'] ('+control.length+')');
cc = null;
} }
log(LOG_DEBUG,'CONTROL END: ['+read+']'); log(LOG_DEBUG,'CONTROL END: ['+read+']');
@ -238,7 +239,10 @@ while(bbs.online) {
// Edit frame // Edit frame
} else if (cmd == '04') { } else if (cmd == '04') {
sendBaseline(ERR_NOT_IMPLEMENTED,false); mode = action = false;
require('ansitex/load/edit.js','CONTROL_EDIT');
control.push(new edit(fo));
} else { } else {
next_page = { frame: cmd }; next_page = { frame: cmd };
@ -632,7 +636,7 @@ while(bbs.online) {
if (next_page !== null) { if (next_page !== null) {
current = fo; current = fo;
fo = new Frame(); fo = new TexFrame();
fo.load(pageStr(next_page)); fo.load(pageStr(next_page));
if (fo.page == null) { if (fo.page == null) {