2015-08-22 16:37:55 +02:00
|
|
|
<!doctype html>
|
|
|
|
<title>Worker</title>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
window.onload = function()
|
|
|
|
{
|
|
|
|
var worker = new Worker("worker.js");
|
|
|
|
var terminal = document.getElementById("terminal");
|
|
|
|
|
|
|
|
worker.onmessage = function(e)
|
|
|
|
{
|
|
|
|
terminal.textContent += e.data;
|
|
|
|
}
|
2015-09-12 00:35:44 +02:00
|
|
|
|
|
|
|
terminal.onkeypress = function(e)
|
|
|
|
{
|
|
|
|
e.preventDefault();
|
|
|
|
worker.postMessage(String.fromCharCode(e.which));
|
|
|
|
};
|
2015-08-22 16:37:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var start = Date.now();
|
|
|
|
setInterval(function()
|
|
|
|
{
|
|
|
|
document.getElementById("time").textContent = (Date.now() - start) / 1000 | 0;
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<span id=time></span>s
|
|
|
|
<hr>
|
2015-09-12 00:35:44 +02:00
|
|
|
<textarea rows=25 cols=80 id=terminal></textarea>
|
2015-08-22 16:37:55 +02:00
|
|
|
|