91459f95f7
- Support for group libraries - General support for multiple libraries of different types - Streamlined sync support - Using solely libraryID and key rather than itemID, and removed all itemID-changing code - Combined two requests for increased performance and decreased server load - Added warning on user account change - Provide explicit error message on SSL failure - Removed snapshot and link toolbar buttons and changed browser context menu options and drags to create parent items + snapshots - Closes #786, Add numPages field - Fixes #1063, Duplicate item with tags broken in Sync Preview - Added better purging of deleted tags - Added local user key before first sync - Add clientDateModified to all objects for more flexibility in syncing - Added new triples-based Relation object type, currently used to store links between items copied between local and group libraries - Updated zotero.org translator for groups - Additional trigger-based consistency checks - Fixed broken URL drag in Firefox 3.5 - Disabled zeroconf menu option (no longer functional) Developer-specific changes: - Overhauled data layer - Data object constructors no longer take arguments (return to 1.0-like API) - Existing objects can be retrieved by setting id or library/key properties - id/library/key must be set for new objects before other fields - New methods: - ZoteroPane.getSelectedLibraryID() - ZoteroPane.getSelectedGroup(asID) - ZoteroPane.addItemFromDocument(doc, itemType, saveSnapshot) - ZoteroPane.addItemFromURL(url, itemType) - ZoteroPane.canEdit() - Zotero.CollectionTreeView.selectLibrary(libraryID) - New Zotero.URI methods - Changed methods - Many data object methods now take a libraryID - ZoteroPane.addAttachmentFromPage(link, itemID) - Removed saveItem and saveAttachments parameters from Zotero.Translate constructor - translate() now takes a libraryID, null for local library, or false to not save items (previously on constructor) - saveAttachments is now a translate() parameter - Zotero.flattenArguments() better handles passed objects - Zotero.File.getFileHash() (not currently used)
54 lines
1.9 KiB
JavaScript
54 lines
1.9 KiB
JavaScript
const Zotero_Lookup = new function () {
|
|
this.accept = function() {
|
|
document.getElementById("progress").setAttribute("status", "animate");
|
|
document.getElementById("accept-button").disabled = true;
|
|
var identifier = document.getElementById("lookup-textbox").value;
|
|
if(identifier.substr(0, 3) == "10.") {
|
|
// DOI
|
|
var item = {itemType:"journalArticle", DOI:identifier};
|
|
} else {
|
|
identifier = identifier.replace("-", "", "g");
|
|
if(identifier.length == 10 || identifier.length == 13) {
|
|
// ISBN
|
|
var item = {itemType:"book", ISBN:identifier};
|
|
} else {
|
|
// PMID; right now, PMIDs are 8 digits, so there doesn't seem like we will need to
|
|
// discriminate for a fairly long time
|
|
var item = {itemType:"journalArticle", contextObject:"rft_id=info:pmid/"+identifier};
|
|
}
|
|
}
|
|
|
|
var translate = new Zotero.Translate("search");
|
|
translate.setSearch(item);
|
|
|
|
// be lenient about translators
|
|
var translators = translate.getTranslators();
|
|
translate.setTranslator(translators);
|
|
|
|
translate.setHandler("done", function(translate, success) {
|
|
if(success) {
|
|
window.close();
|
|
} else {
|
|
document.getElementById("accept-button").disabled = undefined;
|
|
document.getElementById("progress").setAttribute("status", "error");
|
|
var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
|
.getService(Components.interfaces.nsIPromptService);
|
|
prompts.alert(window, Zotero.getString("lookup.failure.title"),
|
|
Zotero.getString("lookup.failure.description"));
|
|
}
|
|
});
|
|
|
|
var libraryID = null;
|
|
var collection = false;
|
|
try {
|
|
libraryID = window.opener.ZoteroPane.getSelectedLibraryID();
|
|
collection = window.opener.ZoteroPane.getSelectedCollection();
|
|
} catch(e) {}
|
|
translate.setHandler("itemDone", function(obj, item) {
|
|
if(collection) collection.addItem(item.id);
|
|
});
|
|
|
|
translate.translate(libraryID);
|
|
return false;
|
|
}
|
|
}
|