Skip to content

Commit 46eaa93

Browse files
committedFeb 27, 2025
launcher: preserve hash
1 parent 71fcb8c commit 46eaa93

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed
 

‎run/index.html

+11-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@
9898
function afterImport(imageName) {
9999
setTimeout(() => drop.style.borderColor = "", 500);
100100
if (!imageName) showFiles();
101-
else runSqueak(imageName);
101+
else {
102+
const hash = '#' + paramsForImage(imageName);
103+
if (location.hash !== hash) history.pushState({}, "", hash);
104+
runSqueak(imageName);
105+
}
102106
}
103107
function exportFile(a) {
104108
var path = Squeak.splitFilePath(a.innerText);
@@ -108,6 +112,11 @@
108112
}, alert);
109113
return false;
110114
}
115+
function paramsForImage(imageName) {
116+
var params = new URLSearchParams(location.hash.slice(1));
117+
params.set("image", imageName);
118+
return params.toString();
119+
}
111120
function showFiles() {
112121
var imgList = [],
113122
fileList = [],
@@ -122,7 +131,7 @@
122131
var entry = entries[f],
123132
path = dir + '/' + f;
124133
if (!entry[3] && f.match(/\.image$/))
125-
imgList.push('<li><a href="#image=' + path + '">' + path + '</a> (' + (entry[4]/1000000).toFixed(1) + ' MB)</li>');
134+
imgList.push('<li><a href="#' + paramsForImage(path) + '">' + path + '</a> (' + (entry[4]/1000000).toFixed(1) + ' MB)</li>');
126135
if (entry[3]) {
127136
dirs.push(path);
128137
nDirs++;

0 commit comments

Comments
 (0)