From f05c11d5a220c81a4def3168c584df19cd5be49b Mon Sep 17 00:00:00 2001 From: Deon George Date: Mon, 17 Aug 2020 20:18:51 +1000 Subject: [PATCH] Auto space QR render and more fixes for viewdata frames --- load/viewdataframe.js | 5 ++--- main.js | 19 +++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/load/viewdataframe.js b/load/viewdataframe.js index 2aa257b..b3aba6e 100644 --- a/load/viewdataframe.js +++ b/load/viewdataframe.js @@ -411,11 +411,10 @@ function VIEWDATAFrame() { return output; }; - this.qrcode = function(qr,subframe) { - var offset = 18; + this.qrcode = function(qr) { // Render the body var qrcode = VIEWDATA_HOME+VIEWDATA_DOWN.repeat(5); - //var line = ''; + var offset = VIEWDATA_FRAME_WIDTH-Math.ceil(qr.size/2)-1; for (var x = -1; x < qr.size; x=x+3) { var line = VIEWDATA_RIGHT.repeat(offset ? offset-1 : 0)+VIEWDATA_MOSIAC_WHITE; diff --git a/main.js b/main.js index 6df8b4e..53c214e 100644 --- a/main.js +++ b/main.js @@ -38,7 +38,7 @@ while(bbs.online) { var timer = time(); var control = []; // Methods that need to process input var extendedkey = ''; // Current Extended Key being captured - var viewdata = (client.socket.local_port !== 516); + var viewdata = (client.socket.local_port == 516); while (action != ACTION_TERMINATE && action !=ACTION_EXIT) { bbs.nodesync(); // @todo Stop the display of telegrams @@ -182,9 +182,7 @@ while(bbs.online) { break; case '_': - if (! viewdata) - break; - + if (! viewdata) break; case '#': log(LOG_DEBUG,'- false: Key ['+read+'] ['+pageStr(fo)+']'); if (fo.index !== 'z') { @@ -371,6 +369,8 @@ while(bbs.online) { // Login frame. case FRAME_TYPE_LOGIN: switch (read) { + case '_': + if (! viewdata) break; case '#': case '\r': log(LOG_DEBUG,'- MODE_FIELD:FRAME_TYPE_LOGIN: ['+read+'] A'); @@ -396,7 +396,6 @@ while(bbs.online) { // End of field entry. case '_': if (! viewdata) break; - case '#': case '\r': log(LOG_DEBUG,'- MODE_FIELD:FRAME_TYPE_RESPONSE: # ['+read+']'); @@ -736,7 +735,7 @@ while(bbs.online) { // If we are editing a specific frame, attempt to load it if (fe) { current = fo; - fo = viewdata ? new ANSIFrame() : new VIEWDATAFrame(); + fo = viewdata ? new VIEWDATAFrame() : new ANSIFrame(); fo.load(pageStr(fe)); // If the frame doesnt exist, check that the parent frame exists in case we are creating a new one @@ -745,7 +744,7 @@ while(bbs.online) { // We can always create an 'a' frame if (fe.index !== 'a') { - fo = viewdata ? new ANSIFrame() : new VIEWDATAFrame(); + fo = viewdata ? new VIEWDATAFrame() : new ANSIFrame(); 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)+')'); @@ -759,7 +758,7 @@ while(bbs.online) { } // New frame - fo = viewdata ? new ANSIFrame() : new VIEWDATAFrame(); + fo = viewdata ? new VIEWDATAFrame() : new ANSIFrame(); fo.frame = fe.frame; fo.index = fe.index; fo.cost = 0; @@ -798,7 +797,7 @@ while(bbs.online) { if (next_page !== null) { current = fo; - fo = viewdata ? new ANSIFrame() : new VIEWDATAFrame(); + fo = viewdata ? new VIEWDATAFrame() : new ANSIFrame(); fo.load(pageStr(next_page)); if (fo.page == null) { @@ -806,7 +805,7 @@ while(bbs.online) { // In case the frame doesnt exist if (fo == null) - fo = viewdata ? new ANSIFrame() : new VIEWDATAFrame(); + fo = viewdata ? new VIEWDATAFrame() : new ANSIFrame(); // sendbaseline ERR_PAGE fo.sendBaseline('ERR_ROUTE',false);