From bc55af5b9923eb08247f5746f6ea0f9dfe7d0caf Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 19 Mar 2009 22:26:20 +0000 Subject: [PATCH] Updated Wiley InterScience translator that uses the new Zotero.Utilities.processAsync() function --- translators/Wiley InterScience.js | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/translators/Wiley InterScience.js b/translators/Wiley InterScience.js index 7342cdcdf8..0b4430ebeb 100644 --- a/translators/Wiley InterScience.js +++ b/translators/Wiley InterScience.js @@ -74,26 +74,22 @@ function doWeb(doc, url){ ids.push(m[2]); } - var setupSets = []; + + var sets = []; for each (id in ids) { var uri = host + 'tools/citex'; var poststring = "clienttype=1&subtype=1&mode=1&version=1&id=" + id; - setupSets.push({ id: id, uri: uri, poststring: poststring }); + sets.push({ id: id, uri: uri, poststring: poststring }); } - var setupCallback = function () { - if (setupSets.length) { - var set = setupSets.shift(); - Zotero.Utilities.HTTP.doPost(set.uri, set.poststring, function () { - processCallback(set.id); - }); - } - else { - Zotero.done(); - } + var setupCallback = function (set, next) { + Zotero.Utilities.HTTP.doPost(set.uri, set.poststring, function () { + next(); + }); } - var processCallback = function (id) { + var processCallback = function (set, next) { + var id = set.id; var uri = host+"tools/CitEx"; var poststring = "mode=2&format=3&type=2&file=3&exportCitation.x=16&exportCitation.y=10&exportCitation=submit"; Zotero.Utilities.HTTP.doPost(uri, poststring, function(text) { @@ -119,10 +115,11 @@ function doWeb(doc, url){ }); translator.translate(); - setupCallback(); + next(); }); } - setupCallback(); + var callbacks = [setupCallback, processCallback]; + Zotero.Utilities.processAsync(sets, callbacks, function () { Zotero.done(); }); Zotero.wait(); } \ No newline at end of file