Fix ESLint warnings (and one actual bug)

This commit is contained in:
Joshua Bell 2023-01-04 19:34:48 -08:00
parent 7a8c663315
commit cc5806e482
3 changed files with 16 additions and 21 deletions

View File

@ -1233,7 +1233,7 @@ this.basic = (function() {
(function(source) { (function(source) {
function munge(kw) { function munge(kw) {
// Escape special characters // Escape special characters
function escape(c) { return (/[\[\]\\\^\$\.\|\?\*\+\(\)]/).test(c) ? '\\' + c : c; } function escape(c) { return (/[[\]\\^$.|?*+()]/).test(c) ? '\\' + c : c; }
// Allow linear whitespace between characters // Allow linear whitespace between characters
//return kw.split('').map(escape).join('[ \\t]*'); //return kw.split('').map(escape).join('[ \\t]*');
@ -1268,9 +1268,9 @@ this.basic = (function() {
var regexReservedWords = new RegExp("^(" + RESERVED_WORDS.map(munge).join("|") + ")", "i"), var regexReservedWords = new RegExp("^(" + RESERVED_WORDS.map(munge).join("|") + ")", "i"),
regexIdentifier = /^([A-Za-z][A-Za-z0-9]?)[A-Za-z0-9]*(\$|%)?/, regexIdentifier = /^([A-Za-z][A-Za-z0-9]?)[A-Za-z0-9]*(\$|%)?/,
regexStringLiteral = /^"([^"]*?)(?:"|(?=\n|\r|$))/, regexStringLiteral = /^"([^"]*?)(?:"|(?=\n|\r|$))/,
regexNumberLiteral = /^[0-9]*\.?[0-9]+(?:[eE]\s*[\-+]?\s*[0-9]+)?/, regexNumberLiteral = /^[0-9]*\.?[0-9]+(?:[eE]\s*[-+]?\s*[0-9]+)?/,
regexHexLiteral = /^\$[0-9A-Fa-f]+/, regexHexLiteral = /^\$[0-9A-Fa-f]+/,
regexOperator = /^[;=<>+\-*\/\^(),]/, regexOperator = /^[;=<>+\-*/^(),]/,
regexLineNumber = /^[0-9]+/, regexLineNumber = /^[0-9]+/,
regexSeparator = /^:/, regexSeparator = /^:/,

23
dos.js
View File

@ -151,18 +151,13 @@ function DOS(tty) {
if (file === null) { if (file === null) {
// Not cached - do a synchronous XmlHttpRequest for the file here // Not cached - do a synchronous XmlHttpRequest for the file here
req = new XMLHttpRequest(); req = new XMLHttpRequest();
try { url = "vfs/" + encodeURIComponent(filename.replace(/\./g, '_')) + ".txt";
url = "vfs/" + encodeURIComponent(filename.replace(/\./g, '_')) + ".txt"; async = false;
async = false; req.open("GET", url, async);
req.open("GET", url, async); req.send(null);
req.send(null); if (req.status === 200 || req.status === 0) { // 0 for file:// protocol
if (req.status === 200 || req.status === 0) { // 0 for file:// protocol file = req.responseText.replace(/\r\n/g, "\r");
file = req.responseText.replace(/\r\n/g, "\r"); vfs_set(filename, file);
vfs_set(filename, file);
}
} catch (e) {
// File doesn't exist - APPEND/READ will fail
throw e;
} }
} }
@ -179,7 +174,7 @@ function DOS(tty) {
// Normal open logic // Normal open logic
open(filename, recordlength); open(filename, recordlength);
if (!buffers.hasOwnProperty(filename)) { if (!Object.prototype.hasOwnProperty.call(buffers, filename)) {
doserror(DOSErrors.FILE_NOT_FOUND); doserror(DOSErrors.FILE_NOT_FOUND);
} }
@ -196,7 +191,7 @@ function DOS(tty) {
// If not specified, close all buffers // If not specified, close all buffers
if (!filename) { if (!filename) {
for (fn in buffers) { for (fn in buffers) {
if (buffers.hasOwnProperty(fn)) { if (Object.prototype.hasOwnProperty.call(buffers, fn)) {
close(fn); close(fn);
} }
} }

View File

@ -87,7 +87,10 @@ function HiRes(element, width, height) {
err = dx - dy, err = dx - dy,
e2; e2;
while (true) { last_x = x;
last_y = y;
for (;;) {
this.plot(x0, y0); this.plot(x0, y0);
if (x0 === x1 && y0 === y1) { return; } if (x0 === x1 && y0 === y1) { return; }
@ -101,9 +104,6 @@ function HiRes(element, width, height) {
y0 += sy; y0 += sy;
} }
} }
last_x = x;
last_y = y;
}; };
this.getPixel = function(x, y) { this.getPixel = function(x, y) {