Created
January 21, 2013 17:06
-
-
Save TCotton/4587498 to your computer and use it in GitHub Desktop.
Detects browser web worker support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WEB_WORKER = window.WEB_WORKER || {}; | |
WEB_WORKER = (function($, window) { | |
var _private = { | |
worker: null, | |
file: null, | |
web_worker: function() { | |
return !!window.Worker; | |
}, | |
set_url: function(args) { | |
this.file = args.url; | |
this.set_web_worker(); | |
}, | |
set_web_worker: function() { | |
this.worker = new Worker(this.file); | |
}, | |
get_web_worker: function() { | |
return this.worker; | |
} | |
}; | |
return { | |
init: function(args) { | |
if (_private.web_worker()) { | |
_private.set_url(args); | |
WEB_WORKER.DETECTION = _private.get_web_worker(); | |
} else { | |
WEB_WORKER.DETECTION = null; | |
} | |
} | |
}; | |
}(jQuery, window)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment