mirror of
https://github.com/boxgaming/qbjs.git
synced 2024-09-20 04:24:45 +00:00
commit
fb0af807b2
3 changed files with 60 additions and 36 deletions
|
@ -121,7 +121,7 @@
|
||||||
<div>
|
<div>
|
||||||
<img id="logo" src="logo.png" onclick="window.open('https://github.com/boxgaming/qbjs/wiki', '_blank')">
|
<img id="logo" src="logo.png" onclick="window.open('https://github.com/boxgaming/qbjs/wiki', '_blank')">
|
||||||
<p>QBJS - QBasic for the Web!</p>
|
<p>QBJS - QBasic for the Web!</p>
|
||||||
<p>Version: 0.7.0</p>
|
<p>Version: 0.7.3</p>
|
||||||
<p></p>
|
<p></p>
|
||||||
<p>
|
<p>
|
||||||
QBJS brings the fun and accessibility of QBasic to the browser.<br/>
|
QBJS brings the fun and accessibility of QBasic to the browser.<br/>
|
||||||
|
@ -141,7 +141,7 @@
|
||||||
</body>
|
</body>
|
||||||
<script language="javascript" src="vfs.js"></script>
|
<script language="javascript" src="vfs.js"></script>
|
||||||
<script language="javascript" src="gx/gx.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="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>
|
</html>
|
9
qb.js
9
qb.js
|
@ -169,9 +169,9 @@ var QB = new function() {
|
||||||
_nextFontId = 1000;
|
_nextFontId = 1000;
|
||||||
_font = 16;
|
_font = 16;
|
||||||
_fonts = {};
|
_fonts = {};
|
||||||
_fonts[8] = { 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 };
|
_fonts[14] = { name: "dosvga", size: "16px", style: "", offset: 3, monospace: true };
|
||||||
_fonts[16] = { name: "dosvga", size: "16px", style: "", offset: 3 };
|
_fonts[16] = { name: "dosvga", size: "16px", style: "", offset: 3, monospace: true };
|
||||||
GX.vfsCwd(GX.vfs().rootDirectory());
|
GX.vfsCwd(GX.vfs().rootDirectory());
|
||||||
_fileHandles = {};
|
_fileHandles = {};
|
||||||
_initColorTable();
|
_initColorTable();
|
||||||
|
@ -558,7 +558,7 @@ var QB = new function() {
|
||||||
_fonts[id].monospace = false;
|
_fonts[id].monospace = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_fonts[id].width = tm.width;
|
_fonts[id].width = tm.width + 1;
|
||||||
_fonts[id].monospace = true;
|
_fonts[id].monospace = true;
|
||||||
}
|
}
|
||||||
return id;
|
return id;
|
||||||
|
@ -1909,6 +1909,7 @@ var QB = new function() {
|
||||||
}
|
}
|
||||||
if (col && col > 0 && col <= _textColumns()) {
|
if (col && col > 0 && col <= _textColumns()) {
|
||||||
_locX = col-1;
|
_locX = col-1;
|
||||||
|
_lastTextX = _locX * QB.func__FontWidth();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
81
qbjs-ide.js
81
qbjs-ide.js
|
@ -62,27 +62,38 @@ async function init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var srcUrl = null;
|
var srcUrl = null;
|
||||||
if (url && url.indexOf("?")) {
|
if (url && (url.indexOf("?") || url.indexOf("#"))) {
|
||||||
var queryString = url.substring(url.indexOf("?")+1);
|
var pindex = url.indexOf("?");
|
||||||
|
if (pindex == -1) {
|
||||||
|
pindex = url.indexOf("#");
|
||||||
|
}
|
||||||
|
var queryString = url.substring(pindex + 1);
|
||||||
var nvpairs = queryString.split("&");
|
var nvpairs = queryString.split("&");
|
||||||
for (var i = 0; i < nvpairs.length; i++) {
|
for (var i = 0; i < nvpairs.length; i++) {
|
||||||
var nv = nvpairs[i].split("=");
|
var pname = "";
|
||||||
if (nv[0] == "qbcode") {
|
var pvalue = "";
|
||||||
var zin = new Shorty();
|
var nvidx = nvpairs[i].indexOf("=");
|
||||||
qbcode = zin.inflate(atob(nv[1]));
|
if (nvidx > -1) {
|
||||||
break;
|
pname = nvpairs[i].substring(0, nvidx);
|
||||||
}
|
pvalue = nvpairs[i].substring(nvidx + 1);
|
||||||
else if (nv[0] == "code") {
|
|
||||||
qbcode = LZUTF8.decompress(nv[1], { inputEncoding: "Base64" });
|
if (pname == "qbcode") {
|
||||||
}
|
var zin = new Shorty();
|
||||||
else if (nv[0] == "mode") {
|
qbcode = zin.inflate(atob(pvalue));
|
||||||
appMode = nv[1];
|
break;
|
||||||
}
|
}
|
||||||
else if (nv[0] == "src") {
|
else if (pname == "code") {
|
||||||
srcUrl = nv[1];
|
qbcode = LZUTF8.decompress(pvalue, { inputEncoding: "Base64" });
|
||||||
}
|
}
|
||||||
else if (nv[0] == "main") {
|
else if (pname == "mode") {
|
||||||
mainProg = nv[1];
|
appMode = pvalue;
|
||||||
|
}
|
||||||
|
else if (pname == "src") {
|
||||||
|
srcUrl = decodeURIComponent(pvalue);
|
||||||
|
}
|
||||||
|
else if (pname == "main") {
|
||||||
|
mainProg = pvalue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,13 +153,13 @@ async function init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (srcUrl) {
|
if (srcUrl) {
|
||||||
var res = await fetch(nv[1]);
|
var res = await fetch(srcUrl);
|
||||||
var contentType = res.headers.get("Content-Type");
|
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
|
// load a project
|
||||||
await loadProject(await res.arrayBuffer(), mainProg);
|
await loadProject(await res.arrayBuffer(), mainProg);
|
||||||
// TODO: shouldn't have to do this
|
|
||||||
//qbcode = editor.getValue();
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// otherwise, assume a single source file
|
// otherwise, assume a single source file
|
||||||
|
@ -654,8 +665,8 @@ window.onresize = function() {
|
||||||
if (appMode == "play" || appMode == "auto") {
|
if (appMode == "play" || appMode == "auto") {
|
||||||
f.style.left = "0px";
|
f.style.left = "0px";
|
||||||
f.style.top = "0px";
|
f.style.top = "0px";
|
||||||
f.style.width = window.innerWidth;
|
f.style.width = window.innerWidth + "px";
|
||||||
f.style.height = window.innerHeight;
|
f.style.height = window.innerHeight + "px";
|
||||||
f.style.border = "0px";
|
f.style.border = "0px";
|
||||||
_e.codeContainer.style.display = "none";
|
_e.codeContainer.style.display = "none";
|
||||||
_e.slider.style.display = "none";
|
_e.slider.style.display = "none";
|
||||||
|
@ -666,6 +677,8 @@ window.onresize = function() {
|
||||||
_e.rightPanel.style.backgroundColor = "#000";
|
_e.rightPanel.style.backgroundColor = "#000";
|
||||||
_e.toolbar.style.display = "none";
|
_e.toolbar.style.display = "none";
|
||||||
jsDiv.style.display = "none";
|
jsDiv.style.display = "none";
|
||||||
|
_e.vslider.style.display = "none";
|
||||||
|
splitHeight = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var cmwidth = splitWidth;
|
var cmwidth = splitWidth;
|
||||||
|
@ -927,7 +940,17 @@ dropArea.addEventListener("dragover", fileDragOver, false);
|
||||||
dropArea.addEventListener("dragenter", fileDragEnter, false);
|
dropArea.addEventListener("dragenter", fileDragEnter, false);
|
||||||
dropArea.addEventListener("dragleave", fileDragLeave, false);
|
dropArea.addEventListener("dragleave", fileDragLeave, false);
|
||||||
|
|
||||||
addEventListener("beforeunload", function(e) {
|
if (!inIframe() && appMode == "ide") {
|
||||||
e.preventDefault();
|
addEventListener("beforeunload", function(e) {
|
||||||
return e.returnValue = "stop";
|
e.preventDefault();
|
||||||
});
|
return e.returnValue = "stop";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function inIframe () {
|
||||||
|
try {
|
||||||
|
return window.self !== window.top;
|
||||||
|
} catch (e) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue