diff --git a/source/Ox/js/Request.js b/source/Ox/js/Request.js index 2e0b30f9..c6e80e90 100644 --- a/source/Ox/js/Request.js +++ b/source/Ox/js/Request.js @@ -29,15 +29,27 @@ Ox.get = function(url, callback) { Ox.getJSON Get and parse a remote JSON file # fixme: remote? same-origin-policy? jsonp? (url, callback) -> undefined - url Remote URL + url One or more remote URLs callback Callback function - data The parsed contents of the remote resource + data The parsed contents of the remote resource(s) + For multiple URLs, keys are file names, values are contents @*/ -Ox.getJSON = function(url, callback) { - Ox.get(url, function(data) { - callback(JSON.parse(data)); - }); -}; +Ox.getJSON = (function() { + function getJSON(url, callback) { + Ox.get(url, function(data) { + callback(JSON.parse(data)); + }); + } + return function(url, callback) { + var urls = Ox.toArray(url), data = {}, i = 0, n = urls.length; + urls.forEach(function(url) { + getJSON(url, function(data_) { + data[url] = data_; + ++i == n && callback(n == 1 ? data[url] : data); + }); + }); + }; +}()); /*@ Ox.getJSONC Get and parse a remote JSONC file @@ -154,7 +166,7 @@ Ox.loadFiles = (function() { files = Ox.toArray(files); var i = 0, n = files.length, images = {}; Ox.toArray(files).forEach(function(file) { - loadFile(file, function(image) { + Ox.loadFile(file, function(image) { if (image) { images[file] = image; }