Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
56 lines (52 sloc) 1.94 KB
Index: chrome/content/zotero/recognizePDF.js
===================================================================
--- chrome/content/zotero/recognizePDF.js (revision 7517)
+++ chrome/content/zotero/recognizePDF.js (working copy)
@@ -174,30 +174,39 @@
* @param {String} [error] The error name, if recognition was unsuccessful.
*/
Zotero_RecognizePDF.ItemRecognizer.prototype._callback = function(newItem, error) {
+ var recognitionSuccess = false;
if(this._stopped) {
if(newItem) Zotero.Items.erase(newItem.id);
return;
}
if(newItem) {
+ recognitionSuccess=true;
+ } else if (Zotero.Prefs.get('documentOnRecognizeFailureHack')) {
+ newItem = new Zotero.Item('document');
+ newItem.setField('title', this._item.getFile().leafName);
+ newItem.save();
+ }
+
+ if(newItem) {
// put new item in same collections as the old one
var itemCollections = this._item.getCollections();
for(var j=0; j<itemCollections.length; j++) {
var collection = Zotero.Collections.get(itemCollections[j]);
collection.addItem(newItem.id);
}
-
+
// put old item as a child of the new item
this._item.setSource(newItem.id);
- this._item.save();
+ this._item.save();
}
// add name
this._progressWindow.document.getElementById("item-"+this._item.id+"-title").
- setAttribute("label", (newItem ? newItem.getField("title") : Zotero.getString(error)));
+ setAttribute("label", (recognitionSuccess ? newItem.getField("title") : Zotero.getString(error)));
// update icon
this._progressWindow.document.getElementById("item-"+this._item.id+"-icon").
- setAttribute("src", (newItem ? Zotero_RecognizePDF_SUCCESS_IMAGE : Zotero_RecognizePDF_FAILURE_IMAGE));
+ setAttribute("src", (recognitionSuccess ? Zotero_RecognizePDF_SUCCESS_IMAGE : Zotero_RecognizePDF_FAILURE_IMAGE));
if(error == "recognizePDF.limit") {
// now done, since we hit the query limit
@@ -455,4 +464,4 @@
obj[i] = items;
return obj;
}
-}
\ No newline at end of file
+}