Fixes for viewdata, tested with proper viewdata client

This commit is contained in:
Deon George 2020-08-17 17:39:13 +10:00
parent 424e4a8f64
commit b14cd82329
3 changed files with 33 additions and 17 deletions

View File

@ -23,8 +23,6 @@ function sqrllogin() {
var complete = false; var complete = false;
var cancel = false; var cancel = false;
fo.render();
log(LOG_DEBUG,'OPTIONS: '+JSON.stringify(loadOptions('sqrl'))); log(LOG_DEBUG,'OPTIONS: '+JSON.stringify(loadOptions('sqrl')));
sqrl = loadOptions('sqrl'); sqrl = loadOptions('sqrl');
http = new HTTPRequest(); http = new HTTPRequest();

View File

@ -14,6 +14,13 @@ var VIEWDATA_COFF = "\x14";
var VIEWDATA_CON = "\x11"; var VIEWDATA_CON = "\x11";
var VIEWDATA_RIGHT = "\x09"; var VIEWDATA_RIGHT = "\x09";
var VIEWDATA_LEFT = "\x08"; var VIEWDATA_LEFT = "\x08";
var VIEWDATA_MOSIAC_RED = ascii(27)+ascii(0x51);
var VIEWDATA_MOSIAC_GREEN = ascii(27)+ascii(0x52);
var VIEWDATA_MOSIAC_YELLOW = ascii(27)+ascii(0x53);
var VIEWDATA_MOSIAC_BLUE = ascii(27)+ascii(0x54);
var VIEWDATA_MOSIAC_MAGENTA = ascii(27)+ascii(0x55);
var VIEWDATA_MOSIAC_CYAN = ascii(27)+ascii(0x56);
var VIEWDATA_MOSIAC_WHITE = ascii(27)+ascii(0x57);
var VIEWDATA_MSG_SENDORNOT = ascii(27)+'BKEY 1 TO SEND, 2 NOT TO SEND'; var VIEWDATA_MSG_SENDORNOT = ascii(27)+'BKEY 1 TO SEND, 2 NOT TO SEND';
var VIEWDATA_MSG_LOGON = ascii(27)+'BKEY 1 TO LOGON, 2 TO RETURN'; var VIEWDATA_MSG_LOGON = ascii(27)+'BKEY 1 TO LOGON, 2 TO RETURN';
@ -405,13 +412,13 @@ function VIEWDATAFrame() {
}; };
this.qrcode = function(qr,subframe) { this.qrcode = function(qr,subframe) {
var offset = 18/2; // @todo For some reason RIGHT movements results in 2 spaces var offset = 18;
// Render the body // Render the body
var qrcode = VIEWDATA_HOME+VIEWDATA_DOWN.repeat(5)+VIEWDATA_RIGHT.repeat(offset); var qrcode = VIEWDATA_HOME+VIEWDATA_DOWN.repeat(5);
//var line = ''; //var line = '';
for (var x = -1; x < qr.size; x=x+3) { for (var x = -1; x < qr.size; x=x+3) {
var line = VIEWDATA_RIGHT.repeat(offset)+ascii(0x97); var line = VIEWDATA_RIGHT.repeat(offset ? offset-1 : 0)+VIEWDATA_MOSIAC_WHITE;
for (var y = -1; y < qr.size; y=y+2) { for (var y = -1; y < qr.size; y=y+2) {
var char = 0; var char = 0;
@ -440,7 +447,9 @@ function VIEWDATAFrame() {
if (y%2) if (y%2)
line += ascii(0x35); line += ascii(0x35);
qrcode += line+' '.repeat(VIEWDATA_FRAME_WIDTH-Math.ceil(qr.size/2)-2-offset*2-(y%2 ? 0 : 1))+VIEWDATA_RIGHT.repeat(offset); repeat_count = VIEWDATA_FRAME_WIDTH-Math.ceil(qr.size/2)-offset-(offset ? 1 : 2)-(y%2 == 1 ? 0 : 1);
qrcode += line+' '.repeat(repeat_count > 0 ? repeat_count : 0);
} }
log(LOG_DEBUG,'WIDTH:'+VIEWDATA_FRAME_WIDTH); log(LOG_DEBUG,'WIDTH:'+VIEWDATA_FRAME_WIDTH);
@ -451,7 +460,8 @@ function VIEWDATAFrame() {
// Render the bottom // Render the bottom
if (x%3) { if (x%3) {
line = VIEWDATA_RIGHT.repeat(offset)+ascii(0x97); line = VIEWDATA_RIGHT.repeat(offset ? offset-1 : 0)+VIEWDATA_MOSIAC_WHITE;
for (var y = 0; y < qr.size; y=y+2) { for (var y = 0; y < qr.size; y=y+2) {
line += ascii(0x23); line += ascii(0x23);
} }
@ -461,10 +471,10 @@ function VIEWDATAFrame() {
line += ascii(0x21); line += ascii(0x21);
} }
qrcode += line+' '.repeat(VIEWDATA_FRAME_WIDTH-Math.ceil(qr.size/2)-2-offset-(y%2 ? 0 : 1)); qrcode += line+' '.repeat(repeat_count > 0 ? repeat_count : 0);
} }
write_raw(qrcode+VIEWDATA_DOWN); write_raw(qrcode);
}; };
this.save=function() { this.save=function() {

24
main.js
View File

@ -37,7 +37,8 @@ while(bbs.online) {
var timeout = false; // Track our inactivity timeout var timeout = false; // Track our inactivity timeout
var timer = time(); var timer = time();
var control = []; // Methods that need to process input var control = []; // Methods that need to process input
var extendedkey = ''; // Current Extended Key being captured var extendedkey = ''; // Current Extended Key being captured
var viewdata = (client.socket.local_port !== 516);
while (action != ACTION_TERMINATE && action !=ACTION_EXIT) { while (action != ACTION_TERMINATE && action !=ACTION_EXIT) {
bbs.nodesync(); // @todo Stop the display of telegrams bbs.nodesync(); // @todo Stop the display of telegrams
@ -180,6 +181,10 @@ while(bbs.online) {
break; break;
case '_':
if (! viewdata)
break;
case '#': case '#':
log(LOG_DEBUG,'- false: Key ['+read+'] ['+pageStr(fo)+']'); log(LOG_DEBUG,'- false: Key ['+read+'] ['+pageStr(fo)+']');
if (fo.index !== 'z') { if (fo.index !== 'z') {
@ -322,7 +327,7 @@ while(bbs.online) {
} }
} }
if (read == '#' || read == '\r') { if ((vewdata && read=='_') || (! viewdata && read == '#') || read == '\r') {
// Nothing typed between * and # // Nothing typed between * and #
// *# means go back // *# means go back
if (cmd == '') { if (cmd == '') {
@ -389,6 +394,9 @@ while(bbs.online) {
switch (read) { switch (read) {
// End of field entry. // End of field entry.
case '_':
if (! viewdata) break;
case '#': case '#':
case '\r': case '\r':
log(LOG_DEBUG,'- MODE_FIELD:FRAME_TYPE_RESPONSE: # ['+read+']'); log(LOG_DEBUG,'- MODE_FIELD:FRAME_TYPE_RESPONSE: # ['+read+']');
@ -649,7 +657,7 @@ while(bbs.online) {
case MODE_RFERROR: case MODE_RFERROR:
fo.cursorOff(); fo.cursorOff();
if (read == '#') { if ((viewdata && read == '_') || (! viewdata && read == '#')) {
/* /*
if ($x = $this->fo->route(2) AND $x !== '*' AND is_numeric($x)) { if ($x = $this->fo->route(2) AND $x !== '*' AND is_numeric($x)) {
$next_page = ['frame'=>$x]; $next_page = ['frame'=>$x];
@ -728,7 +736,7 @@ while(bbs.online) {
// If we are editing a specific frame, attempt to load it // If we are editing a specific frame, attempt to load it
if (fe) { if (fe) {
current = fo; current = fo;
fo = (client.socket.local_port !== 516) ? new ANSIFrame() : new VIEWDATAFrame(); fo = viewdata ? new ANSIFrame() : new VIEWDATAFrame();
fo.load(pageStr(fe)); fo.load(pageStr(fe));
// If the frame doesnt exist, check that the parent frame exists in case we are creating a new one // If the frame doesnt exist, check that the parent frame exists in case we are creating a new one
@ -737,7 +745,7 @@ while(bbs.online) {
// We can always create an 'a' frame // We can always create an 'a' frame
if (fe.index !== 'a') { if (fe.index !== 'a') {
fo = (client.socket.local_port !== 516) ? new ANSIFrame() : new VIEWDATAFrame(); fo = viewdata ? new ANSIFrame() : new VIEWDATAFrame();
fo.load(pageStr({frame: fe.frame, index: String.fromCharCode(fe.index.charCodeAt(0)-1)})); fo.load(pageStr({frame: fe.frame, index: String.fromCharCode(fe.index.charCodeAt(0)-1)}));
log(LOG_DEBUG,'- ACTION_EDIT: check index: '+JSON.stringify(fo)+' ('+String.fromCharCode(fe.index.charCodeAt(0)-1)+')'); log(LOG_DEBUG,'- ACTION_EDIT: check index: '+JSON.stringify(fo)+' ('+String.fromCharCode(fe.index.charCodeAt(0)-1)+')');
@ -751,7 +759,7 @@ while(bbs.online) {
} }
// New frame // New frame
fo = (client.socket.local_port !== 516) ? new ANSIFrame() : new VIEWDATAFrame(); fo = viewdata ? new ANSIFrame() : new VIEWDATAFrame();
fo.frame = fe.frame; fo.frame = fe.frame;
fo.index = fe.index; fo.index = fe.index;
fo.cost = 0; fo.cost = 0;
@ -790,7 +798,7 @@ while(bbs.online) {
if (next_page !== null) { if (next_page !== null) {
current = fo; current = fo;
fo = (client.socket.local_port !== 516) ? new ANSIFrame() : new VIEWDATAFrame(); fo = viewdata ? new ANSIFrame() : new VIEWDATAFrame();
fo.load(pageStr(next_page)); fo.load(pageStr(next_page));
if (fo.page == null) { if (fo.page == null) {
@ -798,7 +806,7 @@ while(bbs.online) {
// In case the frame doesnt exist // In case the frame doesnt exist
if (fo == null) if (fo == null)
fo = (client.socket.local_port !== 516) ? new ANSIFrame() : new VIEWDATAFrame(); fo = viewdata ? new ANSIFrame() : new VIEWDATAFrame();
// sendbaseline ERR_PAGE // sendbaseline ERR_PAGE
fo.sendBaseline('ERR_ROUTE',false); fo.sendBaseline('ERR_ROUTE',false);