www

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

commit d5bc6cbe4b676d2de248e0d183d3e4374748b33d
parent 14c5c40a504e9dda1bf9964eba20b9a83c41fb9f
Author: Simon Kornblith <simon@simonster.com>
Date:   Sat,  9 Sep 2006 22:45:03 +0000

- fixes a bug in capitalizeTitle
- better feedback for search translator errors


Diffstat:
Mchrome/chromeFiles/content/scholar/xpcom/translate.js | 41++++++++++++++++++++++++-----------------
Mchrome/chromeFiles/content/scholar/xpcom/utilities.js | 7+++++--
Mscrapers.sql | 6+-----
3 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/chrome/chromeFiles/content/scholar/xpcom/translate.js b/chrome/chromeFiles/content/scholar/xpcom/translate.js @@ -876,6 +876,8 @@ Scholar.Translate.prototype._translationComplete = function(returnValue, error) if(this.type == "search" && !this._itemsFound && this.translator.length > 1) { // if we're performing a search and didn't get any results, go on // to the next translator + Scholar.debug("could not find a result using "+this.translator[0].label+": \n" + +this._generateErrorString(error)); this.translator.shift(); this.translate(); } else { @@ -897,23 +899,7 @@ Scholar.Translate.prototype._translationComplete = function(returnValue, error) this._runHandler("done", returnValue); if(!returnValue) { - var errorString = ""; - if(typeof(error) == "string") { - errorString = "\nthrown exception => "+error; - } else { - for(var i in error) { - if(typeof(error[i]) != "object") { - errorString += "\n"+i+' => '+error[i]; - } - } - } - - errorString += "\nurl => "+this.path - + "\nextensions.zotero.cacheTranslatorData => "+Scholar.Prefs.get("cacheTranslatorData") - + "\nextensions.zotero.downloadAssociatedFiles => "+Scholar.Prefs.get("downloadAssociatedFiles"); - - errorString = errorString.substr(1); - + var errorString = this._generateErrorString(error); Scholar.debug("translation using "+this.translator[0].label+" failed: \n"+errorString); if(this.type == "web") { @@ -928,6 +914,27 @@ Scholar.Translate.prototype._translationComplete = function(returnValue, error) } /* + * generates a useful error string, for submitting and debugging purposes + */ +Scholar.Translate.prototype._generateErrorString = function(error) { + var errorString = ""; + if(typeof(error) == "string") { + errorString = "\nthrown exception => "+error; + } else { + for(var i in error) { + if(typeof(error[i]) != "object") { + errorString += "\n"+i+' => '+error[i]; + } + } + } + + errorString += "\nurl => "+this.path + + "\nextensions.zotero.cacheTranslatorData => "+Scholar.Prefs.get("cacheTranslatorData") + + "\nextensions.zotero.downloadAssociatedFiles => "+Scholar.Prefs.get("downloadAssociatedFiles"); + return errorString.substr(1); +} + +/* * runs an HTTP request to report a translation error */ Scholar.Translate.prototype._reportTranslationFailure = function(errorData) { diff --git a/chrome/chromeFiles/content/scholar/xpcom/utilities.js b/chrome/chromeFiles/content/scholar/xpcom/utilities.js @@ -158,6 +158,7 @@ Scholar.Utilities.capitalizeSkipWords = ["but", "or", "yet", "so", "for", "and", "nor", "a", "an", "the", "at", "by", "from", "in", "into", "of", "on", "to", "with", "up", "down"]; Scholar.Utilities.prototype.capitalizeTitle = function(title) { + title = this.cleanString(title); title = title.replace(/ : /g, ": "); var words = title.split(" "); @@ -172,7 +173,7 @@ Scholar.Utilities.prototype.capitalizeTitle = function(title) { for(var i=1; i<lastWordIndex; i++) { // if not a skip word if(Scholar.Utilities.capitalizeSkipWords.indexOf(words[i].toLowerCase()) == -1 || - words[i-1][words[i-1].length-1] == ":") { + (words[i-1].length && words[i-1][words[i-1].length-1] == ":")) { words[i] = words[i][0].toUpperCase() + words[i].substr(1); } else { words[i] = words[i].toLowerCase(); @@ -560,7 +561,9 @@ Scholar.Utilities.HTTP.processDocuments = function(firstDoc, urls, processor, do } } else { removeListeners(); - done(); + if(done) { + done(); + } } }; var onLoad = function() { diff --git a/scrapers.sql b/scrapers.sql @@ -4094,9 +4094,7 @@ function processOWC(doc) { var spanTitle = spanTags[i].getAttribute("title"); var item = new Scholar.Item(); if(Scholar.Utilities.parseContextObject(spanTitle, item)) { - if(item.title) { - item.title = Scholar.Utilities.capitalizeTitle(item.title); - } + item.title = Scholar.Utilities.capitalizeTitle(item.title); item.complete(); return true; } else { @@ -4146,8 +4144,6 @@ function doSearch(item) { processOWC(doc); }, function() { // done Scholar.done(); - }, function() { // error - Scholar.done(false); }); } }, null);