Обновить getMany. Убрать import
This commit is contained in:
@@ -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 item = items[id];
|
||||||
const urlId = id;
|
const url = item[0];
|
||||||
murom.get(
|
const name = item[1];
|
||||||
url,
|
var isBinary = (item[2] == "b");
|
||||||
function(contents)
|
|
||||||
{
|
function success(contents)
|
||||||
results[urlId] = contents;
|
{
|
||||||
reportCompletion()
|
results[name] = contents;
|
||||||
},
|
reportCompletion()
|
||||||
function(status)
|
}
|
||||||
{
|
function failure(status)
|
||||||
LOG(
|
{
|
||||||
formatString(
|
LOG(
|
||||||
"ERROR Could not download URL: '{0}' status: '{1}'",
|
formatString(
|
||||||
url,
|
"ERROR Could not download URL: '{0}' status: '{1}'",
|
||||||
status
|
url,
|
||||||
)
|
status
|
||||||
);
|
)
|
||||||
reportCompletion()
|
);
|
||||||
}
|
reportCompletion()
|
||||||
);
|
}
|
||||||
|
|
||||||
|
if (isBinary)
|
||||||
|
{
|
||||||
|
murom.getb(url, success, failure);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
murom.get(url, success, failure);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
murom.import = function(urls, completionCallback)
|
|
||||||
{
|
|
||||||
murom.getMany(
|
|
||||||
urls,
|
|
||||||
function(contents)
|
|
||||||
{
|
|
||||||
for (var id in contents)
|
|
||||||
{
|
|
||||||
eval(contents[id]);
|
|
||||||
}
|
|
||||||
completionCallback();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|||||||
Reference in New Issue
Block a user