really fix dates this time

This commit is contained in:
Simon Kornblith 2006-12-20 06:14:57 +00:00
parent b79e798ef4
commit e5575d0643

View File

@ -371,39 +371,44 @@ Zotero.CSL.prototype.preprocessItems = function(items) {
if(lastAuthor == author) { if(lastAuthor == author) {
item._csl.subsequentAuthorSubstitute = true; item._csl.subsequentAuthorSubstitute = true;
} }
lastAuthor = author;
// handle (2006a) disambiguation for author-date styles // handle (2006a) disambiguation for author-date styles
if(this.class == "author-date") { if(this.class == "author-date") {
var year = item._csl.date.year; var year = item._csl.date.year;
if(usedCitations[year]) { if(lastAuthor == author) {
if(!usedCitations[year]._csl.date.disambiguation) { if(usedCitations[year]) {
usedCitations[year]._csl.date.disambiguation = "a"; if(!usedCitations[year]._csl.date.disambiguation) {
item._csl.date.disambiguation = "b"; usedCitations[year]._csl.date.disambiguation = "a";
} else { item._csl.date.disambiguation = "b";
// get all but last character
var oldLetter = usedCitations[year]._csl.date.disambiguation;
if(oldLetter.length > 1) {
item._csl.date.disambiguation = oldLetter.substr(0, oldLetter.length-1);
} else { } else {
item._csl.date.disambiguation = ""; // get all but last character
} var oldLetter = usedCitations[year]._csl.date.disambiguation;
if(oldLetter.length > 1) {
item._csl.date.disambiguation = oldLetter.substr(0, oldLetter.length-1);
} else {
item._csl.date.disambiguation = "";
}
var charCode = oldLetter.charCodeAt(oldLetter.length-1); var charCode = oldLetter.charCodeAt(oldLetter.length-1);
if(charCode == 122) { if(charCode == 122) {
// item is z; add another letter // item is z; add another letter
item._csl.date.disambiguation += "za"; item._csl.date.disambiguation += "za";
} else { } else {
// next lowercase letter // next lowercase letter
item._csl.date.disambiguation += String.fromCharCode(charCode+1); item._csl.date.disambiguation += String.fromCharCode(charCode+1);
}
} }
} }
} else {
usedCitations = new Array();
} }
usedCitations[year] = item; usedCitations[year] = item;
} }
lastAuthor = author;
// add numbers to each // add numbers to each
item._csl.number = i; item._csl.number = i;
} }