From 64f810dd5a00e327ccca60ed8f3bb7dc9fdb74ec Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Mon, 16 Aug 2010 08:46:07 +0000 Subject: [PATCH] fix issues inserting new citations with locators with accented characters (citations will still need to be reinserted) --- .../zotero/integration/addCitationDialog.js | 11 +++-- chrome/content/zotero/xpcom/integration.js | 41 +++++-------------- 2 files changed, 18 insertions(+), 34 deletions(-) diff --git a/chrome/content/zotero/integration/addCitationDialog.js b/chrome/content/zotero/integration/addCitationDialog.js index 8af44386e3..d0884eac67 100644 --- a/chrome/content/zotero/integration/addCitationDialog.js +++ b/chrome/content/zotero/integration/addCitationDialog.js @@ -125,7 +125,8 @@ var Zotero_Citation_Dialog = new function () { _suppressNextTreeSelect = true; // switch to library if item doesn't exist in current selection - if(collectionsView.getSelectedCollection() && !collectionsView.getSelectedCollection().hasItem(io.citation.citationItems[0].id)) { + var collection = collectionsView.getSelectedCollection(); + if(collection && !collection.hasItem(io.citation.citationItems[0].id)) { var item = Zotero.Items.get(io.citation.citationItems[0].id); collectionsView.selectLibrary(item.libraryID); } @@ -709,12 +710,14 @@ var Zotero_Citation_Dialog = new function () { if(box == "label") { citationItem[box] = _locatorNameArray[document.getElementById(box).selectedIndex]; } else { - citationItem[box] = document.getElementById(box)[property]; + var prop = document.getElementById(box)[property]; + if(prop !== "" && prop !== false) citationItem[box] = prop; } } - if(citationItem["locator"] == "") { - citationItem["locator"] = citationItem["label"] = undefined; + if(!citationItem["locator"]) { + delete citationItem["locator"]; + delete citationItem["label"]; } io.citation.citationItems = [citationItem]; diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js index c75fcc0ae1..f00b52bfd1 100644 --- a/chrome/content/zotero/xpcom/integration.js +++ b/chrome/content/zotero/xpcom/integration.js @@ -1048,45 +1048,26 @@ Zotero.Integration.Session.prototype.reselectItem = function(exception) { /** * Generates a field from a citation object */ -Zotero.Integration.Session._acceptableTypes = ["string", "boolean", "number"]; -Zotero.Integration.Session._saveProperties = ["custom", "unsorted"]; -Zotero.Integration.Session._saveItems = ["locator", "label", "suppress-author", "author-only", "prefix", "suffix"]; Zotero.Integration.Session.prototype.getCitationField = function(citation) { + const saveProperties = ["custom", "unsorted"]; + const saveCitationItems = ["locator", "label", "suppress-author", "author-only", "prefix", "suffix", "uri"]; + var type; var field = []; field.push('"citationID":'+uneval(citation.citationID)); - var properties = []; - for(var j=0; j