diff --git a/modules/c1pjs/lib/video.js b/modules/c1pjs/lib/video.js
index 5569ec162..df3a057b6 100644
--- a/modules/c1pjs/lib/video.js
+++ b/modules/c1pjs/lib/video.js
@@ -541,8 +541,8 @@ C1PVideo.init = function()
* "autocapitalize" work here.
*/
var eCanvas = window.document.createElement("canvas");
- if (eCanvas === undefined) {
- eVideo.innerHTML = "
Missing <canvas> support; try a new web browser.";
+ if (eCanvas === undefined || !eCanvas.getContext) {
+ eVideo.innerHTML = "
Missing <canvas> support. Please try a newer web browser.";
return;
}
eCanvas.setAttribute("class", C1PJSCLASS + "-canvas");
diff --git a/modules/htmlout/lib/htmlout.js b/modules/htmlout/lib/htmlout.js
index ac37059fe..986ecd591 100644
--- a/modules/htmlout/lib/htmlout.js
+++ b/modules/htmlout/lib/htmlout.js
@@ -163,6 +163,10 @@ var aMachineFileTypes = {
'body': [".js"]
};
+/*
+ * Since we have a small server-side optimization that assumes any directory entry without an extension is
+ * a directory, this is a list of known exceptions (ie, entries that are NOT directories despite no extension).
+ */
var asNonDirectories = [
"COPYING",
"LICENSE",
@@ -170,6 +174,9 @@ var asNonDirectories = [
"makefile"
];
+/*
+ * A list of plain-text file types that we want the server to serve up with mime-type "text/plain".
+ */
var asExtsPlainText = [
"65v",
"bas",
@@ -201,6 +208,7 @@ var asFilesNonListed = [
"package.json",
"server.js",
"index.html",
+ "notes.md",
"README.md",
"robots.txt",
"machine.xml",
diff --git a/modules/pcjs/lib/debugger.js b/modules/pcjs/lib/debugger.js
index 83c54531c..5a914b3ab 100644
--- a/modules/pcjs/lib/debugger.js
+++ b/modules/pcjs/lib/debugger.js
@@ -1648,7 +1648,7 @@ if (DEBUGGER) {
var aEnable = this.parseCommand(sEnable.replace("keys","key").replace("kbd","keyboard"));
if (aEnable.length) {
for (var m in Debugger.MESSAGES) {
- if (aEnable.indexOf(m) >= 0) {
+ if (usr.indexOf(aEnable, m) >= 0) {
this.bitsMessage |= Debugger.MESSAGES[m];
this.println(m + " messages enabled");
}
@@ -1683,7 +1683,7 @@ if (DEBUGGER) {
* @return {number}
*/
Debugger.prototype.getRegIndex = function(sReg) {
- return Debugger.REGS.indexOf(sReg.toUpperCase());
+ return usr.indexOf(Debugger.REGS, sReg.toUpperCase());
};
/**
diff --git a/modules/pcjs/lib/video.js b/modules/pcjs/lib/video.js
index 28a91ab27..474e276c3 100644
--- a/modules/pcjs/lib/video.js
+++ b/modules/pcjs/lib/video.js
@@ -2720,8 +2720,12 @@ Video.prototype.onLoadSetFonts = function(sFontFile, sFontData, nErrorCode)
}
/*
* If we're still here, then we're ready!
+ *
+ * UPDATE: Per issue #21, I'm issuing setReady() *only* if a valid contextScreen exists *or* a Debugger is attached.
+ *
+ * TODO: Consider a more general-purpose solution for deciding whether or not the user wants to run in a "headless" mode.
*/
- this.setReady();
+ if (this.contextScreen || this.dbg) this.setReady();
};
/**
@@ -5197,8 +5201,8 @@ Video.init = function()
var parmsVideo = Component.getComponentParms(eVideo);
var eCanvas = window.document.createElement("canvas");
- if (eCanvas === undefined) {
- eVideo.innerHTML = "
Missing <canvas> support; try a new web browser.";
+ if (eCanvas === undefined || !eCanvas.getContext) {
+ eVideo.innerHTML = "
Missing <canvas> support. Please try a newer web browser.";
return;
}
diff --git a/modules/shared/lib/component.js b/modules/shared/lib/component.js
index 50551d380..87528e7aa 100644
--- a/modules/shared/lib/component.js
+++ b/modules/shared/lib/component.js
@@ -249,7 +249,7 @@ Component.log = function(s, type)
Component.msStart = usr.getTime();
}
msElapsed = usr.getTime() - Component.msStart;
- console.log(msElapsed + "ms: " + sMsg.replace(/\n/g, " "));
+ if (window && window.console) console.log(msElapsed + "ms: " + sMsg.replace(/\n/g, " "));
}
}
};
@@ -658,7 +658,7 @@ Component.prototype = {
}
control.value += s + "\n";
control.scrollTop = control.scrollHeight;
- if (DEBUG) console.log(s);
+ if (DEBUG && window && window.console) console.log(s);
};
}(control));
/**
diff --git a/modules/shared/lib/usrlib.js b/modules/shared/lib/usrlib.js
index 455d07f7e..c98ebe1c8 100644
--- a/modules/shared/lib/usrlib.js
+++ b/modules/shared/lib/usrlib.js
@@ -34,6 +34,28 @@
var usr = {};
+/**
+ * indexOf(a, t, i)
+ *
+ * @param {Array} a
+ * @param {*} t
+ * @param {number} [i]
+ * @returns {number}
+ */
+usr.indexOf = function(a, t, i)
+{
+ if (Array.prototype.indexOf) {
+ return a.indexOf(t, i);
+ }
+ i = i || 0;
+ if (i < 0) i += a.length;
+ if (i < 0) i = 0;
+ for (var n = a.length; i < n; i++) {
+ if (i in a && a[i] === t) return i;
+ }
+ return -1;
+};
+
/**
* binarySearch(a, v, fnCompare)
*