- fix compatibility with older documents
- add upgrade warning
This commit is contained in:
parent
cf5eb92799
commit
5b3c1b7bb2
2 changed files with 28 additions and 16 deletions
|
@ -130,10 +130,12 @@ Zotero.Integration = new function() {
|
||||||
try {
|
try {
|
||||||
integration[command]();
|
integration[command]();
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
integration._doc.displayAlert(Zotero.getString("integration.error.generic"),
|
if(!(e instanceof Zotero.Integration.UserCancelledException)) {
|
||||||
Components.interfaces.zoteroIntegrationDocument.DIALOG_ICON_STOP,
|
integration._doc.displayAlert(Zotero.getString("integration.error.generic"),
|
||||||
Components.interfaces.zoteroIntegrationDocument.DIALOG_BUTTONS_OK);
|
Components.interfaces.zoteroIntegrationDocument.DIALOG_ICON_STOP,
|
||||||
throw e;
|
Components.interfaces.zoteroIntegrationDocument.DIALOG_BUTTONS_OK);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
integration.cleanup();
|
integration.cleanup();
|
||||||
}
|
}
|
||||||
|
@ -191,17 +193,20 @@ Zotero.Integration.MissingItemException = function(reselectKeys, reselectKeyType
|
||||||
}
|
}
|
||||||
Zotero.Integration.MissingItemException.prototype.name = "MissingItemException";
|
Zotero.Integration.MissingItemException.prototype.name = "MissingItemException";
|
||||||
Zotero.Integration.MissingItemException.prototype.message = "An item in this document is missing from your Zotero library.";
|
Zotero.Integration.MissingItemException.prototype.message = "An item in this document is missing from your Zotero library.";
|
||||||
Zotero.Integration.MissingItemException.prototype.toString = function() {
|
Zotero.Integration.MissingItemException.prototype.toString = function() { return this.name; };
|
||||||
return this.name;
|
|
||||||
}
|
Zotero.Integration.UserCancelledException = function() {};
|
||||||
|
Zotero.Integration.UserCancelledException.prototype.name = "UserCancelledException";
|
||||||
|
Zotero.Integration.UserCancelledException.prototype.message = "User cancelled document update.";
|
||||||
|
Zotero.Integration.UserCancelledException.prototype.toString = function() { return this.name; };
|
||||||
|
|
||||||
|
|
||||||
// Field code for an item
|
// Field code for an item
|
||||||
const ITEM_CODE = "ITEM"
|
const ITEM_CODE = "ITEM";
|
||||||
// Field code for a bibliography
|
// Field code for a bibliography
|
||||||
const BIBLIOGRAPHY_CODE = "BIBL"
|
const BIBLIOGRAPHY_CODE = "BIBL";
|
||||||
// Placeholder for an empty bibliography
|
// Placeholder for an empty bibliography
|
||||||
const BIBLIOGRAPHY_PLACEHOLDER = "{Bibliography}"
|
const BIBLIOGRAPHY_PLACEHOLDER = "{Bibliography}";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -231,7 +236,6 @@ Zotero.Integration.Document.prototype._createNewSession = function(data) {
|
||||||
*/
|
*/
|
||||||
Zotero.Integration.Document.prototype._getSession = function(require, dontRunSetDocPrefs) {
|
Zotero.Integration.Document.prototype._getSession = function(require, dontRunSetDocPrefs) {
|
||||||
var dataString = this._doc.getDocumentData();
|
var dataString = this._doc.getDocumentData();
|
||||||
Zotero.debug(dataString);
|
|
||||||
if(!dataString) {
|
if(!dataString) {
|
||||||
if(require) {
|
if(require) {
|
||||||
this._doc.displayAlert(Zotero.getString("integration.error.mustInsertCitation"),
|
this._doc.displayAlert(Zotero.getString("integration.error.mustInsertCitation"),
|
||||||
|
@ -248,6 +252,13 @@ Zotero.Integration.Document.prototype._getSession = function(require, dontRunSet
|
||||||
this._doc.setDocumentData(this._session.data.serializeXML());
|
this._doc.setDocumentData(this._session.data.serializeXML());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if(dataString[0] != "<") {
|
||||||
|
var warning = this._doc.displayAlert(Zotero.getString("integration.upgradeWarning"),
|
||||||
|
Components.interfaces.zoteroIntegrationDocument.DIALOG_ICON_WARNING,
|
||||||
|
Components.interfaces.zoteroIntegrationDocument.DIALOG_BUTTONS_OK_CANCEL);
|
||||||
|
if(!warning) throw new Zotero.Integration.UserCancelledException();
|
||||||
|
}
|
||||||
|
|
||||||
var data = new Zotero.Integration.DocumentData(dataString);
|
var data = new Zotero.Integration.DocumentData(dataString);
|
||||||
if(Zotero.Integration.sessions[data.sessionID]) {
|
if(Zotero.Integration.sessions[data.sessionID]) {
|
||||||
this._session = Zotero.Integration.sessions[data.sessionID];
|
this._session = Zotero.Integration.sessions[data.sessionID];
|
||||||
|
@ -365,7 +376,7 @@ Zotero.Integration.Document.prototype._updateSession = function(editField) {
|
||||||
field.select();
|
field.select();
|
||||||
var result = this._doc.displayAlert(msg, 1, 3);
|
var result = this._doc.displayAlert(msg, 1, 3);
|
||||||
if(result == 0) { // Cancel
|
if(result == 0) { // Cancel
|
||||||
throw "Integration update canceled by user";
|
throw new Zotero.Integration.UserCancelledException();
|
||||||
} else if(result == 1) { // No
|
} else if(result == 1) { // No
|
||||||
for each(var reselectKey in e.reselectKeys) {
|
for each(var reselectKey in e.reselectKeys) {
|
||||||
deleteKeys[reselectKey] = true;
|
deleteKeys[reselectKey] = true;
|
||||||
|
@ -1535,14 +1546,14 @@ Zotero.Integration.DocumentData.prototype.unserializeXML = function(xmlData) {
|
||||||
* Unserializes document-specific data, either as XML or as the string form used previously
|
* Unserializes document-specific data, either as XML or as the string form used previously
|
||||||
*/
|
*/
|
||||||
Zotero.Integration.DocumentData.prototype.unserialize = function(input) {
|
Zotero.Integration.DocumentData.prototype.unserialize = function(input) {
|
||||||
if(input[0] == "<" || input[1] == "<") {
|
if(input[0] == "<") {
|
||||||
this.unserializeXML(input);
|
this.unserializeXML(input);
|
||||||
} else {
|
} else {
|
||||||
const splitRe = /(^|[^\:])\:([^\:]|$)/;
|
const splitRe = /(^|[^\:])\:([^\:]|$)/;
|
||||||
|
|
||||||
var prefParameters = [];
|
var splitOutput = input.split(splitRe);
|
||||||
var splitOutput = splitRe.split(input);
|
var prefParameters = [splitOutput[0]+splitOutput[1]];
|
||||||
for(var i=0; i<splitOutput.length; i+=3) {
|
for(var i=2; i<splitOutput.length; i+=3) {
|
||||||
prefParameters.push((splitOutput[i]+splitOutput[i+1]+splitOutput[i+2]).replace("::", ":", "g"));
|
prefParameters.push((splitOutput[i]+splitOutput[i+1]+splitOutput[i+2]).replace("::", ":", "g"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -519,6 +519,7 @@ integration.missingItem.single = This item no longer exists in your Zotero dat
|
||||||
integration.missingItem.multiple = Item %1$S in this citation no longer exists in your Zotero database. Do you want to select a substitute item?
|
integration.missingItem.multiple = Item %1$S in this citation no longer exists in your Zotero database. Do you want to select a substitute item?
|
||||||
integration.missingItem.description = Clicking "No" will delete the field codes for citations containing this item, preserving the citation text but deleting it from your bibliography.
|
integration.missingItem.description = Clicking "No" will delete the field codes for citations containing this item, preserving the citation text but deleting it from your bibliography.
|
||||||
integration.removeCodesWarning = Removing field codes will prevent Zotero from updating citations and bibliographies in this document. Are you sure you want to continue?
|
integration.removeCodesWarning = Removing field codes will prevent Zotero from updating citations and bibliographies in this document. Are you sure you want to continue?
|
||||||
|
integration.upgradeWarning = Your document must be permanently upgraded in order to work with Zotero 2.0b7 or later. It is recommended that you make a backup before proceeding. Are you sure you want to continue?
|
||||||
|
|
||||||
styles.installStyle = Install style "%1$S" from %2$S?
|
styles.installStyle = Install style "%1$S" from %2$S?
|
||||||
styles.updateStyle = Update existing style "%1$S" with "%2$S" from %3$S?
|
styles.updateStyle = Update existing style "%1$S" with "%2$S" from %3$S?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue