Ticket #1753: recognizePDF.js.diff
| File recognizePDF.js.diff, 1.9 KB (added by ajlyon, 6 years ago) |
|---|
-
chrome/content/zotero/recognizePDF.js
174 174 * @param {String} [error] The error name, if recognition was unsuccessful. 175 175 */ 176 176 Zotero_RecognizePDF.ItemRecognizer.prototype._callback = function(newItem, error) { 177 var recognitionSuccess = false; 177 178 if(this._stopped) { 178 179 if(newItem) Zotero.Items.erase(newItem.id); 179 180 return; 180 181 } 181 182 182 183 if(newItem) { 184 recognitionSuccess=true; 185 } else if (Zotero.Prefs.get('documentOnRecognizeFailureHack')) { 186 newItem = new Zotero.Item('document'); 187 newItem.setField('title', this._item.getFile().leafName); 188 newItem.save(); 189 } 190 191 if(newItem) { 183 192 // put new item in same collections as the old one 184 193 var itemCollections = this._item.getCollections(); 185 194 for(var j=0; j<itemCollections.length; j++) { 186 195 var collection = Zotero.Collections.get(itemCollections[j]); 187 196 collection.addItem(newItem.id); 188 197 } 189 198 190 199 // put old item as a child of the new item 191 200 this._item.setSource(newItem.id); 192 this._item.save(); 201 this._item.save(); 193 202 } 194 203 195 204 // add name 196 205 this._progressWindow.document.getElementById("item-"+this._item.id+"-title"). 197 setAttribute("label", ( newItem? newItem.getField("title") : Zotero.getString(error)));206 setAttribute("label", (recognitionSuccess ? newItem.getField("title") : Zotero.getString(error))); 198 207 // update icon 199 208 this._progressWindow.document.getElementById("item-"+this._item.id+"-icon"). 200 setAttribute("src", ( newItem? Zotero_RecognizePDF_SUCCESS_IMAGE : Zotero_RecognizePDF_FAILURE_IMAGE));209 setAttribute("src", (recognitionSuccess ? Zotero_RecognizePDF_SUCCESS_IMAGE : Zotero_RecognizePDF_FAILURE_IMAGE)); 201 210 202 211 if(error == "recognizePDF.limit") { 203 212 // now done, since we hit the query limit … … 455 464 obj[i] = items; 456 465 return obj; 457 466 } 458 } 459 No newline at end of file 467 }