closes #463, ibid and repeat citation support in footnotes

attempts, but fails, to suppress an inconsequential error related to communication with Word on the Mac (perhaps on the PC, too?). i encased it in a try block, but it still throws an exception. strange.
This commit is contained in:
Simon Kornblith 2007-03-23 00:51:44 +00:00
parent 4b52c8c44d
commit c8737e946a
2 changed files with 54 additions and 19 deletions

View File

@ -416,28 +416,51 @@ Zotero.CSL.prototype.preprocessItems = function(items) {
}
}
Zotero.CSL._locatorTerms = {
p:"page",
g:"paragraph",
l:"line"
};
/*
* create a citation (in-text or footnote)
*/
Zotero.CSL.prototype.createCitation = function(citation, format) {
if(citation.citationType == 2) {
if(citation.citationType >= 3) { // indicates ibid
var string = new Zotero.CSL.FormattedString(this, format);
var term = this._getTerm("ibid");
string.append(term[0].toUpperCase()+term.substr(1));
} else {
// if type == 4, attach pages
if(citation.citationType == 4) {
// locator data
var locator = citation.locators[0];
if(locator) {
var locatorType = Zotero.CSL._locatorTerms[citation.locatorTypes[0]];
// search for elements with the same serialization
var element = this._getFieldDefaults("locator");
if(!element) {
element = {
name:"locator",
children:{name:"number"}
};
}
if(element) {
string.append("., ");
string.appendLocator(locatorType, locator, element);
}
}
}
} else { // indicates primary or subsequent
var lasti = citation.itemIDs.length-1;
for(var i in citation.itemIDs) {
var locatorType = false;
var locator = false;
if(citation.locators) {
if(citation.locatorTypes[i] == "p") {
locatorType = "page";
} else if(citation.locatorTypes[i] == "g") {
locatorType = "paragraph";
} else if(citation.locatorTypes[i] == "l") {
locatorType = "line";
}
locatorType = Zotero.CSL._locatorTerms[citation.locatorTypes[i]];
locator = citation.locators[i];
}
@ -1158,6 +1181,7 @@ Zotero.CSL.prototype._getFieldValue = function(name, element, item, formattedStr
string = item.getField("publicationTitle");
} else if(element.relation == "collection") {
string = item.getField("seriesTitle");
if(!string) string = item.getField("series");
} else if(element.relation == "event") {
string = item.getField("conferenceName");
}

View File

@ -321,11 +321,16 @@ Zotero.Integration.DataListener.prototype._requestFinished = function(response)
// write response
intlStream.writeString(response);
intlStream.close();
// write
this.oStream.write(response, response.length);
// close output stream
this.oStream.close();
// write
try {
this.oStream.write(response, response.length);
} finally {
try {
// close output stream
this.oStream.close();
} catch(e) {}
}
}
Zotero.Integration.SOAP = new function() {
@ -636,13 +641,18 @@ Zotero.Integration.CitationSet.prototype.addCitation = function(citation) {
if(this.style.ibid && citation.itemIDs.length == 1 && // if using ibid
citation.itemIDString == this.lastItemIDString) { // and is same as last
// use ibid if possible
citation.citationType = 2;
citation.serializedType = "2";
// use ibid if possible, but check whether to use ibid+pages
if(citation.locatorString == this.lastLocatorString) {
citation.citationType = 3;
citation.serializedType = "3";
} else {
citation.citationType = 4;
citation.serializedType = "4";
}
for each(itemID in citation.itemIDs) {
this.citationsByID[itemID].push(citation);
}
this.citationsByField[citation.field] = citation;
} else {
// loop through to see which are first citations
@ -653,7 +663,7 @@ Zotero.Integration.CitationSet.prototype.addCitation = function(citation) {
citation.citationType.push(1);
} else {
this.citationsByID[itemID].push(citation);
citation.citationType.push(3);
citation.citationType.push(2);
}
}
citation.serializedType = citation.citationType.join(",");
@ -667,6 +677,7 @@ Zotero.Integration.CitationSet.prototype.addCitation = function(citation) {
}
this.lastItemIDString = (citation.itemIDs.length == 1 ? citation.itemIDString : null);
this.lastLocatorString = citation.locatorString;
this.citationsByIndex[citation.index] = citation;
return isDuplicate;