1
1
Fork 0
mirror of https://github.com/boxgaming/qbjs.git synced 2024-09-19 20:14:58 +00:00

Merge pull request #71 from boxgaming/v0.7

V0.7
This commit is contained in:
boxgaming 2023-06-14 10:44:57 -05:00 committed by GitHub
commit fb0af807b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 60 additions and 36 deletions

View file

@ -121,7 +121,7 @@
<div>
<img id="logo" src="logo.png" onclick="window.open('https://github.com/boxgaming/qbjs/wiki', '_blank')">
<p>QBJS - QBasic for the Web!</p>
<p>Version: 0.7.0</p>
<p>Version: 0.7.3</p>
<p></p>
<p>
QBJS brings the fun and accessibility of QBasic to the browser.<br/>
@ -141,7 +141,7 @@
</body>
<script language="javascript" src="vfs.js"></script>
<script language="javascript" src="gx/gx.js"></script>
<script language="javascript" src="qb.js"></script>
<script language="javascript" src="qb.js?v=0.7.3"></script>
<script language="javascript" src="qb2js.js"></script>
<script language="javascript" src="qbjs-ide.js"></script>
<script language="javascript" src="qbjs-ide.js?v=0.7.3.1"></script>
</html>

9
qb.js
View file

@ -169,9 +169,9 @@ var QB = new function() {
_nextFontId = 1000;
_font = 16;
_fonts = {};
_fonts[8] = { name: "dosvga", size: "16px", style: "", offset: 3 };
_fonts[14] = { name: "dosvga", size: "16px", style: "", offset: 3 };
_fonts[16] = { name: "dosvga", size: "16px", style: "", offset: 3 };
_fonts[8] = { name: "dosvga", size: "16px", style: "", offset: 3, monospace: true };
_fonts[14] = { name: "dosvga", size: "16px", style: "", offset: 3, monospace: true };
_fonts[16] = { name: "dosvga", size: "16px", style: "", offset: 3, monospace: true };
GX.vfsCwd(GX.vfs().rootDirectory());
_fileHandles = {};
_initColorTable();
@ -558,7 +558,7 @@ var QB = new function() {
_fonts[id].monospace = false;
}
else {
_fonts[id].width = tm.width;
_fonts[id].width = tm.width + 1;
_fonts[id].monospace = true;
}
return id;
@ -1909,6 +1909,7 @@ var QB = new function() {
}
if (col && col > 0 && col <= _textColumns()) {
_locX = col-1;
_lastTextX = _locX * QB.func__FontWidth();
}
};

View file

@ -62,27 +62,38 @@ async function init() {
}
var srcUrl = null;
if (url && url.indexOf("?")) {
var queryString = url.substring(url.indexOf("?")+1);
if (url && (url.indexOf("?") || url.indexOf("#"))) {
var pindex = url.indexOf("?");
if (pindex == -1) {
pindex = url.indexOf("#");
}
var queryString = url.substring(pindex + 1);
var nvpairs = queryString.split("&");
for (var i = 0; i < nvpairs.length; i++) {
var nv = nvpairs[i].split("=");
if (nv[0] == "qbcode") {
var zin = new Shorty();
qbcode = zin.inflate(atob(nv[1]));
break;
}
else if (nv[0] == "code") {
qbcode = LZUTF8.decompress(nv[1], { inputEncoding: "Base64" });
}
else if (nv[0] == "mode") {
appMode = nv[1];
}
else if (nv[0] == "src") {
srcUrl = nv[1];
}
else if (nv[0] == "main") {
mainProg = nv[1];
var pname = "";
var pvalue = "";
var nvidx = nvpairs[i].indexOf("=");
if (nvidx > -1) {
pname = nvpairs[i].substring(0, nvidx);
pvalue = nvpairs[i].substring(nvidx + 1);
if (pname == "qbcode") {
var zin = new Shorty();
qbcode = zin.inflate(atob(pvalue));
break;
}
else if (pname == "code") {
qbcode = LZUTF8.decompress(pvalue, { inputEncoding: "Base64" });
}
else if (pname == "mode") {
appMode = pvalue;
}
else if (pname == "src") {
srcUrl = decodeURIComponent(pvalue);
}
else if (pname == "main") {
mainProg = pvalue;
}
}
}
}
@ -142,13 +153,13 @@ async function init() {
}
if (srcUrl) {
var res = await fetch(nv[1]);
var res = await fetch(srcUrl);
var contentType = res.headers.get("Content-Type");
if (contentType == "application/zip") {
if (contentType == "application/zip" ||
contentType == "application/zip-compressed" ||
contentType == "application/x-zip-compressed") {
// load a project
await loadProject(await res.arrayBuffer(), mainProg);
// TODO: shouldn't have to do this
//qbcode = editor.getValue();
}
else {
// otherwise, assume a single source file
@ -654,8 +665,8 @@ window.onresize = function() {
if (appMode == "play" || appMode == "auto") {
f.style.left = "0px";
f.style.top = "0px";
f.style.width = window.innerWidth;
f.style.height = window.innerHeight;
f.style.width = window.innerWidth + "px";
f.style.height = window.innerHeight + "px";
f.style.border = "0px";
_e.codeContainer.style.display = "none";
_e.slider.style.display = "none";
@ -666,6 +677,8 @@ window.onresize = function() {
_e.rightPanel.style.backgroundColor = "#000";
_e.toolbar.style.display = "none";
jsDiv.style.display = "none";
_e.vslider.style.display = "none";
splitHeight = 0;
}
else {
var cmwidth = splitWidth;
@ -927,7 +940,17 @@ dropArea.addEventListener("dragover", fileDragOver, false);
dropArea.addEventListener("dragenter", fileDragEnter, false);
dropArea.addEventListener("dragleave", fileDragLeave, false);
addEventListener("beforeunload", function(e) {
e.preventDefault();
return e.returnValue = "stop";
});
if (!inIframe() && appMode == "ide") {
addEventListener("beforeunload", function(e) {
e.preventDefault();
return e.returnValue = "stop";
});
}
function inIframe () {
try {
return window.self !== window.top;
} catch (e) {
return true;
}
}