diff --git a/chrome/chromeFiles/content/scholar/ingester/browser.js b/chrome/chromeFiles/content/scholar/ingester/browser.js index 92e5df7572..ee9ae66f0d 100644 --- a/chrome/chromeFiles/content/scholar/ingester/browser.js +++ b/chrome/chromeFiles/content/scholar/ingester/browser.js @@ -167,8 +167,6 @@ Scholar_Ingester_Interface.tabClose = function(event) { Scholar_Ingester_Interface.tabSelect = function(event) { var data = Scholar_Ingester_Interface._getData(Scholar_Ingester_Interface.tabBrowser.selectedBrowser); Scholar_Ingester_Interface._updateStatus(data); - // Make sure scrape progress is gone - Scholar_Ingester_Interface.Progress.kill(); } Scholar_Ingester_Interface.hidePopup = function(collectionID) { diff --git a/chrome/chromeFiles/content/scholar/xpcom/translate.js b/chrome/chromeFiles/content/scholar/xpcom/translate.js index 5ff86fef0c..df0e8ddc00 100644 --- a/chrome/chromeFiles/content/scholar/xpcom/translate.js +++ b/chrome/chromeFiles/content/scholar/xpcom/translate.js @@ -558,14 +558,13 @@ Scholar.Translate.prototype._generateSandbox = function() { this._sandbox.Scholar.nextItem = function() { return me._exportGetItem() }; this._sandbox.Scholar.nextCollection = function() { return me._exportGetCollection() } } else { - // add routines to add new items - this._sandbox.Scholar.Item = Scholar.Translate.ScholarItem; - // attach the function to be run when an item is done + // copy routines to add new items + this._sandbox.Scholar.Item = Scholar.Translate.GenerateScholarItemClass(); this._sandbox.Scholar.Item.prototype.complete = function() {me._itemDone(this)}; if(this.type == "import") { // add routines to add new collections - this._sandbox.Scholar.Collection = Scholar.Translate.ScholarCollection; + this._sandbox.Scholar.Collection = Scholar.Translate.GenerateScholarItemClass(); // attach the function to be run when a collection is done this._sandbox.Scholar.Collection.prototype.complete = function() {me._collectionDone(this)}; } @@ -882,7 +881,7 @@ Scholar.Translate.prototype._translationComplete = function(returnValue) { Scholar.Notifier.trigger("add", "item", this.newItems); } // notify collectionTreeView about updates - if(this.newCollections.length) { + if(this.newCollections && this.newCollections.length) { Scholar.Notifier.trigger("add", "collection", this.newCollections); } } @@ -1007,7 +1006,7 @@ Scholar.Translate.prototype._itemTagsAndSeeAlso = function(item, newItem) { /* * executed when an item is done and ready to be loaded into the database */ -Scholar.Translate.prototype._itemDone = function(item) { +Scholar.Translate.prototype._itemDone = function(item) { if(!this.saveItem) { // if we're not supposed to save the item, just // return the item array @@ -1056,7 +1055,7 @@ Scholar.Translate.prototype._itemDone = function(item) { item.itemType = item.complete = undefined; // automatically set access date if URL is set - if(item.url && !item.accessDate) { + if(item.url && !item.accessDate && this.type == "web") { item.accessDate = (new Date()).toLocaleString(); } @@ -1778,26 +1777,34 @@ Scholar.Translate.prototype._storageFunctions = function(read, write) { * inside scraper code */ -Scholar.Translate.ScholarItem = function(itemType) { - // assign item type - this.itemType = itemType; - // generate creators array - this.creators = new Array(); - // generate notes array - this.notes = new Array(); - // generate tags array - this.tags = new Array(); - // generate see also array - this.seeAlso = new Array(); - // generate file array - this.attachments = new Array(); +Scholar.Translate.GenerateScholarItemClass = function() { + var ScholarItem = function(itemType) { + // assign item type + this.itemType = itemType; + // generate creators array + this.creators = new Array(); + // generate notes array + this.notes = new Array(); + // generate tags array + this.tags = new Array(); + // generate see also array + this.seeAlso = new Array(); + // generate file array + this.attachments = new Array(); + }; + + return ScholarItem; } /* Scholar.Translate.Collection: a class for generating a new top-level * collection from inside scraper code */ - -Scholar.Translate.ScholarCollection = function() {} + +Scholar.Translate.GenerateScholarCollectionClass = function() { + var ScholarCollection = Scholar.Translate.ScholarCollection = function() {}; + + return ScholarCollection; +} /* Scholar.Translate.RDF: a class for handling RDF IO * diff --git a/chrome/chromeFiles/content/scholar/xpcom/utilities.js b/chrome/chromeFiles/content/scholar/xpcom/utilities.js index 32e7f6ea05..bf6cf2ad7b 100644 --- a/chrome/chromeFiles/content/scholar/xpcom/utilities.js +++ b/chrome/chromeFiles/content/scholar/xpcom/utilities.js @@ -62,7 +62,7 @@ Scholar.Utilities.prototype.cleanString = function(s) { throw "cleanString: argument must be a string"; } - s = s.replace(/[ \xA0\r\n]+/g, " "); + s = s.replace(/[\xA0\r\n\s]+/g, " "); s = s.replace(/^\s+/, ""); return s.replace(/\s+$/, ""); } @@ -236,13 +236,21 @@ Scholar.Utilities.Ingester.prototype.getItemArray = function(doc, inHere, urlRe, // Require link to match this if(urlRe) { - var urlRegexp = new RegExp(); - urlRegexp.compile(urlRe, "i"); + if(urlRe.exec) { + var urlRegexp = urlRe; + } else { + var urlRegexp = new RegExp(); + urlRegexp.compile(urlRe, "i"); + } } // Do not allow text to match this if(rejectRe) { - var rejectRegexp = new RegExp(); - rejectRegexp.compile(rejectRe, "i"); + if(rejectRe.exec) { + var rejectRegexp = rejectRe; + } else { + var rejectRegexp = new RegExp(); + rejectRegexp.compile(rejectRe, "i"); + } } if(!inHere.length) { @@ -253,7 +261,7 @@ Scholar.Utilities.Ingester.prototype.getItemArray = function(doc, inHere, urlRe, var links = inHere[j].getElementsByTagName("a"); for(var i=0; i