From 4d8cd4f64d2420c650a8355e7905869971bc5cd0 Mon Sep 17 00:00:00 2001 From: Vanessa Freudenberg Date: Wed, 20 Dec 2023 17:42:34 -0800 Subject: [PATCH] Allow image override --- index.html | 7 +++++-- squeak.js | 17 +++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index 25c7b37..ae146cd 100644 --- a/index.html +++ b/index.html @@ -36,12 +36,15 @@ } } // start SqueakJS - SqueakJS.runSqueak("BridgeDemo.image", sqCanvas, { + const params = new URLSearchParams(window.location.search); + const image = params.get("image") || "BridgeDemo.image"; + const changes = image.replace(".image", ".changes"); + SqueakJS.runSqueak(image, sqCanvas, { appName: "Croquet Jasmine", fullscreen: true, swapButtons: true, spinner: sqSpinner, - files: ["BridgeDemo.changes", "JasmineV1.sources"], + files: [changes, "JasmineV1.sources"], root: "/jasmine", templates: { "/jasmine/Content": "Content", diff --git a/squeak.js b/squeak.js index 70baa48..8e9e366 100644 --- a/squeak.js +++ b/squeak.js @@ -117,7 +117,7 @@ "version", { // system attributes vmVersion: "SqueakJS 1.1.2", - vmDate: "2023-12-19", // Maybe replace at build time? + vmDate: "2023-12-20", // Maybe replace at build time? vmBuild: "unknown", // or replace at runtime by last-modified? vmPath: "unknown", // Replace at runtime vmFile: "vm.js", @@ -38903,7 +38903,7 @@ } else if (line.match(/Host:/i)) { var hostAndPort = line.substr(6).trim(); var host = hostAndPort.split(':')[0]; - var port = parseInt(hostAndPort.split(':')[1]) || 80; + var port = parseInt(hostAndPort.split(':')[1]) || this.port; if (this.host !== host) { console.warn('Host for ' + this.hostAddress + ' was ' + this.host + ' but from HTTP request now ' + host); this.host = host; @@ -55756,19 +55756,20 @@ image, imageName = null; display.droppedFiles = []; files.forEach(function(f) { - display.droppedFiles.push(f.name); + var path = options.root + f.name; + display.droppedFiles.push(path); var reader = new FileReader(); reader.onload = function () { var buffer = this.result; - Squeak.filePut(f.name, buffer); - loaded.push(f.name); - if (!image && /.*image$/.test(f.name) && (!display.vm || confirm("Run " + f.name + " now?\n(cancel to use as file)"))) { + Squeak.filePut(path, buffer); + loaded.push(path); + if (!image && /.*image$/.test(path) && (!display.vm || confirm("Run " + f.name + " now?\n(cancel to use as file)"))) { image = buffer; - imageName = f.name; + imageName = path; } if (loaded.length == files.length) { if (image) { - SqueakJS.appName = imageName.slice(0, -6); + SqueakJS.appName = imageName.replace(/.*\//,'').replace(/\.image$/,''); SqueakJS.runImage(image, imageName, display, options); } else { recordDragDropEvent(Squeak.EventDragDrop, evt, canvas, display);