From 1b9c89fd595a9f6afb1eaed5c30c16e3970887ad Mon Sep 17 00:00:00 2001 From: aurimasv Date: Sat, 22 Sep 2012 06:32:18 -0500 Subject: [PATCH] Add support for multiple identifier lookup to the magic wand tool. Enable shift+enter for submitting input in multiline mode. Use shift+enter in single line mode to convert to multiline --- chrome/content/zotero/lookup.js | 191 ++++++++++++++----- chrome/content/zotero/zoteroPane.xul | 14 +- chrome/locale/en-US/zotero/zotero.dtd | 5 +- chrome/locale/en-US/zotero/zotero.properties | 1 + chrome/skin/default/zotero/overlay.css | 4 + 5 files changed, 158 insertions(+), 57 deletions(-) diff --git a/chrome/content/zotero/lookup.js b/chrome/content/zotero/lookup.js index 1f4a3cbc0..7239ecc19 100644 --- a/chrome/content/zotero/lookup.js +++ b/chrome/content/zotero/lookup.js @@ -31,71 +31,126 @@ const Zotero_Lookup = new function () { /** * Performs a lookup by DOI, PMID, or ISBN */ - this.accept = function() { - var identifierElement = document.getElementById("zotero-lookup-textbox"); - var identifier = identifierElement.value; - - var doi = Zotero.Utilities.cleanDOI(identifier); - if(doi) { - var item = {itemType:"journalArticle", DOI:doi}; - } else { - identifier = identifier.trim().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}; + this.accept = function(textBox) { + var identifier = textBox.value; + //first look for DOIs + var ids = identifier.split(/[\s\u00A0]+/); //whitespace + non-breaking space + var items = [], doi; + for(var i=0, n=ids.length; i +