mirror of
https://github.com/turuslan/HackTimer
synced 2024-11-21 15:10:11 +00:00
Checking fake id in list before removing (clearTimeout, clearInterval) in worker. Removing fake id from list after setTimeout callback was called in worker. Minified version.
This commit is contained in:
parent
1177ef0328
commit
3b71d4f731
@ -14,17 +14,24 @@ onmessage = function (event) {
|
|||||||
}, time);
|
}, time);
|
||||||
break;
|
break;
|
||||||
case 'clearInterval':
|
case 'clearInterval':
|
||||||
clearInterval(fakeIdToId[fakeId]);
|
if (fakeIdToId.hasOwnProperty (fakeId)) {
|
||||||
delete fakeIdToId[fakeId];
|
clearInterval(fakeIdToId[fakeId]);
|
||||||
|
delete fakeIdToId[fakeId];
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'setTimeout':
|
case 'setTimeout':
|
||||||
fakeIdToId[fakeId] = setTimeout(function () {
|
fakeIdToId[fakeId] = setTimeout(function () {
|
||||||
postMessage({fakeId: fakeId});
|
postMessage({fakeId: fakeId});
|
||||||
|
if (fakeIdToId.hasOwnProperty (fakeId)) {
|
||||||
|
delete fakeIdToId[fakeId];
|
||||||
|
}
|
||||||
}, time);
|
}, time);
|
||||||
break;
|
break;
|
||||||
case 'clearTimeout':
|
case 'clearTimeout':
|
||||||
clearTimeout(fakeIdToId[fakeId]);
|
if (fakeIdToId.hasOwnProperty (fakeId)) {
|
||||||
delete fakeIdToId[fakeId];
|
clearTimeout(fakeIdToId[fakeId]);
|
||||||
|
delete fakeIdToId[fakeId];
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
HackTimerWorker.min.js
vendored
2
HackTimerWorker.min.js
vendored
@ -1 +1 @@
|
|||||||
var f={},p=postMessage;onmessage=function(e){var d=e.data,i=d.i,t=d.hasOwnProperty('t')?d.t:0;switch(d.n){case'a':f[i]=setInterval(function(){p(i)},t);break;case'b':clearInterval(f[i]);delete f[i];break;case'c':f[i]=setTimeout(function(){p(i)},t);break;case'd':clearTimeout(f[i]);delete f[i];break}}
|
var f={},p=postMessage,r='hasOwnProperty';onmessage=function(e){var d=e.data,i=d.i,t=d[r]('t')?d.t:0;switch(d.n){case'a':f[i]=setInterval(function(){p(i)},t);break;case'b':if(f[r](i)){clearInterval(f[i]);delete f[i]}break;case'c':f[i]=setTimeout(function(){p(i);if(f[r](i))delete f[i]},t);break;case'd':if(f[r](i)){clearTimeout(f[i]);delete f[i]}break}}
|
Loading…
Reference in New Issue
Block a user