Merge pull request #229 from aurimasv/args
Add a way for translators to pass arguments to callbacks for HTTP requests
This commit is contained in:
commit
b08e52363b
2 changed files with 12 additions and 3 deletions
|
@ -576,9 +576,10 @@ Zotero.HTTP = new function() {
|
|||
/**
|
||||
* Handler for XMLHttpRequest state change
|
||||
*
|
||||
* @param {nsIXMLHttpRequest} XMLHttpRequest whose state just changed
|
||||
* @param {Function} [onDone] Callback for request completion
|
||||
* @param {nsIXMLHttpRequest} xmlhttp XMLHttpRequest whose state just changed
|
||||
* @param {Function} [callback] Callback for request completion
|
||||
* @param {String} [responseCharset] Character set to force on the response
|
||||
* @param {*} [data] Data to be passed back to callback as the second argument
|
||||
* @private
|
||||
*/
|
||||
function _stateChange(xmlhttp, callback, responseCharset, data) {
|
||||
|
|
|
@ -208,14 +208,22 @@ Zotero.Utilities.Translate.prototype.processDocuments = function(urls, processor
|
|||
var translate = this._translate;
|
||||
if(exception) {
|
||||
var myException = function(e) {
|
||||
var browserDeleted;
|
||||
try {
|
||||
exception(e);
|
||||
} catch(e) {
|
||||
try {
|
||||
Zotero.Browser.deleteHiddenBrowser(hiddenBrowser);
|
||||
} catch(e) {}
|
||||
browserDeleted = true;
|
||||
translate.complete(false, e);
|
||||
}
|
||||
|
||||
if(!browserDeleted) {
|
||||
try {
|
||||
Zotero.Browser.deleteHiddenBrowser(hiddenBrowser);
|
||||
} catch(e) {}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var myException = function(e) {
|
||||
|
@ -402,7 +410,7 @@ Zotero.Utilities.Translate.prototype.doGet = function(urls, processor, done, res
|
|||
}
|
||||
|
||||
if(callAgain) {
|
||||
me.doGet(urls, processor, done);
|
||||
me.doGet(urls, processor, done, responseCharset);
|
||||
} else {
|
||||
if(done) {
|
||||
done();
|
||||
|
|
Loading…
Reference in a new issue