From e35b035224244e8522c05815ae253ff31ae6d959 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 21 Oct 2017 03:26:27 -0400 Subject: [PATCH] Separate identifer parsing from Add Item by Identifier and search translation - Move identifier detection to `Zotero.Utilities.Internal.extractIdentifiers()` so that it can be used for things other than Add Item by Identifier (e.g., translation-server) - Add a `Zotero.Translate.Search::setIdentifier()` function that takes an identifier object produced by `extractIdentifiers()` (`{ DOI: "10/..." }`), converts that to the search format expected by translators, and calls setSearch() --- chrome/content/zotero/lookup.js | 73 +------------------ .../zotero/xpcom/translation/translate.js | 31 ++++++++ .../zotero/xpcom/utilities_internal.js | 67 +++++++++++++++++ test/tests/utilities_internalTest.js | 53 +++++++++++++- 4 files changed, 154 insertions(+), 70 deletions(-) diff --git a/chrome/content/zotero/lookup.js b/chrome/content/zotero/lookup.js index 66948c640..885211d7c 100644 --- a/chrome/content/zotero/lookup.js +++ b/chrome/content/zotero/lookup.js @@ -32,73 +32,8 @@ var Zotero_Lookup = new function () { * Performs a lookup by DOI, PMID, or ISBN */ this.accept = Zotero.Promise.coroutine(function* (textBox) { - var foundIDs = []; //keep track of identifiers to avoid duplicates - var identifier = textBox.value; - //first look for DOIs - var ids = identifier.split(/[\s\u00A0]+/); //whitespace + non-breaking space - var searches = [], doi; - for(var i=0, n=ids.length; i