More code formatting and fix SQRL

This commit is contained in:
Deon George 2022-04-16 15:36:17 +10:00
parent 756bebd3d7
commit aae10fbc36
12 changed files with 182 additions and 168 deletions

View File

@ -31,7 +31,7 @@ function getKey(page,signed) {
// If it was signed, is the key a value one // If it was signed, is the key a value one
if (signed && signed.length) { if (signed && signed.length) {
if (pk == signed) { if (pk === signed) {
//print('SIGNED key is valid:' + signed); //print('SIGNED key is valid:' + signed);
key = signed; key = signed;
throw BreakException; throw BreakException;
@ -73,7 +73,7 @@ function msgBaseExport(msgbase) {
} }
// If pointer doesnt exist, reset it from the message base. // If pointer doesnt exist, reset it from the message base.
if (export_ptr == undefined) { if (export_ptr === undefined) {
var f = new File(file_getcase(msgbase.file+'.sbl')); var f = new File(file_getcase(msgbase.file+'.sbl'));
if (f.open('rb')) { if (f.open('rb')) {
@ -108,7 +108,7 @@ function msgBaseExport(msgbase) {
highest = idx.number; highest = idx.number;
// Only check messages from Videotex // Only check messages from Videotex
if (idx.from != crc16_calc('videotex')) { if (idx.from !== crc16_calc('videotex')) {
log(LOG_DEBUG,'! IGNORING: Message offset ['+i+'] in ['+msgbase.file+']'); log(LOG_DEBUG,'! IGNORING: Message offset ['+i+'] in ['+msgbase.file+']');
continue; continue;
} }
@ -212,7 +212,7 @@ function msgBaseExport(msgbase) {
} }
f.close(); f.close();
if (signed != getKey(frame.frame,signed)) { if (signed !== getKey(frame.frame,signed)) {
log(LOG_ERROR,'! ERROR: Key ['+signed+' is not authorised for message offset ['+i+'] in ['+msgbase.file+']'); log(LOG_ERROR,'! ERROR: Key ['+signed+' is not authorised for message offset ['+i+'] in ['+msgbase.file+']');
continue; continue;
} }

View File

@ -90,6 +90,6 @@ const HOME_FRAME_AUTH ={frame: 98,index: 'b'};
const HOME_FRAME_CONNECT ={frame: 980,index: 'a'}; const HOME_FRAME_CONNECT ={frame: 980,index: 'a'};
/* Attributes saved/loaded from files */ /* Attributes saved/loaded from files */
const SAVED_FRAME_ATTRS =['version','frame','index','owner','cost','content','isPublic','isAccessible','type','key']; const SAVED_FRAME_ATTRS =['version','frame','frame_fields','index','owner','cost','content','isPublic','isAccessible','type','key'];
this; this;

View File

@ -30,8 +30,8 @@ function edit(fo) {
const frame = new Frame(1,1,console.screen_columns,console.screen_rows,BG_BLACK|LIGHTGRAY); const frame = new Frame(1,1,console.screen_columns,console.screen_rows,BG_BLACK|LIGHTGRAY);
frame.gotoxy(1,1); frame.gotoxy(1,1);
header = '\1n'+fo.pageownerlogo+' '.repeat(fo.FRAME_PAGENUM-console.strlen(fo.pageownerlogo))+'\1n '+ header = '\1n'+fo.pageownerlogo+' '.repeat(fo.settings.FRAME_HEADER-console.strlen(fo.pageownerlogo))+'\1n '+
'\1W\1H'+fo.page+' '.repeat(fo.FRAME_PAGENUM-fo.page.length)+' '+ '\1W\1H'+fo.page+' '.repeat(fo.settings.FRAME_PAGENUM-fo.page.length)+' '+
'\1G\1H'+' Edit'; '\1G\1H'+' Edit';
frame.putmsg(header); frame.putmsg(header);
frame.open(); frame.open();
@ -74,8 +74,33 @@ function edit(fo) {
frame.cycle(); frame.cycle();
this.handle=function(read) { this.handle=function(read) {
if (! js.terminated && ascii(read) != 27) { if (! js.terminated) {
switch (ascii(read)) {
case 26:
if (inProperty) {
propFrame.close();
frame.top();
frame.cycle();
inProperty = false;
} else {
properties();
}
return '';
case 27:
if (inProperty) {
log(LOG_DEBUG, ' + FrameEdit properties(): ESC');
propFrame.close();
frame.top();
frame.cycle();
inProperty = false;
}
return '';
default:
if (inProperty) { if (inProperty) {
log(LOG_DEBUG, ' + FrameEdit properties(): read'); log(LOG_DEBUG, ' + FrameEdit properties(): read');
propFrame.putmsg(read); propFrame.putmsg(read);
@ -89,25 +114,12 @@ function edit(fo) {
if (! complete) if (! complete)
return ''; return '';
// Ignore esc
} else if (ascii(read) == 27) {
if (inProperty) {
log(LOG_DEBUG, ' + FrameEdit properties(): ESC');
propFrame.close();
frame.top();
frame.cycle();
inProperty = false;
} }
return '';
} }
editor.close(); editor.close();
frame.close(); frame.close();
fo.render();
console.clear(LIGHTGRAY);
console.putmsg(fo.render());
return ''; return '';
} }

View File

@ -95,7 +95,7 @@ function FrameAnsi() {
(console.screen_columns > 80 ? '\n\r' : ''); (console.screen_columns > 80 ? '\n\r' : '');
} }
console.clear(); console.clear(LIGHTGRAY);
return console.putmsg(header+this.parse(base64_decode(this.content))); return console.putmsg(header+this.parse(base64_decode(this.content)));
}; };
@ -124,7 +124,7 @@ function FrameAnsi() {
for (var y = 0; y < qr.size; y++) { for (var y = 0; y < qr.size; y++) {
// Top is white // Top is white
if (((x==-1)? 0 : qr.getModule(x, y)) == 0) { if (! ((x===-1)? 0 : qr.getModule(x, y))) {
line += (qr.getModule(x+1, y)) ? top : full; line += (qr.getModule(x+1, y)) ? top : full;
// Top is black // Top is black

View File

@ -97,7 +97,7 @@ function PageFrame() {
*/ */
Object.defineProperty(this,'page', { Object.defineProperty(this,'page', {
get: function() { get: function() {
if (this.frame == null || this.index == null) return null; if (this.frame === null || this.index === null) return null;
return this.frame.toString()+this.index; return this.frame.toString()+this.index;
} }
}); });
@ -239,7 +239,7 @@ PageFrame.prototype.parse = function(text) {
match = text.substr(p,cte).match(/[\r\n\x1b]/); match = text.substr(p,cte).match(/[\r\n\x1b]/);
//log(LOG_DEBUG,'SPECIAL CHAR ['+r+'x'+c+'] ['+p+'-'+cte+'] for: '+match); //log(LOG_DEBUG,'SPECIAL CHAR ['+r+'x'+c+'] ['+p+'-'+cte+'] for: '+match);
if (match == null || match.index) { if (match === null || match.index) {
advance = match ? match.index : cte; advance = match ? match.index : cte;
//log(LOG_DEBUG,'INCLUDE: '+text.substr(p,advance)); //log(LOG_DEBUG,'INCLUDE: '+text.substr(p,advance));

View File

@ -140,17 +140,17 @@ function FrameViewdata() {
var char = 0; var char = 0;
//TL //TL
char |= ((x==-1) || (y==-1) || ! qr.getModule(x,y)) ? (1<<0) : (0<<0); char |= ((x===-1) || (y===-1) || ! qr.getModule(x,y)) ? (1<<0) : (0<<0);
//TR //TR
char |= ((x==-1) || (y == qr.size-1) || ! qr.getModule(x,y+1)) ? (1<<1) : (0<<1); char |= ((x===-1) || (y === qr.size-1) || ! qr.getModule(x,y+1)) ? (1<<1) : (0<<1);
//ML //ML
char |= ((y==-1) || ! qr.getModule(x+1,y)) ? (1<<2) : (0<<2); char |= ((y===-1) || ! qr.getModule(x+1,y)) ? (1<<2) : (0<<2);
//MR //MR
char |= ((y == qr.size-1) || ! qr.getModule(x+1,y+1)) ? (1<<3) : (0<<3); char |= ((y === qr.size-1) || ! qr.getModule(x+1,y+1)) ? (1<<3) : (0<<3);
//BL //BL
char |= ((x==qr.size-2) || (y==-1) || ! qr.getModule(x+2,y)) ? (1<<4) : (0<<4); char |= ((x===qr.size-2) || (y===-1) || ! qr.getModule(x+2,y)) ? (1<<4) : (0<<4);
//BR //BR
char |= ((x==qr.size-2) || (y == qr.size-1) || ! qr.getModule(x+2,y+1)) ? (1<<5) : (0<<5); char |= ((x===qr.size-2) || (y === qr.size-1) || ! qr.getModule(x+2,y+1)) ? (1<<5) : (0<<5);
char += 0x20; char += 0x20;
if (char > 0x3f) if (char > 0x3f)
@ -163,7 +163,7 @@ function FrameViewdata() {
if (y%2) if (y%2)
line += ascii(0x35); line += ascii(0x35);
repeat_count = this.settings.FRAME_WIDTH-Math.ceil(qr.size/2)-offset-(offset ? 1 : 2)-(y%2 == 1 ? 0 : 1); repeat_count = this.settings.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); qrcode += line+' '.repeat(repeat_count > 0 ? repeat_count : 0);
@ -186,7 +186,7 @@ function FrameViewdata() {
} }
// Render the right column // Render the right column
if (y%2 == 0) { if (y%2 === 0) {
line += ascii(0x21); line += ascii(0x21);
} }

View File

@ -7,22 +7,22 @@ load('graphic.js');
if (!String.prototype.repeat) { if (!String.prototype.repeat) {
String.prototype.repeat = function(count) { String.prototype.repeat = function(count) {
'use strict'; 'use strict';
if (this == null) { if (this === null) {
throw new TypeError('can\'t convert ' + this + ' to object'); throw new TypeError('can\'t convert ' + this + ' to object');
} }
var str = '' + this; var str = '' + this;
count = +count; count = +count;
if (count != count) { if (count !== count) {
count = 0; count = 0;
} }
if (count < 0) { if (count < 0) {
throw new RangeError('repeat count must be non-negative'); throw new RangeError('repeat count must be non-negative: '+count);
} }
if (count == Infinity) { if (count === Infinity) {
throw new RangeError('repeat count must be less than infinity'); throw new RangeError('repeat count must be less than infinity');
} }
count = Math.floor(count); count = Math.floor(count);
if (str.length == 0 || count == 0) { if (str.length === 0 || count === 0) {
return ''; return '';
} }
// Ensuring count is a 31-bit integer allows us to heavily optimize the // Ensuring count is a 31-bit integer allows us to heavily optimize the
@ -33,11 +33,11 @@ if (!String.prototype.repeat) {
} }
var rpt = ''; var rpt = '';
for (;;) { for (;;) {
if ((count & 1) == 1) { if ((count & 1) === 1) {
rpt += str; rpt += str;
} }
count >>>= 1; count >>>= 1;
if (count == 0) { if (count === 0) {
break; break;
} }
str += str; str += str;
@ -86,7 +86,7 @@ function findMsgBase(code) {
for (var s in msg_area.sub) { for (var s in msg_area.sub) {
var sub = msg_area.sub[s]; var sub = msg_area.sub[s];
if (sub.code.substr(-code.length).toLowerCase() == code) if (sub.code.substr(-code.length).toLowerCase() === code)
return sub.code; return sub.code;
} }
@ -98,6 +98,7 @@ function findMsgBase(code) {
* *
* @param key * @param key
* @param error * @param error
* @param abort
*/ */
function getArg(key,error,abort) { function getArg(key,error,abort) {
index = argv.indexOf(key); index = argv.indexOf(key);

View File

@ -1,4 +1,4 @@
"use strict"; 'use strict';
/* /*
* Module "qrcodegen", public members: * Module "qrcodegen", public members:
* - Class QrCode: * - Class QrCode:
@ -37,11 +37,11 @@ var qrcodegen = new function() {
// Check scalar arguments // Check scalar arguments
if (version < MIN_VERSION || version > MAX_VERSION) if (version < MIN_VERSION || version > MAX_VERSION)
throw "Version value out of range"; throw 'Version value out of range';
if (mask < -1 || mask > 7) if (mask < -1 || mask > 7)
throw "Mask value out of range"; throw 'Mask value out of range';
if (!(errCorLvl instanceof Ecc)) if (!(errCorLvl instanceof Ecc))
throw "QrCode.Ecc expected"; throw 'QrCode.Ecc expected';
var size = version * 4 + 17; var size = version * 4 + 17;
// Initialize both grids to be size*size arrays of Boolean false // Initialize both grids to be size*size arrays of Boolean false
@ -61,7 +61,7 @@ var qrcodegen = new function() {
drawCodewords(allCodewords); drawCodewords(allCodewords);
// Do masking // Do masking
if (mask == -1) { // Automatically choose best mask if (mask === -1) { // Automatically choose best mask
var minPenalty = Infinity; var minPenalty = Infinity;
for (var i = 0; i < 8; i++) { for (var i = 0; i < 8; i++) {
applyMask(i); applyMask(i);
@ -75,7 +75,7 @@ var qrcodegen = new function() {
} }
} }
if (mask < 0 || mask > 7) if (mask < 0 || mask > 7)
throw "Assertion error"; throw 'Assertion error';
applyMask(mask); // Apply the final choice of mask applyMask(mask); // Apply the final choice of mask
drawFormatBits(mask); // Overwrite old format bits drawFormatBits(mask); // Overwrite old format bits
@ -86,19 +86,19 @@ var qrcodegen = new function() {
// The version number of this QR Code, which is between 1 and 40 (inclusive). // The version number of this QR Code, which is between 1 and 40 (inclusive).
// This determines the size of this barcode. // This determines the size of this barcode.
Object.defineProperty(this, "version", {value:version}); Object.defineProperty(this, 'version', {value:version});
// The width and height of this QR Code, measured in modules, between // The width and height of this QR Code, measured in modules, between
// 21 and 177 (inclusive). This is equal to version * 4 + 17. // 21 and 177 (inclusive). This is equal to version * 4 + 17.
Object.defineProperty(this, "size", {value:size}); Object.defineProperty(this, 'size', {value:size});
// The error correction level used in this QR Code. // The error correction level used in this QR Code.
Object.defineProperty(this, "errorCorrectionLevel", {value:errCorLvl}); Object.defineProperty(this, 'errorCorrectionLevel', {value:errCorLvl});
// The index of the mask pattern used in this QR Code, which is between 0 and 7 (inclusive). // The index of the mask pattern used in this QR Code, which is between 0 and 7 (inclusive).
// Even if a QR Code is created with automatic masking requested (mask = -1), // Even if a QR Code is created with automatic masking requested (mask = -1),
// the resulting object still has a mask value between 0 and 7. // the resulting object still has a mask value between 0 and 7.
Object.defineProperty(this, "mask", {value:mask}); Object.defineProperty(this, 'mask', {value:mask});
/*---- Accessor methods ----*/ /*---- Accessor methods ----*/
@ -119,14 +119,14 @@ var qrcodegen = new function() {
// The scale must be a positive integer and the border must be a non-negative integer. // The scale must be a positive integer and the border must be a non-negative integer.
this.drawCanvas = function(scale, border, canvas) { this.drawCanvas = function(scale, border, canvas) {
if (scale <= 0 || border < 0) if (scale <= 0 || border < 0)
throw "Value out of range"; throw 'Value out of range';
var width = (size + border * 2) * scale; var width = (size + border * 2) * scale;
canvas.width = width; canvas.width = width;
canvas.height = width; canvas.height = width;
var ctx = canvas.getContext("2d"); var ctx = canvas.getContext('2d');
for (var y = -border; y < size + border; y++) { for (var y = -border; y < size + border; y++) {
for (var x = -border; x < size + border; x++) { for (var x = -border; x < size + border; x++) {
ctx.fillStyle = this.getModule(x, y) ? "#000000" : "#FFFFFF"; ctx.fillStyle = this.getModule(x, y) ? '#000000' : '#FFFFFF';
ctx.fillRect((x + border) * scale, (y + border) * scale, scale, scale); ctx.fillRect((x + border) * scale, (y + border) * scale, scale, scale);
} }
} }
@ -136,12 +136,12 @@ var qrcodegen = new function() {
// of border modules. The string always uses Unix newlines (\n), regardless of the platform. // of border modules. The string always uses Unix newlines (\n), regardless of the platform.
this.toSvgString = function(border) { this.toSvgString = function(border) {
if (border < 0) if (border < 0)
throw "Border must be non-negative"; throw 'Border must be non-negative';
var parts = []; var parts = [];
for (var y = 0; y < size; y++) { for (var y = 0; y < size; y++) {
for (var x = 0; x < size; x++) { for (var x = 0; x < size; x++) {
if (this.getModule(x, y)) if (this.getModule(x, y))
parts.push("M" + (x + border) + "," + (y + border) + "h1v1h-1z"); parts.push('M' + (x + border) + ',' + (y + border) + 'h1v1h-1z');
} }
} }
return '<?xml version="1.0" encoding="UTF-8"?>\n' + return '<?xml version="1.0" encoding="UTF-8"?>\n' +
@ -160,8 +160,8 @@ var qrcodegen = new function() {
function drawFunctionPatterns() { function drawFunctionPatterns() {
// Draw horizontal and vertical timing patterns // Draw horizontal and vertical timing patterns
for (var i = 0; i < size; i++) { for (var i = 0; i < size; i++) {
setFunctionModule(6, i, i % 2 == 0); setFunctionModule(6, i, i % 2 === 0);
setFunctionModule(i, 6, i % 2 == 0); setFunctionModule(i, 6, i % 2 === 0);
} }
// Draw 3 finder patterns (all corners except bottom right; overwrites some timing modules) // Draw 3 finder patterns (all corners except bottom right; overwrites some timing modules)
@ -175,7 +175,7 @@ var qrcodegen = new function() {
for (var i = 0; i < numAlign; i++) { for (var i = 0; i < numAlign; i++) {
for (var j = 0; j < numAlign; j++) { for (var j = 0; j < numAlign; j++) {
// Don't draw on the three finder corners // Don't draw on the three finder corners
if (!(i == 0 && j == 0 || i == 0 && j == numAlign - 1 || i == numAlign - 1 && j == 0)) if (!(i === 0 && j === 0 || i === 0 && j === numAlign - 1 || i === numAlign - 1 && j === 0))
drawAlignmentPattern(alignPatPos[i], alignPatPos[j]); drawAlignmentPattern(alignPatPos[i], alignPatPos[j]);
} }
} }
@ -195,8 +195,8 @@ var qrcodegen = new function() {
for (var i = 0; i < 10; i++) for (var i = 0; i < 10; i++)
rem = (rem << 1) ^ ((rem >>> 9) * 0x537); rem = (rem << 1) ^ ((rem >>> 9) * 0x537);
var bits = (data << 10 | rem) ^ 0x5412; // uint15 var bits = (data << 10 | rem) ^ 0x5412; // uint15
if (bits >>> 15 != 0) if (bits >>> 15 !== 0)
throw "Assertion error"; throw 'Assertion error';
// Draw first copy // Draw first copy
for (var i = 0; i <= 5; i++) for (var i = 0; i <= 5; i++)
@ -227,8 +227,8 @@ var qrcodegen = new function() {
for (var i = 0; i < 12; i++) for (var i = 0; i < 12; i++)
rem = (rem << 1) ^ ((rem >>> 11) * 0x1F25); rem = (rem << 1) ^ ((rem >>> 11) * 0x1F25);
var bits = version << 12 | rem; // uint18 var bits = version << 12 | rem; // uint18
if (bits >>> 18 != 0) if (bits >>> 18 !== 0)
throw "Assertion error"; throw 'Assertion error';
// Draw two copies // Draw two copies
for (var i = 0; i < 18; i++) { for (var i = 0; i < 18; i++) {
@ -249,7 +249,7 @@ var qrcodegen = new function() {
var dist = Math.max(Math.abs(dx), Math.abs(dy)); // Chebyshev/infinity norm var dist = Math.max(Math.abs(dx), Math.abs(dy)); // Chebyshev/infinity norm
var xx = x + dx, yy = y + dy; var xx = x + dx, yy = y + dy;
if (0 <= xx && xx < size && 0 <= yy && yy < size) if (0 <= xx && xx < size && 0 <= yy && yy < size)
setFunctionModule(xx, yy, dist != 2 && dist != 4); setFunctionModule(xx, yy, dist !== 2 && dist !== 4);
} }
} }
} }
@ -260,7 +260,7 @@ var qrcodegen = new function() {
function drawAlignmentPattern(x, y) { function drawAlignmentPattern(x, y) {
for (var dy = -2; dy <= 2; dy++) { for (var dy = -2; dy <= 2; dy++) {
for (var dx = -2; dx <= 2; dx++) for (var dx = -2; dx <= 2; dx++)
setFunctionModule(x + dx, y + dy, Math.max(Math.abs(dx), Math.abs(dy)) != 1); setFunctionModule(x + dx, y + dy, Math.max(Math.abs(dx), Math.abs(dy)) !== 1);
} }
} }
@ -278,8 +278,8 @@ var qrcodegen = new function() {
// Returns a new byte string representing the given data with the appropriate error correction // Returns a new byte string representing the given data with the appropriate error correction
// codewords appended to it, based on this object's version and error correction level. // codewords appended to it, based on this object's version and error correction level.
function addEccAndInterleave(data) { function addEccAndInterleave(data) {
if (data.length != QrCode.getNumDataCodewords(version, errCorLvl)) if (data.length !== QrCode.getNumDataCodewords(version, errCorLvl))
throw "Invalid argument"; throw 'Invalid argument';
// Calculate parameter numbers // Calculate parameter numbers
var numBlocks = QrCode.NUM_ERROR_CORRECTION_BLOCKS[errCorLvl.ordinal][version]; var numBlocks = QrCode.NUM_ERROR_CORRECTION_BLOCKS[errCorLvl.ordinal][version];
@ -305,12 +305,12 @@ var qrcodegen = new function() {
for (var i = 0; i < blocks[0].length; i++) { for (var i = 0; i < blocks[0].length; i++) {
for (var j = 0; j < blocks.length; j++) { for (var j = 0; j < blocks.length; j++) {
// Skip the padding byte in short blocks // Skip the padding byte in short blocks
if (i != shortBlockLen - blockEccLen || j >= numShortBlocks) if (i !== shortBlockLen - blockEccLen || j >= numShortBlocks)
result.push(blocks[j][i]); result.push(blocks[j][i]);
} }
} }
if (result.length != rawCodewords) if (result.length !== rawCodewords)
throw "Assertion error"; throw 'Assertion error';
return result; return result;
} }
@ -318,17 +318,17 @@ var qrcodegen = new function() {
// Draws the given sequence of 8-bit codewords (data and error correction) onto the entire // Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
// data area of this QR Code. Function modules need to be marked off before this is called. // data area of this QR Code. Function modules need to be marked off before this is called.
function drawCodewords(data) { function drawCodewords(data) {
if (data.length != Math.floor(QrCode.getNumRawDataModules(version) / 8)) if (data.length !== Math.floor(QrCode.getNumRawDataModules(version) / 8))
throw "Invalid argument"; throw 'Invalid argument';
var i = 0; // Bit index into the data var i = 0; // Bit index into the data
// Do the funny zigzag scan // Do the funny zigzag scan
for (var right = size - 1; right >= 1; right -= 2) { // Index of right column in each column pair for (var right = size - 1; right >= 1; right -= 2) { // Index of right column in each column pair
if (right == 6) if (right === 6)
right = 5; right = 5;
for (var vert = 0; vert < size; vert++) { // Vertical counter for (var vert = 0; vert < size; vert++) { // Vertical counter
for (var j = 0; j < 2; j++) { for (var j = 0; j < 2; j++) {
var x = right - j; // Actual x coordinate var x = right - j; // Actual x coordinate
var upward = ((right + 1) & 2) == 0; var upward = ((right + 1) & 2) === 0;
var y = upward ? size - 1 - vert : vert; // Actual y coordinate var y = upward ? size - 1 - vert : vert; // Actual y coordinate
if (!isFunction[y][x] && i < data.length * 8) { if (!isFunction[y][x] && i < data.length * 8) {
modules[y][x] = getBit(data[i >>> 3], 7 - (i & 7)); modules[y][x] = getBit(data[i >>> 3], 7 - (i & 7));
@ -339,8 +339,8 @@ var qrcodegen = new function() {
} }
} }
} }
if (i != data.length * 8) if (i !== data.length * 8)
throw "Assertion error"; throw 'Assertion error';
} }
@ -351,20 +351,20 @@ var qrcodegen = new function() {
// QR Code needs exactly one (not zero, two, etc.) mask applied. // QR Code needs exactly one (not zero, two, etc.) mask applied.
function applyMask(mask) { function applyMask(mask) {
if (mask < 0 || mask > 7) if (mask < 0 || mask > 7)
throw "Mask value out of range"; throw 'Mask value out of range';
for (var y = 0; y < size; y++) { for (var y = 0; y < size; y++) {
for (var x = 0; x < size; x++) { for (var x = 0; x < size; x++) {
var invert; var invert;
switch (mask) { switch (mask) {
case 0: invert = (x + y) % 2 == 0; break; case 0: invert = (x + y) % 2 === 0; break;
case 1: invert = y % 2 == 0; break; case 1: invert = y % 2 === 0; break;
case 2: invert = x % 3 == 0; break; case 2: invert = x % 3 === 0; break;
case 3: invert = (x + y) % 3 == 0; break; case 3: invert = (x + y) % 3 === 0; break;
case 4: invert = (Math.floor(x / 3) + Math.floor(y / 2)) % 2 == 0; break; case 4: invert = (Math.floor(x / 3) + Math.floor(y / 2)) % 2 === 0; break;
case 5: invert = x * y % 2 + x * y % 3 == 0; break; case 5: invert = x * y % 2 + x * y % 3 === 0; break;
case 6: invert = (x * y % 2 + x * y % 3) % 2 == 0; break; case 6: invert = (x * y % 2 + x * y % 3) % 2 === 0; break;
case 7: invert = ((x + y) % 2 + x * y % 3) % 2 == 0; break; case 7: invert = ((x + y) % 2 + x * y % 3) % 2 === 0; break;
default: throw "Assertion error"; default: throw 'Assertion error';
} }
if (!isFunction[y][x] && invert) if (!isFunction[y][x] && invert)
modules[y][x] = !modules[y][x]; modules[y][x] = !modules[y][x];
@ -384,9 +384,9 @@ var qrcodegen = new function() {
var color = false; var color = false;
var runX = 0; var runX = 0;
for (var x = 0; x < size; x++) { for (var x = 0; x < size; x++) {
if (modules[y][x] == color) { if (modules[y][x] === color) {
runX++; runX++;
if (runX == 5) if (runX === 5)
result += QrCode.PENALTY_N1; result += QrCode.PENALTY_N1;
else if (runX > 5) else if (runX > 5)
result++; result++;
@ -410,9 +410,9 @@ var qrcodegen = new function() {
var color = false; var color = false;
var runY = 0; var runY = 0;
for (var y = 0; y < size; y++) { for (var y = 0; y < size; y++) {
if (modules[y][x] == color) { if (modules[y][x] === color) {
runY++; runY++;
if (runY == 5) if (runY === 5)
result += QrCode.PENALTY_N1; result += QrCode.PENALTY_N1;
else if (runY > 5) else if (runY > 5)
result++; result++;
@ -435,7 +435,7 @@ var qrcodegen = new function() {
for (var y = 0; y < size - 1; y++) { for (var y = 0; y < size - 1; y++) {
for (var x = 0; x < size - 1; x++) { for (var x = 0; x < size - 1; x++) {
var color = modules[y][x]; var color = modules[y][x];
if (color == modules[y][x + 1] && color == modules[y + 1][x] && color == modules[y + 1][x + 1]) if (color === modules[y][x + 1] && color === modules[y + 1][x] && color === modules[y + 1][x + 1])
result += QrCode.PENALTY_N2; result += QrCode.PENALTY_N2;
} }
} }
@ -448,7 +448,7 @@ var qrcodegen = new function() {
black++; black++;
}); });
}); });
var total = size * size; // Note that size is odd, so black/total != 1/2 var total = size * size; // Note that size is odd, so black/total !== 1/2
// Compute the smallest integer k >= 0 such that (45-5k)% <= black/total <= (55+5k)% // Compute the smallest integer k >= 0 such that (45-5k)% <= black/total <= (55+5k)%
var k = Math.ceil(Math.abs(black * 20 - total * 10) / total) - 1; var k = Math.ceil(Math.abs(black * 20 - total * 10) / total) - 1;
result += k * QrCode.PENALTY_N4; result += k * QrCode.PENALTY_N4;
@ -460,11 +460,11 @@ var qrcodegen = new function() {
// Each position is in the range [0,177), and are used on both the x and y axes. // Each position is in the range [0,177), and are used on both the x and y axes.
// This could be implemented as lookup table of 40 variable-length lists of integers. // This could be implemented as lookup table of 40 variable-length lists of integers.
function getAlignmentPatternPositions() { function getAlignmentPatternPositions() {
if (version == 1) if (version === 1)
return []; return [];
else { else {
var numAlign = Math.floor(version / 7) + 2; var numAlign = Math.floor(version / 7) + 2;
var step = (version == 32) ? 26 : var step = (version === 32) ? 26 :
Math.ceil((size - 13) / (numAlign*2 - 2)) * 2; Math.ceil((size - 13) / (numAlign*2 - 2)) * 2;
var result = [6]; var result = [6];
for (var pos = size - 7; result.length < numAlign; pos -= step) for (var pos = size - 7; result.length < numAlign; pos -= step)
@ -476,7 +476,7 @@ var qrcodegen = new function() {
// Returns true iff the i'th bit of x is set to 1. // Returns true iff the i'th bit of x is set to 1.
function getBit(x, i) { function getBit(x, i) {
return ((x >>> i) & 1) != 0; return ((x >>> i) & 1) !== 0;
} }
}; };
@ -522,12 +522,12 @@ var qrcodegen = new function() {
* This is a mid-level API; the high-level API is encodeText() and encodeBinary(). * This is a mid-level API; the high-level API is encodeText() and encodeBinary().
*/ */
this.QrCode.encodeSegments = function(segs, ecl, minVersion, maxVersion, mask, boostEcl) { this.QrCode.encodeSegments = function(segs, ecl, minVersion, maxVersion, mask, boostEcl) {
if (minVersion == undefined) minVersion = MIN_VERSION; if (minVersion === undefined) minVersion = MIN_VERSION;
if (maxVersion == undefined) maxVersion = MAX_VERSION; if (maxVersion === undefined) maxVersion = MAX_VERSION;
if (mask == undefined) mask = -1; if (mask === undefined) mask = -1;
if (boostEcl == undefined) boostEcl = true; if (boostEcl === undefined) boostEcl = true;
if (!(MIN_VERSION <= minVersion && minVersion <= maxVersion && maxVersion <= MAX_VERSION) || mask < -1 || mask > 7) if (!(MIN_VERSION <= minVersion && minVersion <= maxVersion && maxVersion <= MAX_VERSION) || mask < -1 || mask > 7)
throw "Invalid value"; throw 'Invalid value';
// Find the minimal version number to use // Find the minimal version number to use
var version, dataUsedBits; var version, dataUsedBits;
@ -537,7 +537,7 @@ var qrcodegen = new function() {
if (dataUsedBits <= dataCapacityBits) if (dataUsedBits <= dataCapacityBits)
break; // This version number is found to be suitable break; // This version number is found to be suitable
if (version >= maxVersion) // All versions in the range could not fit the given data if (version >= maxVersion) // All versions in the range could not fit the given data
throw "Data too long"; throw 'Data too long';
} }
// Increase the error correction level while the data still fits in the current version number // Increase the error correction level while the data still fits in the current version number
@ -555,17 +555,17 @@ var qrcodegen = new function() {
bb.push(bit); bb.push(bit);
}); });
}); });
if (bb.length != dataUsedBits) if (bb.length !== dataUsedBits)
throw "Assertion error"; throw 'Assertion error';
// Add terminator and pad up to a byte if applicable // Add terminator and pad up to a byte if applicable
var dataCapacityBits = QrCode.getNumDataCodewords(version, ecl) * 8; var dataCapacityBits = QrCode.getNumDataCodewords(version, ecl) * 8;
if (bb.length > dataCapacityBits) if (bb.length > dataCapacityBits)
throw "Assertion error"; throw 'Assertion error';
bb.appendBits(0, Math.min(4, dataCapacityBits - bb.length)); bb.appendBits(0, Math.min(4, dataCapacityBits - bb.length));
bb.appendBits(0, (8 - bb.length % 8) % 8); bb.appendBits(0, (8 - bb.length % 8) % 8);
if (bb.length % 8 != 0) if (bb.length % 8 !== 0)
throw "Assertion error"; throw 'Assertion error';
// Pad with alternating bytes until data capacity is reached // Pad with alternating bytes until data capacity is reached
for (var padByte = 0xEC; bb.length < dataCapacityBits; padByte ^= 0xEC ^ 0x11) for (var padByte = 0xEC; bb.length < dataCapacityBits; padByte ^= 0xEC ^ 0x11)
@ -594,7 +594,7 @@ var qrcodegen = new function() {
// The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table. // The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.
QrCode.getNumRawDataModules = function(ver) { QrCode.getNumRawDataModules = function(ver) {
if (ver < MIN_VERSION || ver > MAX_VERSION) if (ver < MIN_VERSION || ver > MAX_VERSION)
throw "Version number out of range"; throw 'Version number out of range';
var result = (16 * ver + 128) * ver + 64; var result = (16 * ver + 128) * ver + 64;
if (ver >= 2) { if (ver >= 2) {
var numAlign = Math.floor(ver / 7) + 2; var numAlign = Math.floor(ver / 7) + 2;
@ -629,8 +629,8 @@ var qrcodegen = new function() {
// Must only be called immediately after a run of white modules has ended. // Must only be called immediately after a run of white modules has ended.
QrCode.hasFinderLikePattern = function(runHistory) { QrCode.hasFinderLikePattern = function(runHistory) {
var n = runHistory[1]; var n = runHistory[1];
return n > 0 && runHistory[2] == n && runHistory[4] == n && runHistory[5] == n return n > 0 && runHistory[2] === n && runHistory[4] === n && runHistory[5] === n
&& runHistory[3] == n * 3 && Math.max(runHistory[0], runHistory[6]) >= n * 4; && runHistory[3] === n * 3 && Math.max(runHistory[0], runHistory[6]) >= n * 4;
}; };
@ -638,8 +638,8 @@ var qrcodegen = new function() {
var MIN_VERSION = 1; // The minimum version number supported in the QR Code Model 2 standard var MIN_VERSION = 1; // The minimum version number supported in the QR Code Model 2 standard
var MAX_VERSION = 40; // The maximum version number supported in the QR Code Model 2 standard var MAX_VERSION = 40; // The maximum version number supported in the QR Code Model 2 standard
Object.defineProperty(this.QrCode, "MIN_VERSION", {value:MIN_VERSION}); Object.defineProperty(this.QrCode, 'MIN_VERSION', {value:MIN_VERSION});
Object.defineProperty(this.QrCode, "MAX_VERSION", {value:MAX_VERSION}); Object.defineProperty(this.QrCode, 'MAX_VERSION', {value:MAX_VERSION});
// For use in getPenaltyScore(), when evaluating which mask is best. // For use in getPenaltyScore(), when evaluating which mask is best.
QrCode.PENALTY_N1 = 3; QrCode.PENALTY_N1 = 3;
@ -682,10 +682,10 @@ var qrcodegen = new function() {
// Private constructor. // Private constructor.
function Ecc(ord, fb) { function Ecc(ord, fb) {
// (Public) In the range 0 to 3 (unsigned 2-bit integer) // (Public) In the range 0 to 3 (unsigned 2-bit integer)
Object.defineProperty(this, "ordinal", {value:ord}); Object.defineProperty(this, 'ordinal', {value:ord});
// (Package-private) In the range 0 to 3 (unsigned 2-bit integer) // (Package-private) In the range 0 to 3 (unsigned 2-bit integer)
Object.defineProperty(this, "formatBits", {value:fb}); Object.defineProperty(this, 'formatBits', {value:fb});
} }
@ -709,18 +709,18 @@ var qrcodegen = new function() {
this.QrSegment = function(mode, numChars, bitData) { this.QrSegment = function(mode, numChars, bitData) {
/*---- Constructor (low level) ----*/ /*---- Constructor (low level) ----*/
if (numChars < 0 || !(mode instanceof Mode)) if (numChars < 0 || !(mode instanceof Mode))
throw "Invalid argument"; throw 'Invalid argument';
// The data bits of this segment. Accessed through getData(). // The data bits of this segment. Accessed through getData().
bitData = bitData.slice(); // Make defensive copy bitData = bitData.slice(); // Make defensive copy
// The mode indicator of this segment. // The mode indicator of this segment.
Object.defineProperty(this, "mode", {value:mode}); Object.defineProperty(this, 'mode', {value:mode});
// The length of this segment's unencoded data. Measured in characters for // The length of this segment's unencoded data. Measured in characters for
// numeric/alphanumeric/kanji mode, bytes for byte mode, and 0 for ECI mode. // numeric/alphanumeric/kanji mode, bytes for byte mode, and 0 for ECI mode.
// Always zero or positive. Not the same as the data's bit length. // Always zero or positive. Not the same as the data's bit length.
Object.defineProperty(this, "numChars", {value:numChars}); Object.defineProperty(this, 'numChars', {value:numChars});
// Returns a new copy of the data bits of this segment. // Returns a new copy of the data bits of this segment.
this.getData = function() { this.getData = function() {
@ -750,7 +750,7 @@ var qrcodegen = new function() {
*/ */
this.QrSegment.makeNumeric = function(digits) { this.QrSegment.makeNumeric = function(digits) {
if (!this.NUMERIC_REGEX.test(digits)) if (!this.NUMERIC_REGEX.test(digits))
throw "String contains non-numeric characters"; throw 'String contains non-numeric characters';
var bb = new BitBuffer(); var bb = new BitBuffer();
for (var i = 0; i < digits.length; ) { // Consume up to 3 digits per iteration for (var i = 0; i < digits.length; ) { // Consume up to 3 digits per iteration
var n = Math.min(digits.length - i, 3); var n = Math.min(digits.length - i, 3);
@ -768,7 +768,7 @@ var qrcodegen = new function() {
*/ */
this.QrSegment.makeAlphanumeric = function(text) { this.QrSegment.makeAlphanumeric = function(text) {
if (!this.ALPHANUMERIC_REGEX.test(text)) if (!this.ALPHANUMERIC_REGEX.test(text))
throw "String contains unencodable characters in alphanumeric mode"; throw 'String contains unencodable characters in alphanumeric mode';
var bb = new BitBuffer(); var bb = new BitBuffer();
var i; var i;
for (i = 0; i + 2 <= text.length; i += 2) { // Process groups of 2 for (i = 0; i + 2 <= text.length; i += 2) { // Process groups of 2
@ -788,7 +788,7 @@ var qrcodegen = new function() {
*/ */
this.QrSegment.makeSegments = function(text) { this.QrSegment.makeSegments = function(text) {
// Select the most efficient segment encoding automatically // Select the most efficient segment encoding automatically
if (text == "") if (text === '')
return []; return [];
else if (this.NUMERIC_REGEX.test(text)) else if (this.NUMERIC_REGEX.test(text))
return [this.makeNumeric(text)]; return [this.makeNumeric(text)];
@ -806,7 +806,7 @@ var qrcodegen = new function() {
this.QrSegment.makeEci = function(assignVal) { this.QrSegment.makeEci = function(assignVal) {
var bb = new BitBuffer(); var bb = new BitBuffer();
if (assignVal < 0) if (assignVal < 0)
throw "ECI assignment value out of range"; throw 'ECI assignment value out of range';
else if (assignVal < (1 << 7)) else if (assignVal < (1 << 7))
bb.appendBits(assignVal, 8); bb.appendBits(assignVal, 8);
else if (assignVal < (1 << 14)) { else if (assignVal < (1 << 14)) {
@ -816,7 +816,7 @@ var qrcodegen = new function() {
bb.appendBits(6, 3); bb.appendBits(6, 3);
bb.appendBits(assignVal, 21); bb.appendBits(assignVal, 21);
} else } else
throw "ECI assignment value out of range"; throw 'ECI assignment value out of range';
return new this(this.Mode.ECI, 0, bb); return new this(this.Mode.ECI, 0, bb);
}; };
@ -853,7 +853,7 @@ var qrcodegen = new function() {
// (Private) The set of all legal characters in alphanumeric mode, // (Private) The set of all legal characters in alphanumeric mode,
// where each character value maps to the index in the string. // where each character value maps to the index in the string.
QrSegment.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:"; QrSegment.ALPHANUMERIC_CHARSET = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:';
/*---- Public helper enumeration ----*/ /*---- Public helper enumeration ----*/
@ -873,7 +873,7 @@ var qrcodegen = new function() {
// Private constructor. // Private constructor.
function Mode(mode, ccbits) { function Mode(mode, ccbits) {
// (Package-private) The mode indicator bits, which is a uint4 value (range 0 to 15). // (Package-private) The mode indicator bits, which is a uint4 value (range 0 to 15).
Object.defineProperty(this, "modeBits", {value:mode}); Object.defineProperty(this, 'modeBits', {value:mode});
// (Package-private) Returns the bit width of the character count field for a segment in // (Package-private) Returns the bit width of the character count field for a segment in
// this mode in a QR Code at the given version number. The result is in the range [0, 16]. // this mode in a QR Code at the given version number. The result is in the range [0, 16].
@ -891,7 +891,7 @@ var qrcodegen = new function() {
str = encodeURI(str); str = encodeURI(str);
var result = []; var result = [];
for (var i = 0; i < str.length; i++) { for (var i = 0; i < str.length; i++) {
if (str.charAt(i) != "%") if (str.charAt(i) !== '%')
result.push(str.charCodeAt(i)); result.push(str.charCodeAt(i));
else { else {
result.push(parseInt(str.substring(i + 1, i + 3), 16)); result.push(parseInt(str.substring(i + 1, i + 3), 16));
@ -912,7 +912,7 @@ var qrcodegen = new function() {
*/ */
function ReedSolomonGenerator(degree) { function ReedSolomonGenerator(degree) {
if (degree < 1 || degree > 255) if (degree < 1 || degree > 255)
throw "Degree out of range"; throw 'Degree out of range';
// Coefficients of the divisor polynomial, stored from highest to lowest power, excluding the leading term which // Coefficients of the divisor polynomial, stored from highest to lowest power, excluding the leading term which
// is always 1. For example the polynomial x^3 + 255x^2 + 8x + 93 is stored as the uint8 array {255, 8, 93}. // is always 1. For example the polynomial x^3 + 255x^2 + 8x + 93 is stored as the uint8 array {255, 8, 93}.
@ -957,16 +957,16 @@ var qrcodegen = new function() {
// This static function returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and // This static function returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and
// result are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8. // result are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8.
ReedSolomonGenerator.multiply = function(x, y) { ReedSolomonGenerator.multiply = function(x, y) {
if (x >>> 8 != 0 || y >>> 8 != 0) if (x >>> 8 !== 0 || y >>> 8 !== 0)
throw "Byte out of range"; throw 'Byte out of range';
// Russian peasant multiplication // Russian peasant multiplication
var z = 0; var z = 0;
for (var i = 7; i >= 0; i--) { for (var i = 7; i >= 0; i--) {
z = (z << 1) ^ ((z >>> 7) * 0x11D); z = (z << 1) ^ ((z >>> 7) * 0x11D);
z ^= ((y >>> i) & 1) * x; z ^= ((y >>> i) & 1) * x;
} }
if (z >>> 8 != 0) if (z >>> 8 !== 0)
throw "Assertion error"; throw 'Assertion error';
return z; return z;
}; };
@ -982,8 +982,8 @@ var qrcodegen = new function() {
// Appends the given number of low-order bits of the given value // Appends the given number of low-order bits of the given value
// to this buffer. Requires 0 <= len <= 31 and 0 <= val < 2^len. // to this buffer. Requires 0 <= len <= 31 and 0 <= val < 2^len.
this.appendBits = function(val, len) { this.appendBits = function(val, len) {
if (len < 0 || len > 31 || val >>> len != 0) if (len < 0 || len > 31 || val >>> len !== 0)
throw "Value out of range"; throw 'Value out of range';
for (var i = len - 1; i >= 0; i--) // Append bit by bit for (var i = len - 1; i >= 0; i--) // Append bit by bit
this.push((val >>> i) & 1); this.push((val >>> i) & 1);
}; };

View File

@ -38,14 +38,14 @@ function register() {
// Dont allow existing users to re-register // Dont allow existing users to re-register
if (user.number) { if (user.number) {
fo.sendBaseline('ALREADY_MEMBER',false); fo.sendBaseline('ALREADY_MEMBER',false);
return read == '*' ? read : ''; return read === '*' ? 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)+')');
if ((cf.fname == 'TOKEN') && (read == '#' || read == '\r')) { if ((cf.fname === 'TOKEN') && (read === '#' || read === "\r")) {
if (cf.fvalue == code) { if (cf.fvalue === code) {
complete = true; complete = true;
} else { } else {
@ -65,7 +65,7 @@ function register() {
this.prefield=function() { this.prefield=function() {
log(LOG_DEBUG,'- prefield: Field '+cf.fname+'('+JSON.stringify(cf)+')'); log(LOG_DEBUG,'- prefield: Field '+cf.fname+'('+JSON.stringify(cf)+')');
if (cf.fname == 'TOKEN') { if (cf.fname === 'TOKEN') {
if (! code.length) { if (! code.length) {
log(LOG_DEBUG,' - BASELINE '+cf.fname+'('+JSON.stringify(cf)+')'); log(LOG_DEBUG,' - BASELINE '+cf.fname+'('+JSON.stringify(cf)+')');
fo.sendBaseline('TOKEN_EMAIL',false); fo.sendBaseline('TOKEN_EMAIL',false);
@ -97,7 +97,7 @@ function register() {
var hdrs = new Object(); var hdrs = new Object();
hdrs.to=name; hdrs.to=name;
hdrs.to_net_type=netaddr_type(email); hdrs.to_net_type=netaddr_type(email);
if (hdrs.to_net_type != NET_NONE) { if (hdrs.to_net_type !== NET_NONE) {
hdrs.to_net_addr = email; hdrs.to_net_addr = email;
} else { } else {
fo.sendBaseline('CANNOT_SEND_TOKEN',false); fo.sendBaseline('CANNOT_SEND_TOKEN',false);
@ -108,7 +108,7 @@ function register() {
hdrs.from_net_type=NET_INTERNET; hdrs.from_net_type=NET_INTERNET;
hdrs.subject='Registration TOKEN for '+system.name; hdrs.subject='Registration TOKEN for '+system.name;
if (msgbase.open != undefined && msgbase.open() == false) { if (msgbase.open !== undefined && msgbase.open() === false) {
console.print("\r\n\1n\1h\1rERROR: \1y" + msgbase.last_error + "\1n \r\n"); console.print("\r\n\1n\1h\1rERROR: \1y" + msgbase.last_error + "\1n \r\n");
console.pause(); console.pause();
msgbase.close(); msgbase.close();

View File

@ -19,6 +19,7 @@ load('frame.js');
log(LOG_DEBUG,'+ Control SQRL-LOGIN loaded'); log(LOG_DEBUG,'+ Control SQRL-LOGIN loaded');
// @todo This should move to handle - since we have to press 2 twice to get out.
function sqrllogin() { function sqrllogin() {
var complete = false; var complete = false;
var cancel = false; var cancel = false;
@ -39,7 +40,7 @@ function sqrllogin() {
.map(function(x) {return x.charCodeAt(0)}); .map(function(x) {return x.charCodeAt(0)});
var qr = qrcodegen.QrCode.encodeBinary(data,qrcodegen.QrCode.Ecc.LOW); var qr = qrcodegen.QrCode.encodeBinary(data,qrcodegen.QrCode.Ecc.LOW);
var subframe = new Frame((viewdata ? VIEWDATA_FRAME_WIDTH : ANSI_FRAME_WIDTH-qr.size-2),2,(viewdata ? qr.size/2 : qr.size+2),22,BG_BLACK|LIGHTGRAY); var subframe = new Frame((viewdata ? fo.settings.FRAME_WIDTH : fo.settings.FRAME_WIDTH-qr.size-2),2,(viewdata ? qr.size/2 : qr.size+2),22,BG_BLACK|LIGHTGRAY);
fo.qrcode(qr,subframe); fo.qrcode(qr,subframe);
fo.sendBaseline('CANCEL_MSG',false); fo.sendBaseline('CANCEL_MSG',false);
@ -51,7 +52,7 @@ function sqrllogin() {
while (read !== '2') { while (read !== '2') {
read = console.inkey(K_NONE,1000); read = console.inkey(K_NONE,1000);
if (read == 2) if (read === 2)
cancel = true; cancel = true;
http = new HTTPRequest(); http = new HTTPRequest();
@ -73,7 +74,7 @@ function sqrllogin() {
if (result.isReady) { if (result.isReady) {
log(LOG_INFO,'NUT: '+result.msg); log(LOG_INFO,'NUT: '+result.msg);
log(LOG_INFO,'NEXT: '+result.nextPage); log(LOG_INFO,'NEXT: '+result.nextPage);
if (result.msg == 'SQRL authenticated') { if (result.msg === 'SQRL authenticated') {
log(LOG_DEBUG,'Getting Authenticated User ['+result.nextPage+']'); log(LOG_DEBUG,'Getting Authenticated User ['+result.nextPage+']');
http = new HTTPRequest(); http = new HTTPRequest();
http.SetupGet(result.nextPage,undefined,''); http.SetupGet(result.nextPage,undefined,'');
@ -83,7 +84,7 @@ function sqrllogin() {
http.ReadResponse(); http.ReadResponse();
log(LOG_DEBUG,'Getting Authenticated User Response ['+http.response_code+']'); log(LOG_DEBUG,'Getting Authenticated User Response ['+http.response_code+']');
if (http.response_code == 200) { if (http.response_code === 200) {
var sqrluser = http.body.substr(0,40); var sqrluser = http.body.substr(0,40);
var username = 'S'+sqrluser.substr(0,24) var username = 'S'+sqrluser.substr(0,24)
log(LOG_DEBUG,'Getting Authenticated sqrluser ['+JSON.stringify(sqrluser)+']'); log(LOG_DEBUG,'Getting Authenticated sqrluser ['+JSON.stringify(sqrluser)+']');
@ -173,7 +174,7 @@ function sqrllogin() {
if (typeof subframe === 'object') if (typeof subframe === 'object')
subframe.close(); subframe.close();
action = ACTION_GOTO; action = ACTION_GOTO;
next_page = { frame: 98,index: 'a' }; next_page = LOGIN_FRAME;
} }
// Called before processing for a field // Called before processing for a field

18
main.js
View File

@ -147,14 +147,14 @@ while(bbs.online) {
read = KEY_ESC; read = KEY_ESC;
// Recognise when the ESC sequence has ended (with a ~ or ;) // Recognise when the ESC sequence has ended (with a ~ or ;)
} else if (esc && extendedkey && (read === '~' || read === ';')) { } else if (esc && extendedkey && (read === '~' || read === ';' || ! read)) {
switch (extendedkey) { switch (extendedkey) {
case '[15': read = false; break; // F5 case '[15': read = false; break; // F5
case '[17': read = false; break; // F6 case '[17': read = false; break; // F6
case '[18': read = false; break; // F7 case '[18': read = false; break; // F7
case '[19': read = false; break; // F8 case '[19': read = false; break; // F8
case '[20': read = false; break; // F9 case '[20': read = false; break; // F9
case '[21': read = false; break; // F10 case '[21': read = ascii(26); break; // F10
case '[23': read = false; break; // F11 case '[23': read = false; break; // F11
case '[24': read = false; break; // F12 case '[24': read = false; break; // F12
default: default:
@ -592,7 +592,7 @@ while(bbs.online) {
if (read.charCodeAt(0) > 31 && cf.fvalue.length < cf.flength) { if (read.charCodeAt(0) > 31 && cf.fvalue.length < cf.flength) {
cf.fvalue += read; cf.fvalue += read;
console.write((cf.ftype == 't') ? read : 'x'); console.write((cf.ftype === 't') ? read : 'x');
} }
} }
@ -726,7 +726,7 @@ while(bbs.online) {
} }
/* /*
if ($read == HASH) { if ($read === HASH) {
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];
@ -838,7 +838,7 @@ while(bbs.online) {
fo.load(pageStr(next_page)); fo.load(pageStr(next_page));
// 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
if (fo.page == null) { if (fo.page === null) {
log(LOG_DEBUG,'- ACTION_EDIT: check index: '+next_page.index+' ('+String.fromCharCode(next_page.index.charCodeAt(0)-1)+')'); log(LOG_DEBUG,'- ACTION_EDIT: check index: '+next_page.index+' ('+String.fromCharCode(next_page.index.charCodeAt(0)-1)+')');
// We can always create an 'a' frame // We can always create an 'a' frame
@ -847,7 +847,7 @@ while(bbs.online) {
fo.load(pageStr({frame: next_page.frame, index: String.fromCharCode(next_page.index.charCodeAt(0)-1)})); fo.load(pageStr({frame: next_page.frame, index: String.fromCharCode(next_page.index.charCodeAt(0)-1)}));
log(LOG_DEBUG,'- ACTION_EDIT: check index: '+JSON.stringify(fo)+' ('+String.fromCharCode(next_page.index.charCodeAt(0)-1)+')'); log(LOG_DEBUG,'- ACTION_EDIT: check index: '+JSON.stringify(fo)+' ('+String.fromCharCode(next_page.index.charCodeAt(0)-1)+')');
if (fo.page == null) { if (fo.page === null) {
fo = current; fo = current;
// sendbaseline ERR_PAGE // sendbaseline ERR_PAGE
fo.sendBaseline('ERR_NO_PARENT',false); fo.sendBaseline('ERR_NO_PARENT',false);
@ -885,7 +885,7 @@ while(bbs.online) {
log(LOG_DEBUG,'- ACTION_BACKUP: Backing up to ['+(next_page ? pageStr(next_page) : '')+'] current ['+fo.page+']'); log(LOG_DEBUG,'- ACTION_BACKUP: Backing up to ['+(next_page ? pageStr(next_page) : '')+'] current ['+fo.page+']');
// If there is no next page, we'll ignore the request. // If there is no next page, we'll ignore the request.
if (! next_page || (pageStr(next_page) == fo.page)) { if (! next_page || (pageStr(next_page) === fo.page)) {
action = false; action = false;
break; break;
} }
@ -908,11 +908,11 @@ while(bbs.online) {
fo = viewdata ? new FrameViewdata() : new FrameAnsi(); fo = viewdata ? new FrameViewdata() : new FrameAnsi();
fo.load(pageStr(next_page)); fo.load(pageStr(next_page));
if (fo.page == null) { if (fo.page === null) {
fo = current; fo = current;
// In case the frame doesnt exist // In case the frame doesnt exist
if (fo == null) if (fo === null)
fo = viewdata ? new FrameViewdata() : new FrameAnsi(); fo = viewdata ? new FrameViewdata() : new FrameAnsi();
// sendbaseline ERR_PAGE // sendbaseline ERR_PAGE

View File

@ -22,7 +22,7 @@ frame = new TexFrame();
frame.load(pageStr({frame: p,index: i})); frame.load(pageStr({frame: p,index: i}));
if (! send || ! frame || file) { if (! send || ! frame || file) {
if (frame.page == null) { if (frame.page === null) {
frame = new TexFrame(); frame = new TexFrame();
frame.frame = p; frame.frame = p;
frame.index = i; frame.index = i;
@ -55,7 +55,7 @@ if (! send || ! frame || file) {
if (key) { if (key) {
frame.key = key.split(',').map(function(t){return parseInt(t)}); frame.key = key.split(',').map(function(t){return parseInt(t)});
if (frame.key.length != 10) { if (frame.key.length !== 10) {
log(LOG_ERROR,'! ERROR: Must specify 10 keys with -k'); log(LOG_ERROR,'! ERROR: Must specify 10 keys with -k');
exit(1); exit(1);
} }