diff --git a/index.html b/index.html index 6b7c4a5..c0a2819 100644 --- a/index.html +++ b/index.html @@ -121,7 +121,7 @@

QBJS - QBasic for the Web!

-

Version: 0.7.0

+

Version: 0.7.3

QBJS brings the fun and accessibility of QBasic to the browser.
@@ -141,7 +141,7 @@ - + - + \ No newline at end of file diff --git a/qb.js b/qb.js index 4e0ac8c..0cfb760 100644 --- a/qb.js +++ b/qb.js @@ -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(); } }; diff --git a/qbjs-ide.js b/qbjs-ide.js index 78b52ad..03e4317 100644 --- a/qbjs-ide.js +++ b/qbjs-ide.js @@ -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"; -}); \ No newline at end of file +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; + } +} \ No newline at end of file