closes #492, i think

unfortunately, EBSCO exports still aren't working for me, but it doesn't seem to be Zotero's fault; i'm just not getting any RIS output to begin with. i'll give this another glance later today.
This commit is contained in:
Simon Kornblith 2007-01-08 17:38:02 +00:00
parent fceb21f629
commit 97665e4060
2 changed files with 43 additions and 39 deletions

View File

@ -49,6 +49,8 @@ var Zotero_Browser = new function() {
this.tabSelect = tabSelect;
this.tabClose = tabClose;
this.resize = resize;
this.finishScraping = finishScraping;
this.itemDone = itemDone;
this.tabbrowser = null;
this.appcontent = null;
@ -344,6 +346,41 @@ var Zotero_Browser = new function() {
tab.page.annotations.refresh();
}
/*
* Callback to be executed when scraping is complete
*/
function finishScraping(obj, returnValue, collection) {
if(!returnValue) {
Zotero_Browser.Progress.changeHeadline(Zotero.getString("ingester.scrapeError"));
Zotero_Browser.Progress.addDescription(Zotero.getString("ingester.scrapeErrorDescription"));
}
if(collection) {
// notify about modified items
Zotero.Notifier.trigger("modify", "collection", collection.getID());
}
Zotero_Browser.Progress.fade();
}
/*
* Callback to be executed when an item has been finished
*/
function itemDone(obj, item, collection) {
var title = item.getField("title");
var icon = item.getImageSrc();
Zotero_Browser.Progress.addLines([title], [icon]);
// add item to collection, if one was specified
if(collection) {
Zotero.Notifier.disable();
collection.addItem(item.getID());
Zotero.Notifier.enable();
}
}
//////////////////////////////////////////////////////////////////////////////
//
// Private Zotero_Browser methods
@ -553,28 +590,12 @@ Zotero_Browser.Tab.prototype.translate = function(saveLocation) {
// use first translator available
this.page.translate.setTranslator(this.page.translators[0]);
this.page.translate.setHandler("select", me._selectItems);
this.page.translate.setHandler("itemDone", function(obj, item) { me._itemDone(obj, item, saveLocation) });
this.page.translate.setHandler("done", function(obj, item) { me._finishScraping(obj, item, saveLocation) });
this.page.translate.setHandler("itemDone", function(obj, item) { Zotero_Browser.itemDone(obj, item, saveLocation) });
this.page.translate.setHandler("done", function(obj, item) { Zotero_Browser.finishScraping(obj, item, saveLocation) });
this.page.translate.translate();
}
}
/*
* Callback to be executed when an item has been finished
*/
Zotero_Browser.Tab.prototype._itemDone = function(obj, item, collection) {
var title = item.getField("title");
var icon = item.getImageSrc();
Zotero_Browser.Progress.addLines([title], [icon]);
// add item to collection, if one was specified
if(collection) {
Zotero.Notifier.disable();
collection.addItem(item.getID());
Zotero.Notifier.enable();
}
}
/*
* called when a user is supposed to select items
*/
@ -591,23 +612,6 @@ Zotero_Browser.Tab.prototype._selectItems = function(obj, itemList) {
return io.dataOut;
}
/*
* Callback to be executed when scraping is complete
*/
Zotero_Browser.Tab.prototype._finishScraping = function(obj, returnValue, collection) {
if(!returnValue) {
Zotero_Browser.Progress.changeHeadline(Zotero.getString("ingester.scrapeError"));
Zotero_Browser.Progress.addDescription(Zotero.getString("ingester.scrapeErrorDescription"));
}
if(collection) {
// notify about modified items
Zotero.Notifier.trigger("modify", "collection", collection.getID());
}
Zotero_Browser.Progress.fade();
}
/*
* returns the URL of the image representing the translator to be called on the
* current page, or false if the page cannot be scraped

View File

@ -749,18 +749,18 @@ Zotero.Ingester.MIMEHandler.StreamListener.prototype.onStopRequest = function(ch
try {
saveLocation = frontWindow.ZoteroPane.getSelectedCollection();
} catch(e) {}
translation.setHandler("itemDone", function(obj, item) { frontWindow.Zotero_Browser._itemDone(obj, item, saveLocation) });
translation.setHandler("done", function(obj, item) { frontWindow.Zotero_Browser._finishScraping(obj, item, saveLocation) });
translation.setHandler("itemDone", function(obj, item) { frontWindow.Zotero_Browser.itemDone(obj, item, saveLocation) });
translation.setHandler("done", function(obj, item) { frontWindow.Zotero_Browser.finishScraping(obj, item, saveLocation) });
// attempt to retrieve translators
var translators = translation.getTranslators();
if(!translators.length) {
// we lied. we can't really translate this file. call
// nsIExternalHelperAppService with the data
this._frontWindow.Zotero_Browser.Progress.kill();
frontWindow.Zotero_Browser.Progress.kill();
var streamListener;
if(streamListener = externalHelperAppService.doContent(this._contentType, this._request, this._frontWindow)) {
if(streamListener = externalHelperAppService.doContent(this._contentType, this._request, frontWindow)) {
// create a string input stream
var inputStream = Components.classes["@mozilla.org/io/string-input-stream;1"].
createInstance(Components.interfaces.nsIStringInputStream);