jsbin/public/js/editors/sync-worker.js
Aron Carroll ef05666727 Move PHP codebase into ./public directory
Updated all relevant paths to point to new locations. Webs servers will
need to be updated to point to ./public. The build script remains in the
root and will work as before.
2012-04-17 11:38:35 +01:00

40 lines
774 B
JavaScript

// directly from @wookiehangover's amazing demo: https://github.com/wookiehangover/pandaco.de
var reader = new FileReader();
var modified_cache;
self.addEventListener('message', function(e){
var interval = 500;
var multiplier = 1;
var poll = function(){
reader.readAsText(e.data);
setTimeout(poll, interval * multiplier);
};
poll();
reader.onload = function(file){
var modified = +new Date(e.data.lastModifiedDate);
if( modified_cache !== modified ){
multiplier = 1;
modified_cache = modified;
postMessage({
body: file.target.result,
size: file.total,
lastModified: file.timeStamp
});
} else {
delete file;
}
if( multiplier < 8 )
multiplier += 1;
};
}, false);