mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-16 01:13:08 +09:00
50 lines
845 B
JavaScript
50 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);
|
|
}
|
|
}
|