mirror of
https://github.com/classilla/tenfourfox.git
synced 2026-03-13 20:17:00 +00:00
51 lines
845 B
JavaScript
51 lines
845 B
JavaScript
var count = 0;
|
|
var id;
|
|
|
|
onmessage = function(evt)
|
|
{
|
|
try
|
|
{
|
|
switch(evt.data)
|
|
{
|
|
case "TimeoutHandler":
|
|
count = 0;
|
|
id = setTimeout("TimeoutHandler()", 10);
|
|
postMessage('hello');
|
|
break;
|
|
case "IntervalHandler":
|
|
count = 0;
|
|
id = setInterval("IntervalHandler()", 10);
|
|
postMessage('hello');
|
|
break;
|
|
}
|
|
}
|
|
catch(ex)
|
|
{
|
|
postMessage("Fail");
|
|
}
|
|
}
|
|
|
|
function TimeoutHandler()
|
|
{
|
|
count++;
|
|
postMessage("worker");
|
|
|
|
id = setTimeout("TimeoutHandler()", 10);
|
|
|
|
if (count >= 2)
|
|
{
|
|
clearTimeout(id);
|
|
}
|
|
}
|
|
|
|
function IntervalHandler()
|
|
{
|
|
count++;
|
|
postMessage("worker");
|
|
|
|
if (count >= 2)
|
|
{
|
|
clearInterval(id);
|
|
}
|
|
}
|