|
@@ -9,15 +9,15 @@ Reporter.prototype.subscribeMany = function(funcs) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
murom.getMany = function(urls, completionCallback) |
|
|
|
|
|
|
|
|
murom.getMany = function(items, completionCallback) |
|
|
{ |
|
|
{ |
|
|
var self = this; |
|
|
var self = this; |
|
|
var results = new Array(urls.length).fill(null); |
|
|
|
|
|
|
|
|
var results = {}; |
|
|
|
|
|
|
|
|
var count = 0; |
|
|
var count = 0; |
|
|
function reportCompletion() |
|
|
function reportCompletion() |
|
|
{ |
|
|
{ |
|
|
if (++count == urls.length) |
|
|
|
|
|
|
|
|
if (++count == items.length) |
|
|
{ |
|
|
{ |
|
|
if (completionCallback) |
|
|
if (completionCallback) |
|
|
{ |
|
|
{ |
|
@@ -26,43 +26,37 @@ murom.getMany = function(urls, completionCallback) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for (var id in urls) |
|
|
|
|
|
|
|
|
for (var id in items) |
|
|
{ |
|
|
{ |
|
|
const url = urls[id]; |
|
|
|
|
|
const urlId = id; |
|
|
|
|
|
murom.get( |
|
|
|
|
|
url, |
|
|
|
|
|
function(contents) |
|
|
|
|
|
{ |
|
|
|
|
|
results[urlId] = contents; |
|
|
|
|
|
reportCompletion() |
|
|
|
|
|
}, |
|
|
|
|
|
function(status) |
|
|
|
|
|
{ |
|
|
|
|
|
LOG( |
|
|
|
|
|
formatString( |
|
|
|
|
|
"ERROR Could not download URL: '{0}' status: '{1}'", |
|
|
|
|
|
url, |
|
|
|
|
|
status |
|
|
|
|
|
) |
|
|
|
|
|
); |
|
|
|
|
|
reportCompletion() |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
murom.import = function(urls, completionCallback) |
|
|
|
|
|
{ |
|
|
|
|
|
murom.getMany( |
|
|
|
|
|
urls, |
|
|
|
|
|
function(contents) |
|
|
|
|
|
|
|
|
const item = items[id]; |
|
|
|
|
|
const url = item[0]; |
|
|
|
|
|
const name = item[1]; |
|
|
|
|
|
var isBinary = (item[2] == "b"); |
|
|
|
|
|
|
|
|
|
|
|
function success(contents) |
|
|
{ |
|
|
{ |
|
|
for (var id in contents) |
|
|
|
|
|
{ |
|
|
|
|
|
eval(contents[id]); |
|
|
|
|
|
} |
|
|
|
|
|
completionCallback(); |
|
|
|
|
|
|
|
|
results[name] = contents; |
|
|
|
|
|
reportCompletion() |
|
|
|
|
|
} |
|
|
|
|
|
function failure(status) |
|
|
|
|
|
{ |
|
|
|
|
|
LOG( |
|
|
|
|
|
formatString( |
|
|
|
|
|
"ERROR Could not download URL: '{0}' status: '{1}'", |
|
|
|
|
|
url, |
|
|
|
|
|
status |
|
|
|
|
|
) |
|
|
|
|
|
); |
|
|
|
|
|
reportCompletion() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (isBinary) |
|
|
|
|
|
{ |
|
|
|
|
|
murom.getb(url, success, failure); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
murom.get(url, success, failure); |
|
|
} |
|
|
} |
|
|
); |
|
|
|
|
|
|
|
|
} |
|
|
}; |
|
|
}; |