Merge pull request #11 from mcclintock-lab/add-worker-jsroot

Add jsRoot constructor option
This commit is contained in:
Marc Harter 2013-09-09 16:38:29 -07:00
commit ad2ca227e8
1 changed files with 7 additions and 3 deletions

View File

@ -1,14 +1,18 @@
(function(window,undefined){
if(window.document && window.Worker){
var worker = new Worker("shapefile.js")
var worker = null;
var Shapefile = function(o, callback){
var
w = this.worker = worker,
t = this,
o = typeof o == "string" ? {shp: o} : o
if (!worker) {
var path = (o.jsRoot || "") + "shapefile.js"
var w = worker = this.worker = new Worker(path)
}
w.onmessage = function(e){
t.data = e.date
if(callback) callback(e.data)
@ -69,7 +73,7 @@
xhr.send()
if(200 != xhr.status)
throw "Unable to load " + o.shp + " status: " + xhr.status
throw "Unable to load " + o.shp + " status: " + xhr.status
this.url = o.shp
this.stream = new Gordon.Stream(xhr.responseText)