Skip to content

Commit 2efbe3d

Browse files
author
unbug
committed
worker
1 parent 6a9b209 commit 2efbe3d

5 files changed

Lines changed: 48 additions & 2 deletions

File tree

‎cache.manifest‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CACHE MANIFEST
2-
# Build: 20160224113419
2+
# Build: 20160226113415
33

44
CACHE:
55
resources/fonts/Dressedless_Three.svg

‎index.html‎

Lines changed: 7 additions & 1 deletion
Large diffs are not rendered by default.

‎static/app/index.html‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,25 @@
2121
@@include("html/components.html")
2222

2323
@@include("html/scripts.html")
24+
25+
<script id="worker1" type="javascript/worker">
26+
// This script won't be parsed by JS engines
27+
// because its type is javascript/worker.
28+
self.onmessage = function(e) {
29+
self.postMessage('msg from worker');
30+
};
31+
// Rest of your worker code goes here.
32+
console.log(self,this,self==this);
33+
</script>
34+
35+
<script>
36+
var blob = new Blob([document.querySelector('#worker1').textContent]);
37+
38+
var worker = new Worker(window.URL.createObjectURL(blob));
39+
worker.onmessage = function(e) {
40+
console.log("Received: " + e.data);
41+
}
42+
worker.postMessage('test1'); // Start the worker.
43+
</script>
2444
</body>
2545
</html>

‎static/app/src/AppBundle.js‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@
478478
renderAnalytics('vc&q=' + els.lastInputVal);
479479
}
480480
}
481+
481482
function renderHighlightVariableKeyword(){
482483
els.sourceCodeContent.unhighlight();
483484
setTimeout(function(){
@@ -490,6 +491,15 @@
490491
},800);
491492
}
492493

494+
function renderSourceCodeByWorker(){
495+
var blob = new Blob([document.querySelector('#worker1').textContent]);
496+
var worker = new Worker(window.URL.createObjectURL(blob));
497+
worker.onmessage = function(e) {
498+
log("Received: " + e.data);
499+
}
500+
worker.postMessage();
501+
}
502+
493503
function renderRelatedProperty(name) {
494504
var htm = [],
495505
prop = getRelatedProperty(name);

‎static/app/src/view/View.js‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ function renderSourceCode(data) {
422422
renderAnalytics('vc&q=' + els.lastInputVal);
423423
}
424424
}
425+
425426
function renderHighlightVariableKeyword(){
426427
els.sourceCodeContent.unhighlight();
427428
setTimeout(function(){
@@ -434,6 +435,15 @@ function renderHighlightVariableKeyword(){
434435
},800);
435436
}
436437

438+
function renderSourceCodeByWorker(){
439+
var blob = new Blob([document.querySelector('#worker1').textContent]);
440+
var worker = new Worker(window.URL.createObjectURL(blob));
441+
worker.onmessage = function(e) {
442+
log("Received: " + e.data);
443+
}
444+
worker.postMessage();
445+
}
446+
437447
function renderRelatedProperty(name) {
438448
var htm = [],
439449
prop = getRelatedProperty(name);

0 commit comments

Comments
 (0)