diff --git a/lib/torque/animator.js b/lib/torque/animator.js index 263b5c9..0476534 100644 --- a/lib/torque/animator.js +++ b/lib/torque/animator.js @@ -2,9 +2,9 @@ exports.torque = exports.torque || {}; - var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame; + var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || function(c) { setTimeout(c, 16); } - var cancelAnimationFrame = window.requestAnimationFrame || window.mozCancelAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame; + var cancelAnimationFrame = window.requestAnimationFrame || window.mozCancelAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || function(c) { cancelTimeout(c); }; /** * options: diff --git a/lib/torque/gmaps/torque.js b/lib/torque/gmaps/torque.js index 8231f51..82979a4 100644 --- a/lib/torque/gmaps/torque.js +++ b/lib/torque/gmaps/torque.js @@ -63,7 +63,6 @@ GMapsTorqueLayer.prototype = _.extend({}, this.provider = new this.providers[this.options.provider](this.options); this.renderer = new this.renderers[this.options.renderer](this.getCanvas(), this.options); - console.log(this.getCanvas()); this._initTileLoader(this.options.map, this.getProjection()); diff --git a/lib/torque/provider.json.js b/lib/torque/provider.json.js index d7e0a85..b1c127d 100644 --- a/lib/torque/provider.json.js +++ b/lib/torque/provider.json.js @@ -1,8 +1,12 @@ (function(exports) { - exports.torque = exports.torque || {}; + var torque = exports.torque = exports.torque || {}; var providers = exports.torque.providers = exports.torque.providers || {}; + var Uint8Array = torque.types.Uint8Array; + var Int32Array = torque.types.Int32Array; + var Uint32Array = torque.types.Uint32Array; + // format('hello, {0}', 'rambo') -> "hello, rambo" function format(str) { for(var i = 1; i < arguments.length; ++i) { diff --git a/lib/torque/provider.jsonarray.js b/lib/torque/provider.jsonarray.js index c07ebee..d4c4929 100644 --- a/lib/torque/provider.jsonarray.js +++ b/lib/torque/provider.jsonarray.js @@ -1,8 +1,13 @@ (function(exports) { - exports.torque = exports.torque || {}; + + var torque = exports.torque = exports.torque || {}; var providers = exports.torque.providers = exports.torque.providers || {}; + var Uint8Array = torque.types.Uint8Array; + var Int32Array = torque.types.Int32Array; + var Uint32Array = torque.types.Uint32Array; + // format('hello, {0}', 'rambo') -> "hello, rambo" function format(str, attrs) { for(var i = 1; i < arguments.length; ++i) { @@ -50,6 +55,9 @@ } return keys; }, + + + /** * diff --git a/lib/torque/request.js b/lib/torque/request.js index 55081ea..10ed61a 100644 --- a/lib/torque/request.js +++ b/lib/torque/request.js @@ -2,17 +2,28 @@ var torque = exports.torque = exports.torque || {}; torque.net = torque.net || {}; + function get(url, callback) { - var req = new XMLHttpRequest(); - req.onreadystatechange = function() { - if (req.readyState == 4){ - if (req.status == 200){ - callback(req); - } else { - callback(null); - } + var request = XMLHttpRequest; + // from d3.js + if (window.XDomainRequest + && !("withCredentials" in request) + && /^(http(s)?:)?\/\//.test(url)) request = XDomainRequest; + var req = new request(); + + + function respond() { + var status = req.status, result; + if (!status && req.responseText || status >= 200 && status < 300 || status === 304) { + callback(req); + } else { + callback(null); } - }; + } + + "onload" in req + ? req.onload = req.onerror = respond + : req.onreadystatechange = function() { req.readyState > 3 && respond(); }; req.open("GET", url, true); //req.responseType = 'arraybuffer';