www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 5cf6a1cff3cd9e1b676b50e5fb7bdfa3a4ee8bae
parent ed3bc7d1f7edd3c54289566581eca3f3b341e374
Author: Simon Kornblith <simon@simonster.com>
Date:   Fri,  8 Jul 2011 04:20:05 +0000

- Only call Zotero.wait() in translate.js if it is defined
- Don't try to use Zotero.getString() in strToDate if it is not defined
- Add getBaseIDFromTypeAndField to connector/cachedTypes.js and fix getItemTypeFields


Diffstat:
Mchrome/content/zotero/xpcom/connector/cachedTypes.js | 12+++++++++++-
Mchrome/content/zotero/xpcom/date.js | 8++++----
Mchrome/content/zotero/xpcom/translation/translate.js | 6++----
3 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/chrome/content/zotero/xpcom/connector/cachedTypes.js b/chrome/content/zotero/xpcom/connector/cachedTypes.js @@ -140,7 +140,17 @@ Zotero.ItemFields = new function() { return false; }; - this.getItemTypeFields = function(idOrName) { + this.getBaseIDFromTypeAndField = function(itemType, fieldIdOrName) { + if(!Zotero.Connector_Types["fields"][fieldIdOrName] + || !Zotero.Connector_Types["itemTypes"][itemType]) throw new Error("Invalid field or type ID"); + + fieldIdOrName = Zotero.Connector_Types["fields"][fieldIdOrName].id; + + var baseField = Zotero.Connector_Types["itemTypes"][itemType]["baseFields"][fieldIdOrName]; + return baseField ? baseField : false; + }; + + this.getItemTypeFields = function(typeIdOrName) { return Zotero.Connector_Types["itemTypes"][typeIdOrName].fields.slice(); }; } \ No newline at end of file diff --git a/chrome/content/zotero/xpcom/date.js b/chrome/content/zotero/xpcom/date.js @@ -234,13 +234,13 @@ Zotero.Date = new function(){ function strToDate(string) { // Parse 'yesterday'/'today'/'tomorrow' var lc = (string + '').toLowerCase(); - if (lc == 'yesterday' || lc == Zotero.getString('date.yesterday')) { + if (lc == 'yesterday' || (Zotero.getString && lc === Zotero.getString('date.yesterday'))) { string = Zotero.Date.dateToSQL(new Date(new Date().getTime() - 86400000)).substr(0, 10); } - else if (lc == 'today' || lc == Zotero.getString('date.today')) { + else if (lc == 'today' || (Zotero.getString && lc == Zotero.getString('date.today'))) { string = Zotero.Date.dateToSQL(new Date()).substr(0, 10); } - else if (lc == 'tomorrow' || lc == Zotero.getString('date.tomorrow')) { + else if (lc == 'tomorrow' || (Zotero.getString && lc == Zotero.getString('date.tomorrow'))) { string = Zotero.Date.dateToSQL(new Date(new Date().getTime() + 86400000)).substr(0, 10); } @@ -367,7 +367,7 @@ Zotero.Date = new function(){ if(!date.day) { // compile day regular expression if(!_dayRe) { - var daySuffixes = Zotero.getString("date.daySuffixes").replace(/, ?/g, "|"); + var daySuffixes = Zotero.getString ? Zotero.getString("date.daySuffixes").replace(/, ?/g, "|") : ""; _dayRe = new RegExp("\\b([0-9]{1,2})(?:"+daySuffixes+")?\\b(.*)", "i"); } diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js @@ -137,7 +137,7 @@ Zotero.Translate.Sandbox = { }); // Allow progress meter to update - if(!translate.noWait) Zotero.wait(); + if(!translate.noWait && Zotero.wait) Zotero.wait(); translate._runHandler("itemSaving", item); // pass both the saved item and the original JS array item @@ -590,9 +590,7 @@ Zotero.Translate.Sandbox = { translate._runHandler("itemDone", item); // Update progress bar - if(!translate.noWait) { - Zotero.wait(); - } + if(!translate.noWait && Zotero.wait) Zotero.wait(); return item; },