- Eliminate some error messages in translate.js
- Zotero.ItemFields.isValidForType() should not throw on error
This commit is contained in:
parent
ca8c7ba584
commit
f5af708995
2 changed files with 8 additions and 3 deletions
|
@ -115,7 +115,7 @@ Zotero.ItemFields = new function() {
|
|||
this.isValidForType = function(fieldIdOrName, typeIdOrName) {
|
||||
// mimics itemFields.js
|
||||
if(!Zotero.Connector_Types["fields"][fieldIdOrName]
|
||||
|| !Zotero.Connector_Types["itemTypes"][typeIdOrName]) throw "Invalid field or type ID";
|
||||
|| !Zotero.Connector_Types["itemTypes"][typeIdOrName]) return false;
|
||||
|
||||
return Zotero.Connector_Types["itemTypes"][typeIdOrName].fields.indexOf(
|
||||
Zotero.Connector_Types["fields"][fieldIdOrName].id) !== -1;
|
||||
|
@ -123,7 +123,7 @@ Zotero.ItemFields = new function() {
|
|||
|
||||
this.getFieldIDFromTypeAndBase = function(itemType, baseField) {
|
||||
if(!Zotero.Connector_Types["fields"][baseField]
|
||||
|| !Zotero.Connector_Types["itemTypes"][itemType]) throw "Invalid field or type ID";
|
||||
|| !Zotero.Connector_Types["itemTypes"][itemType]) throw new Error("Invalid field or type ID");
|
||||
|
||||
// get as ID
|
||||
baseField = Zotero.Connector_Types["fields"][baseField].id;
|
||||
|
|
|
@ -465,6 +465,7 @@ Zotero.Translate.Sandbox = {
|
|||
}
|
||||
|
||||
// create short title
|
||||
Zotero.debug("item type is "+item.itemType);
|
||||
if(item.shortTitle === undefined && Zotero.Utilities.fieldIsValidForType("shortTitle", item.itemType)) {
|
||||
// only set if changes have been made
|
||||
var setShortTitle = false;
|
||||
|
@ -793,7 +794,7 @@ Zotero.Translate.Base.prototype = {
|
|||
*/
|
||||
"getTranslators":function(getAllTranslators) {
|
||||
// do not allow simultaneous instances of getTranslators
|
||||
if(this._currentState == "detect") throw new Error("getTranslators: detection is already running");
|
||||
if(this._currentState === "detect") throw new Error("getTranslators: detection is already running");
|
||||
this._currentState = "detect";
|
||||
this._getAllTranslators = getAllTranslators;
|
||||
this._getTranslatorsGetPotentialTranslators();
|
||||
|
@ -1426,6 +1427,8 @@ Zotero.Translate.Import.prototype._getTranslatorsGetPotentialTranslators = funct
|
|||
*/
|
||||
Zotero.Translate.Import.prototype.getTranslators = function() {
|
||||
if(!this._string && !this.location) {
|
||||
if(this._currentState === "detect") throw new Error("getTranslators: detection is already running");
|
||||
this._currentState = "detect";
|
||||
this._foundTranslators = Zotero.Translators.getAllForType(this.type);
|
||||
this._potentialTranslators = [];
|
||||
this.complete(true);
|
||||
|
@ -1562,6 +1565,8 @@ Zotero.Translate.Export.prototype.complete = Zotero.Translate.Import.prototype.c
|
|||
* Overload {@link Zotero.Translate.Base#getTranslators} to return all translators immediately
|
||||
*/
|
||||
Zotero.Translate.Export.prototype.getTranslators = function() {
|
||||
if(this._currentState === "detect") throw new Error("getTranslators: detection is already running");
|
||||
this._currentState = "detect";
|
||||
this._foundTranslators = Zotero.Translators.getAllForType(this.type);
|
||||
this._potentialTranslators = [];
|
||||
this.complete(true);
|
||||
|
|
Loading…
Add table
Reference in a new issue