From fe735dea43dff527734be52f8b28aaba33bd407c Mon Sep 17 00:00:00 2001 From: boxgaming <75969133+boxgaming@users.noreply.github.com> Date: Sat, 3 Jun 2023 15:34:10 -0500 Subject: [PATCH 1/5] disable beforeunload event when in iframe --- qbjs-ide.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/qbjs-ide.js b/qbjs-ide.js index 466abca..3f6e00f 100644 --- a/qbjs-ide.js +++ b/qbjs-ide.js @@ -924,7 +924,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()) { + 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 From 3bc5502258e1eff26fad054d636846312a0b1ac8 Mon Sep 17 00:00:00 2001 From: boxgaming <75969133+boxgaming@users.noreply.github.com> Date: Wed, 14 Jun 2023 10:17:25 -0500 Subject: [PATCH 2/5] Fixed Locate bug introduced by new custom font functionality --- qb.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/qb.js b/qb.js index 7529ddf..be8722f 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; @@ -1903,6 +1903,7 @@ var QB = new function() { } if (col && col > 0 && col <= _textColumns()) { _locX = col-1; + _lastTextX = _locX * QB.func__FontWidth(); } }; From d5e4fd67405508f23e78ac933f1d8ac5d4891651 Mon Sep 17 00:00:00 2001 From: boxgaming <75969133+boxgaming@users.noreply.github.com> Date: Wed, 14 Jun 2023 10:18:02 -0500 Subject: [PATCH 3/5] Versioning updates --- index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 15adcd2..8118f55 100644 --- a/index.html +++ b/index.html @@ -120,7 +120,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.
@@ -140,7 +140,7 @@ - + - + \ No newline at end of file From af8b0bd4d93522dcff762110769d45cd9072d87b Mon Sep 17 00:00:00 2001 From: boxgaming <75969133+boxgaming@users.noreply.github.com> Date: Wed, 14 Jun 2023 10:23:56 -0500 Subject: [PATCH 4/5] Fix for src url parameter to correctly handle source urls with parameters Added ability to prefix parameters with "#" instead of "?" to allow for longer code URLs Added detection logic for additional zip file content types: application/zip-compressed, application/x-zip-compressed Fixed screen sizing issue in "auto" and "play" modes --- qbjs-ide.js | 63 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 25 deletions(-) diff --git a/qbjs-ide.js b/qbjs-ide.js index 3f6e00f..21cb397 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; + } } } } @@ -139,13 +150,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 @@ -651,8 +662,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"; @@ -663,6 +674,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; From 18c0c92a814de84e41318411dda50de9e8b29947 Mon Sep 17 00:00:00 2001 From: boxgaming <75969133+boxgaming@users.noreply.github.com> Date: Wed, 14 Jun 2023 10:34:14 -0500 Subject: [PATCH 5/5] Disabled beforeunload event when not in IDE mode (e.g. auto, play) --- index.html | 2 +- qbjs-ide.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 8118f55..e65a082 100644 --- a/index.html +++ b/index.html @@ -142,5 +142,5 @@ - + \ No newline at end of file diff --git a/qbjs-ide.js b/qbjs-ide.js index 21cb397..2874994 100644 --- a/qbjs-ide.js +++ b/qbjs-ide.js @@ -937,7 +937,7 @@ dropArea.addEventListener("dragover", fileDragOver, false); dropArea.addEventListener("dragenter", fileDragEnter, false); dropArea.addEventListener("dragleave", fileDragLeave, false); -if (!inIframe()) { +if (!inIframe() && appMode == "ide") { addEventListener("beforeunload", function(e) { e.preventDefault(); return e.returnValue = "stop";