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

Commit 8864f39

Browse files
committed
Updated the worker example to singal when done loading.
1 parent 43f29bc commit 8864f39

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

examples/webworker/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ <h1>Uncompress a file using a web worker</h1>
2121

2222
<div>
2323
<p>
24-
<input id="fileInput" type="file" required="required" />
24+
<input id="fileInput" type="file" required="required" disabled="true" />
2525
</p>
2626
<p>
2727
password: <input id="filePassword" type="password" />

examples/webworker/main.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ window.onload = function() {
4949
case 'error':
5050
entryList.innerHTML = '<span style="color: red">' + e.data.error + '</span>';
5151
break;
52+
case 'ready':
53+
document.getElementById('fileInput').disabled = false;
54+
break;
5255
}
5356
};
5457

examples/webworker/worker.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
importScripts("polyfill.js");
77
importScripts("../../js/uncompress.js");
88

9-
// Load all the archive formats
10-
loadArchiveFormats(['rar', 'zip', 'tar'], function() {
11-
console.info("Worker ready ...");
12-
});
139

1410
// FIXME: This function is super inefficient
1511
function isValidImageType(file_name) {
@@ -111,3 +107,9 @@ self.addEventListener('message', function(e) {
111107
break;
112108
}
113109
}, false);
110+
111+
// Load all the archive formats, then signal that we are ready to use
112+
loadArchiveFormats(['rar', 'zip', 'tar'], function() {
113+
self.postMessage({ action: 'ready' });
114+
console.info("Worker ready ...");
115+
});

0 commit comments

Comments
 (0)