2009-12-28 09:47:49 +00:00
|
|
|
/*
|
|
|
|
***** BEGIN LICENSE BLOCK *****
|
|
|
|
|
2011-07-24 17:41:48 +00:00
|
|
|
Copyright © 2009-2011 Center for History and New Media
|
|
|
|
George Mason University, Fairfax, Virginia, USA
|
|
|
|
http://zotero.org
|
2009-12-28 09:47:49 +00:00
|
|
|
|
|
|
|
This file is part of Zotero.
|
|
|
|
|
|
|
|
Zotero is free software: you can redistribute it and/or modify
|
2011-05-18 18:34:22 +00:00
|
|
|
it under the terms of the GNU Affero General Public License as published by
|
2009-12-28 09:47:49 +00:00
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Zotero is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2011-05-18 18:34:22 +00:00
|
|
|
GNU Affero General Public License for more details.
|
2009-12-28 09:47:49 +00:00
|
|
|
|
2011-05-18 18:34:22 +00:00
|
|
|
You should have received a copy of the GNU Affero General Public License
|
2009-12-28 09:47:49 +00:00
|
|
|
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
***** END LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-07-24 17:41:48 +00:00
|
|
|
/**
|
|
|
|
* Handles UI for lookup panel
|
|
|
|
* @namespace
|
|
|
|
*/
|
2009-04-11 04:03:23 +00:00
|
|
|
const Zotero_Lookup = new function () {
|
2011-07-24 17:41:48 +00:00
|
|
|
/**
|
|
|
|
* Performs a lookup by DOI, PMID, or ISBN
|
|
|
|
*/
|
2009-04-11 04:03:23 +00:00
|
|
|
this.accept = function() {
|
2011-07-24 17:41:48 +00:00
|
|
|
var progressElement = document.getElementById("zotero-lookup-progress");
|
|
|
|
progressElement.setAttribute("status", "animate");
|
|
|
|
|
|
|
|
var acceptElement = document.getElementById("zotero-lookup-accept-button");
|
|
|
|
acceptElement.disabled = true;
|
|
|
|
|
|
|
|
var identifierElement = document.getElementById("zotero-lookup-textbox");
|
|
|
|
var identifier = identifierElement.value;
|
2009-12-04 23:52:28 +00:00
|
|
|
|
2010-10-25 00:58:47 +00:00
|
|
|
var doi = Zotero.Utilities.cleanDOI(identifier);
|
2009-12-04 23:52:28 +00:00
|
|
|
if(doi) {
|
|
|
|
var item = {itemType:"journalArticle", DOI:doi};
|
2009-04-11 04:03:23 +00:00
|
|
|
} 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};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2.0b3 megacommit
- 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)
2009-05-14 18:23:40 +00:00
|
|
|
var translate = new Zotero.Translate("search");
|
2009-04-11 04:03:23 +00:00
|
|
|
translate.setSearch(item);
|
2009-05-06 07:58:28 +00:00
|
|
|
|
2009-04-11 04:03:23 +00:00
|
|
|
// be lenient about translators
|
|
|
|
var translators = translate.getTranslators();
|
|
|
|
translate.setTranslator(translators);
|
2009-05-06 07:58:28 +00:00
|
|
|
|
2009-04-11 04:03:23 +00:00
|
|
|
translate.setHandler("done", function(translate, success) {
|
|
|
|
if(success) {
|
2011-07-24 17:41:48 +00:00
|
|
|
document.getElementById("zotero-lookup-panel").hidePopup();
|
2009-04-11 04:03:23 +00:00
|
|
|
} else {
|
2011-07-24 17:41:48 +00:00
|
|
|
acceptElement.disabled = undefined;
|
|
|
|
progressElement.removeAttribute("status");
|
|
|
|
|
2009-04-11 04:03:23 +00:00
|
|
|
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"));
|
|
|
|
}
|
|
|
|
});
|
2009-05-06 07:58:28 +00:00
|
|
|
|
2.0b3 megacommit
- 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)
2009-05-14 18:23:40 +00:00
|
|
|
var libraryID = null;
|
|
|
|
var collection = false;
|
2009-04-11 04:03:23 +00:00
|
|
|
try {
|
2011-02-03 05:00:08 +00:00
|
|
|
libraryID = window.opener.ZoteroPane.getSelectedLibraryID();
|
|
|
|
collection = window.opener.ZoteroPane.getSelectedCollection();
|
2009-04-11 04:03:23 +00:00
|
|
|
} catch(e) {}
|
2009-05-06 07:58:28 +00:00
|
|
|
translate.setHandler("itemDone", function(obj, item) {
|
2.0b3 megacommit
- 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)
2009-05-14 18:23:40 +00:00
|
|
|
if(collection) collection.addItem(item.id);
|
2009-05-06 07:58:28 +00:00
|
|
|
});
|
|
|
|
|
2.0b3 megacommit
- 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)
2009-05-14 18:23:40 +00:00
|
|
|
translate.translate(libraryID);
|
2009-04-11 04:03:23 +00:00
|
|
|
return false;
|
|
|
|
}
|
2011-07-24 17:41:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Focuses the field
|
|
|
|
*/
|
|
|
|
this.onShowing = function() {
|
|
|
|
if(!Zotero.isFx4) {
|
|
|
|
document.getElementById("zotero-lookup-panel").style.padding = "10px";
|
|
|
|
}
|
|
|
|
document.getElementById("zotero-lookup-textbox").focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Cancels the popup and resets fields
|
|
|
|
*/
|
|
|
|
this.onHidden = function() {
|
|
|
|
var progressElement = document.getElementById("zotero-lookup-progress");
|
|
|
|
if(progressElement.hasAttribute("status")) progressElement.removeAttribute("status");
|
|
|
|
document.getElementById("zotero-lookup-accept-button").disabled = undefined;
|
|
|
|
document.getElementById("zotero-lookup-textbox").value = "";
|
|
|
|
}
|
2009-04-11 04:03:23 +00:00
|
|
|
}
|