Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F124334082
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, Aug 1, 19:49
Size
1 KB
Mime Type
text/html
Expires
Sun, Aug 3, 19:49 (2 d)
Engine
blob
Format
Raw Data
Handle
27835407
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