-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.html
47 lines (43 loc) · 1.02 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>NijmegenJS Web Worker Challenge</title>
</head>
<body>
<button id="start">Generate random string</button>
<div id="output"></div>
<script src="fall-ready-worker.js"></script>
<script>
//Worker = undefined;
var worker = new FallReadyWorker({
worker: {
func: function(iterations){
var str = '';
for(var i = 0; i < iterations; i++){
//11 chars per iteration
str += Math.random().toString(36).substring(7);
}
return str;
},
getPostData: function(e){
return this.func(e.data);
}
},
onMessage: function(e){
startBtn.removeAttribute('disabled', '');
setTimeout(function(){
outputEl.innerText = 'Done.';
},10);
}
});
var outputEl = document.getElementById('output'),
startBtn = document.getElementById('start');
startBtn.addEventListener('click', function(){
worker.say(6000000);
startBtn.setAttribute('disabled', '');
outputEl.innerText = 'Loading...';
}, false);
</script>
</body>
</html>