Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit d8e7430

Browse files
committed
Updated the examples to put the image in the window hash.
1 parent 9b40336 commit d8e7430

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

examples/simple/main.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,11 @@ function createLinkForEachEntry(archive) {
8484
// Add a link to the Object URL
8585
var a = document.createElement('a');
8686
a.innerHTML = entry.name + ' (' + toFriendlySize(entry.size) + ')';
87-
a.href = entry.name;
87+
a.href = '#' + entry.name;
8888

8989
// Uncompress the entry when the link is clicked on
9090
a.addEventListener('click', function(e) {
9191
console.info('clicked .................');
92-
e.preventDefault();
9392
onClick(entry);
9493
});
9594

@@ -111,6 +110,10 @@ window.onload = function() {
111110
return;
112111
}
113112

113+
// Remove any loaded image
114+
window.location.hash = '';
115+
document.getElementById('currentImage').src = '';
116+
114117
// Get the file's info
115118
var file = file_input.files[0];
116119

examples/webworker/main.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,11 @@ window.onload = function() {
3737

3838
// Add a link to the Object URL
3939
var a = document.createElement('a');
40-
a.href = url;
40+
a.href = '#' + file_name;
4141
a.innerHTML = file_name + ' (' + toFriendlySize(size) + ')';
4242
a.addEventListener('click', function(e) {
43-
e.preventDefault();
4443
var img = document.getElementById('currentImage');
45-
img.src = this.href;
44+
img.src = url;
4645
});
4746

4847
entryList.appendChild(a);
@@ -63,6 +62,10 @@ window.onload = function() {
6362
}
6463
entryList.innerHTML = '';
6564

65+
// Remove any loaded image
66+
window.location.hash = '';
67+
document.getElementById('currentImage').src = '';
68+
6669
// Get the file's info
6770
var file = file_input.files[0];
6871
var blob = file.slice();

0 commit comments

Comments
 (0)