From 9be357216554ea894aade01eef9b07c901dae6de Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Sun, 6 Feb 2011 06:25:31 +0000 Subject: [PATCH] merge r7971-8000 to 2.1 branch --- chrome/content/zotero/xpcom/citeproc.js | 32 ++++++++++++++----- chrome/content/zotero/xpcom/sync.js | 2 +- .../zotero/xpcom/translation/translate.js | 12 ++++--- translators/NCBI PubMed.js | 4 ++- 4 files changed, 35 insertions(+), 15 deletions(-) diff --git a/chrome/content/zotero/xpcom/citeproc.js b/chrome/content/zotero/xpcom/citeproc.js index b053776ac9..cb9453da83 100644 --- a/chrome/content/zotero/xpcom/citeproc.js +++ b/chrome/content/zotero/xpcom/citeproc.js @@ -1262,7 +1262,7 @@ CSL.cloneAmbigConfig = function (config, oldconfig, tainters) { if (tainters.length == 2 || (oldconfig && oldconfig.year_suffix !== config.year_suffix)) { for (pos = 0, len = tainters.length; pos < len; pos += 1) { var oldYS = this.registry.registry[tainters[pos].id].disambig.year_suffix; - if (tainters && (false === oldYS || oldYS !== pos)) { + if (tainters && (false === oldYS || oldYS != pos)) { this.tmp.taintedItemIDs[tainters[pos].id] = true; } } @@ -1732,7 +1732,7 @@ CSL.DateParser = function (txt) { }; CSL.Engine = function (sys, style, lang, forceLang) { var attrs, langspec, localexml, locale; - this.processor_version = "1.0.106"; + this.processor_version = "1.0.108"; this.csl_version = "1.0"; this.sys = sys; this.sys.xml = new CSL.System.Xml.Parsing(); @@ -4709,8 +4709,12 @@ CSL.Node.names = { discretionary_names_length = state.tmp["et-al-use-first"]; } } else { - if (state.tmp.disambig_request && state.tmp["et-al-use-first"] < state.tmp.disambig_request.names[state.tmp.nameset_counter]) { - discretionary_names_length = state.tmp.disambig_request.names[state.tmp.nameset_counter]; + if (state.tmp.disambig_request && state.tmp.disambig_request.names[state.tmp.nameset_counter] > state.tmp["et-al-use-first"]) { + if (display_names.length < state.tmp["et-al-min"]) { + discretionary_names_length = display_names.length; + } else { + discretionary_names_length = state.tmp.disambig_request.names[state.tmp.nameset_counter]; + } } else if (display_names.length >= state.tmp["et-al-min"]) { discretionary_names_length = state.tmp["et-al-use-first"]; } @@ -8955,7 +8959,9 @@ CSL.Disambiguation.prototype.evalScan = function (ismax) { CSL.Disambiguation.prototype.disNames = function (ismax) { var pos, len; if (this.clashes[1] === 0) { - this.state.registry.registerAmbigToken(this.akey, "" + this.partners[0].id, this.base); + mybase = CSL.cloneAmbigConfig(this.base); + mybase.year_suffix = false; + this.state.registry.registerAmbigToken(this.akey, "" + this.partners[0].id, mybase); if (this.nonpartners.length === 1) { this.state.registry.registerAmbigToken(this.akey, "" + this.nonpartners[0].id, this.base); this.lists[this.listpos] = [this.base,[]]; @@ -8988,7 +8994,9 @@ CSL.Disambiguation.prototype.disGivens = function (ismax) { if (this.clashes[0] === 1) { this.base = this.decrementNames(); } - this.state.registry.registerAmbigToken(this.akey, "" + this.partners[0].id, this.base); + mybase = CSL.cloneAmbigConfig(this.base); + mybase.year_suffix = false; + this.state.registry.registerAmbigToken(this.akey, "" + this.partners[0].id, mybase); if (this.nonpartners.length === 1) { this.state.registry.registerAmbigToken(this.akey, "" + this.nonpartners[0].id, this.base); this.lists[this.listpos] = [this.base,[]]; @@ -9019,7 +9027,9 @@ CSL.Disambiguation.prototype.disGivens = function (ismax) { CSL.Disambiguation.prototype.disExtraText = function () { var pos, len; if (this.clashes[1] === 0) { - this.state.registry.registerAmbigToken(this.akey, "" + this.partners[0].id, this.base); + mybase = CSL.cloneAmbigConfig(this.base); + mybase.year_suffix = false; + this.state.registry.registerAmbigToken(this.akey, "" + this.partners[0].id, mybase); if (this.nonpartners.length === 1) { this.state.registry.registerAmbigToken(this.akey, "" + this.nonpartners[0].id, this.base); this.lists[this.listpos] = [this.base,[]]; @@ -9154,7 +9164,13 @@ CSL.Disambiguation.prototype.initVars = function (akey) { } else if (a[0][1] < b[0][1]) { return -1; } else { - return 0; + if (a[1].id > b[1].id) { + return 1; + } else if (a[1].id < b[1].id) { + return -1; + } else { + return 0; + } } } ); diff --git a/chrome/content/zotero/xpcom/sync.js b/chrome/content/zotero/xpcom/sync.js index c4e847ff5f..b9cdabafe6 100644 --- a/chrome/content/zotero/xpcom/sync.js +++ b/chrome/content/zotero/xpcom/sync.js @@ -1350,7 +1350,7 @@ Zotero.Sync.Server = new function () { _error(response.firstChild.firstChild.nodeValue); } - var xml = Zotero.Utilities.trim(xmlhttp.responseText.replace(/<\?xml.*\?>\s*/, '')); + var xml = xmlhttp.responseText.replace(/^\s*<\?xml.*\?>\s*/, '').trim(); // Strip XML declaration and convert to E4X xml = new XML(xml); diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js index 1fc8e284b8..b4c0a63498 100644 --- a/chrome/content/zotero/xpcom/translation/translate.js +++ b/chrome/content/zotero/xpcom/translation/translate.js @@ -190,7 +190,7 @@ Zotero.Translate.Sandbox = { setDefaultHandlers(translate, translation); return translation.translate(false); }; - safeTranslator.getTranslatorObject = function() { + safeTranslator.getTranslatorObject = function(callback) { translation._loadTranslator(translation.translator[0]); if(Zotero.isFx) { @@ -219,6 +219,7 @@ Zotero.Translate.Sandbox = { setDefaultHandlers(translate, translation); // return sandbox + if(callback) callback(translation._sandboxManager.sandbox); return translation._sandboxManager.sandbox; }; @@ -275,7 +276,7 @@ Zotero.Translate.Sandbox = { * @param {Zotero.Translate} translate * @param {Object} options An set of id => name pairs in object format */ - "selectItems":function(translate, options) { + "selectItems":function(translate, options, callback) { // hack to see if there are options var haveOptions = false; for(var i in options) { @@ -288,10 +289,11 @@ Zotero.Translate.Sandbox = { } if(translate._handlers.select) { - return translate._runHandler("select", options); - } else { // no handler defined; assume they want all of them - return options; + options = translate._runHandler("select", options); } + + if(callback) callback(options); + return options; }, /** diff --git a/translators/NCBI PubMed.js b/translators/NCBI PubMed.js index 4686d0e4a8..cf8d8d1df0 100644 --- a/translators/NCBI PubMed.js +++ b/translators/NCBI PubMed.js @@ -9,7 +9,7 @@ "priority":100, "configOptions":{"dataMode":"block"}, "inRepository":true, - "lastUpdated":"2011-01-27 10:15:00" + "lastUpdated":"2011-02-05 10:15:00" } function detectWeb(doc, url) { @@ -195,7 +195,9 @@ function doImportFromText(text) { newItem.tags.push(keywords[k].DescriptorName.text().toString()); } } + // We use a regex to remove the section labels newItem.abstractNote = article.Abstract.AbstractText.toString() + .replace(/<\/?AbstractText\s*(?:Label=")?([^">]+)?[^>]*>/g, "$1\n"); newItem.DOI = xml.PubmedArticle[i].PubmedData.ArticleIdList.ArticleId.(@IdType == "doi" ).text().toString(); newItem.publicationTitle = Zotero.Utilities.capitalizeTitle(newItem.publicationTitle);