-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworker.html
55 lines (49 loc) · 2.17 KB
/
worker.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
48
49
50
51
52
53
54
55
<!DOCTYPE html>
<html>
<head>
<title>StopWatchJS</title>
</head>
<body data-stopwatch="1">
<h1>StopWatchJS</h1>
<script type="text/javascript"
src="//cdnjs.cloudflare.com/ajax/libs/require.js/2.1.22/require.min.js"></script>
<script type="text/javascript">
require.config({
paths: {
"StopWatch": "../src"
}
});
define('main',['StopWatch/StopWatch','StopWatch/StopWatchExporter/SymfonyExporter','StopWatch/StopWatchViewer/SymfonyViewer'],function(StopWatch,SymfonyExporter,SymfonyViewer){
StopWatch.start('initialisation','section');
var worker = new Worker('./worker/worker1.js');
var workerSection = StopWatch.openSection('WebWorker');
worker.addEventListener('message',function(e){
var data = e.data;
switch (data.cmd) {
case 'msg': window.console.log(data.msg); break;
case 'start': workerSection.start(data.event,data.category); break;
case 'lap': workerSection.lap(data.event); break;
case 'stop': workerSection.stop(data.event); break;
}
});
StopWatch.stop('initialisation');
StopWatch.start('waiting','section');
setTimeout(function(){
worker.postMessage({'cmd':'stop'});
StopWatch.closeSection(workerSection);
StopWatch.stop('waiting');
StopWatch.start('workingResult','section');
},1000);
setTimeout(function(){ StopWatch.stop('workingResult'); },1100);
setTimeout(function(){
var exporter = new SymfonyExporter();
exporter.setStopWatch(StopWatch);
var viewer = new SymfonyViewer();
viewer.setStopWatchExporter( exporter );
viewer.open();
},1250);
});
require(['main']);
</script>
</body>
</html>