-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimport_script.html
70 lines (50 loc) · 1.58 KB
/
import_script.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<html>
<head>
<title></title>
</head>
<body>
<div id="content"></div>
<button onclick="launch();" >Prime Number Start/Stop</button>
Delay : <input id="delay" value="0" style="width:30px;" />
RTT Count : <text id="rtt_count" >0</text>
<div id="plane" style="color:0x000000; width:500px; height:500px;"></div>
<script type="text/javascript">
debug = window.location.search.indexOf('debug');
USE_TRANSFERABLE = true;
</script>
<script type="text/javascript" src="src/WW.js"></script>
<script type="text/javascript" src="src/utils.js"></script>
<script type="text/javascript" src="example/import_script.js"></script>
<script type="text/javascript">
content = document.getElementById("content");
content.innerHTML = (debug > 0) ? "Are Transferables Supported ? : "+supported+
"<br/>Using Transferables : "+USE_TRANSFERABLE+"<br/>" : "";
/* Worker Task */
var import_script_task = WW.ImportScriptTask();
import_script_task.addExternalScript("example/import_script_test.js");
/* End Worker Task */
/* Worker */
var ww = new WW.Worker(import_script_task.toBlob());
plane = document.getElementById("plane");
/* Worker Listener */
ww.addListener('print', function (pResult) {
plane.style.backgroundColor = pResult;
content.innerHTML = "Result : "+pResult;
});
var i =0;
function import_script(){
ww.Query('import_script', 5, ++i );
setTimeout(import_script, 100);
}
var run = false;
function launch(){
if(!run){
import_script();
run = true;
} else if (run){
ww.terminate();
}
}
</script>
</body>
</html>