mirror of
https://github.com/jsbin/jsbin.git
synced 2026-01-25 15:38:56 +00:00
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.
40 lines
774 B
JavaScript
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); |