Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F118481413
index.html
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Jun 20, 08:53
Size
1 KB
Mime Type
text/html
Expires
Sun, Jun 22, 08:53 (1 d, 13 h)
Engine
blob
Format
Raw Data
Handle
26865235
Attached To
R4897 i2b2-webclient
index.html
View Options
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!--<script type="text/javascript" src="demo_workers.js"></script> -->
</head>
<body>
<p>Count numbers: <output id="result"></output></p>
<button onclick="startWorker()">Start Worker</button>
<button onclick="stopWorker()">Stop Worker</button>
<script>
var w;
function startWorker() {
if(typeof(Worker) !== "undefined") {
if(typeof(w) == "undefined") {
w = new Worker(URL.createObjectURL(new Blob(["("+worker_function.toString()+")()"], {type: 'text/javascript'})));
//w = new Worker("demo_workers.js");
}
w.onmessage = function(event) {
document.getElementById("result").innerHTML = event.data;
};
} else {
document.getElementById("result").innerHTML = "Sorry! No Web Worker support.";
}
}
function stopWorker() {
w.terminate();
w = undefined;
}
function worker_function() {
// all code here
function timedCount() {
i = i + 1;
postMessage(i);
setTimeout(timedCount,100);
}
var i = 0;
timedCount();
}
</script>
</body>
</html>
Event Timeline
Log In to Comment