From 01970830cef02db61a80d3f40597b235743e07b3 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Mon, 1 Apr 2013 18:41:57 -0400 Subject: [PATCH] Update citeproc-js --- chrome/content/zotero/xpcom/citeproc.js | 91 ++++++++++++++----------- 1 file changed, 53 insertions(+), 38 deletions(-) diff --git a/chrome/content/zotero/xpcom/citeproc.js b/chrome/content/zotero/xpcom/citeproc.js index d3e0586d4b..ea92eeb2e8 100644 --- a/chrome/content/zotero/xpcom/citeproc.js +++ b/chrome/content/zotero/xpcom/citeproc.js @@ -3553,9 +3553,27 @@ CSL.Engine.prototype.updateItems = function (idList, nosort, rerun_ambigs) { }; CSL.Engine.prototype.updateUncitedItems = function (idList, nosort) { var debug = false; + if (!idList) { + idList = []; + } + if ("object" == typeof idList) { + if ("undefined" == typeof idList.length) { + var idHash = idList; + idList = []; + for (var key in idHash) { + idList.push(key); + } + } else if ("number" == typeof idList.length) { + var idHash = {}; + for (var i=0,ilen=idList.length;i -1; i += -1) { - if (tmphash[myitems[i]]) { - myitems = myitems.slice(0, i).concat(myitems.slice(i + 1)); - } else { - tmphash[myitems[i]] = true; - } - } - myitems.reverse(); if (uncited_flag) { - for (var i = myitems.length - 1; i > -1; i += -1) { - myitems[i] = "" + myitems[i]; - if (!this.myhash[myitems[i]] && this.mylist.indexOf(myitems[i]) === -1) { - this.mylist.push(myitems[i]); + this.uncited = {}; + for (var i=0,ilen=itemIDs.length;i-1; i += -1) { + if (myhash[itemIDs[i]]) { + itemIDs = itemIDs.slice(0, i).concat(itemIDs.slice(i + 1)); } else { - myitems = myitems.slice(0,i).concat(myitems.slice(i + 1)) + myhash[itemIDs[i]] = true; } } - this.uncited = myitems; - } else { - this.mylist = myitems.concat(this.uncited); - } - this.myhash = {}; - for (i = 0, ilen = this.mylist.length; i < ilen; i += 1) { - this.mylist[i] = "" + this.mylist[i]; - this.myhash[this.mylist[i]] = true; + this.mylist = []; + for (var i=0,ilen=itemIDs.length;i-1;i+=-1) { + if (this.citationreg.citationsByItemId) { + if (!this.citationreg.citationsByItemId[this.mylist[i]] && !myhash[this.mylist[i]]) { + delete this.myhash[this.mylist[i]]; + this.mylist = this.mylist.slice(0,i).concat(this.mylist.slice(i+1)); + } + } + } + this.dodeletes(this.myhash); +}; CSL.Registry.prototype.dodeletes = function (myhash) { var otheritems, key, ambig, pos, len, items, kkey, mypos, id; if ("string" === typeof myhash) { @@ -12609,7 +12634,7 @@ CSL.Registry.prototype.dodeletes = function (myhash) { } for (key in this.registry) { if (!myhash[key]) { - if (this.registry[key].uncited) { + if (this.uncited[key]) { continue; } otheritems = this.namereg.delitems(key); @@ -12694,16 +12719,6 @@ CSL.Registry.prototype.doinserts = function (mylist) { } } }; -CSL.Registry.prototype.douncited = function () { - var pos, len; - var cited_len = this.mylist.length - this.uncited.length; - for (pos = 0, len = cited_len; pos < len; pos += 1) { - this.registry[this.mylist[pos]].uncited = false; - } - for (pos = cited_len, len = this.mylist.length; pos < len; pos += 1) { - this.registry[this.mylist[pos]].uncited = true; - } -}; CSL.Registry.prototype.rebuildlist = function () { var count, len, pos, item; this.reflist = []; @@ -12778,7 +12793,7 @@ CSL.Registry.prototype.setsortkeys = function () { var key; for (var i = 0, ilen = this.mylist.length; i < ilen; i += 1) { var key = this.mylist[i]; - if (this.touched[key] || this.state.tmp.taintedItemIDs[key]) { + if (this.touched[key] || this.state.tmp.taintedItemIDs[key] || !this.registry[key].sortkeys) { this.registry[key].sortkeys = CSL.getSortKeys.call(this.state, this.state.retrieveItem(key), "bibliography_sort"); } }