diff --git a/chrome/chromeFiles/content/scholar/ingester/browser.js b/chrome/chromeFiles/content/scholar/ingester/browser.js
index 8813c3582..9f28a83b2 100644
--- a/chrome/chromeFiles/content/scholar/ingester/browser.js
+++ b/chrome/chromeFiles/content/scholar/ingester/browser.js
@@ -35,7 +35,6 @@ Scholar_Ingester_Interface.init = function() {
*/
Scholar_Ingester_Interface.chromeLoad = function() {
Scholar_Ingester_Interface.tabBrowser = document.getElementById("content");
- Scholar_Ingester_Interface.hiddenBrowser = document.getElementById("scholar-hidden-browser");
Scholar_Ingester_Interface.appContent = document.getElementById("appcontent");
Scholar_Ingester_Interface.statusImage = document.getElementById("scholar-status-image");
@@ -61,21 +60,11 @@ Scholar_Ingester_Interface.chromeUnload = function() {
Scholar_Ingester_Interface.scrapeThisPage = function() {
var documentObject = Scholar_Ingester_Interface._getDocument(Scholar_Ingester_Interface.tabBrowser.selectedBrowser);
if(documentObject.scraper) {
- if(documentObject.scrapeURLList) {
- // In the case that there are multiple scrapable URLs, make the user choose
- Scholar_Ingester_Interface.chooseURL(documentObject);
- }
Scholar_Ingester_Interface.scrapeProgress = new Scholar_Ingester_Interface.Progress(window, Scholar_Ingester_Interface.tabBrowser.selectedBrowser.contentDocument, Scholar.getString("ingester.scraping"));
documentObject.scrapePage(Scholar_Ingester_Interface._finishScraping);
}
}
-Scholar_Ingester_Interface.chooseURL = function(documentObject) {
- Scholar.debug("chooseURL called");
- var newDialog = window.openDialog("chrome://scholar/content/ingester/selectitems.xul",
- "_blank","chrome,modal,centerscreen,resizable=yes", documentObject);
-}
-
/*
* Updates the status of the capture icon to reflect the scrapability or lack
* thereof of the current page
@@ -182,7 +171,7 @@ Scholar_Ingester_Interface._setDocument = function(browser) {
browser.setAttribute("scholar-key", key);
}
}
- Scholar_Ingester_Interface.browserDocuments[key] = new Scholar.Ingester.Document(browser, Scholar_Ingester_Interface.hiddenBrowser);
+ Scholar_Ingester_Interface.browserDocuments[key] = new Scholar.Ingester.Document(browser, window);
Scholar_Ingester_Interface.browserDocuments[key].retrieveScraper();
}
@@ -203,7 +192,7 @@ Scholar_Ingester_Interface._deleteDocument = function(browser) {
/*
* Callback to be executed when scraping is complete
*/
-Scholar_Ingester_Interface._finishScraping = function(obj) {
+Scholar_Ingester_Interface._finishScraping = function(obj, returnValue) {
if(obj.items.length) {
try { // Encased in a try block to fix a as-of-yet unresolved issue
var item1 = obj.items[0];
@@ -243,12 +232,14 @@ Scholar_Ingester_Interface._finishScraping = function(obj) {
for(i in obj.items) {
obj.items[i].save();
}
+ setTimeout(function() { Scholar_Ingester_Interface.scrapeProgress.fade() }, 2000);
+ } else if(returnValue) {
+ Scholar_Ingester_Interface.scrapeProgress.kill();
} else {
Scholar_Ingester_Interface.scrapeProgress.changeHeadline(Scholar.getString("ingester.scrapeError"));
Scholar_Ingester_Interface.scrapeProgress.addDescription(Scholar.getString("ingester.scrapeErrorDescription"));
+ setTimeout(function() { Scholar_Ingester_Interface.scrapeProgress.fade() }, 2000);
}
-
- setTimeout(function() { Scholar_Ingester_Interface.scrapeProgress.fade() }, 2000);
}
//////////////////////////////////////////////////////////////////////////////
@@ -333,7 +324,6 @@ Scholar_Ingester_Interface.Progress.prototype.addDescription = function(descript
this.table.appendChild(tr);
}
-
Scholar_Ingester_Interface.Progress.prototype.fade = function() {
// Icky, icky hack to keep objects
var me = this;
@@ -349,3 +339,8 @@ Scholar_Ingester_Interface.Progress.prototype.fade = function() {
// Begin fade
this._fader();
}
+
+Scholar_Ingester_Interface.Progress.prototype.kill = function() {
+ this.div.style.display = 'none';
+}
+
diff --git a/chrome/chromeFiles/content/scholar/ingester/browser.xul b/chrome/chromeFiles/content/scholar/ingester/browser.xul
index b9b230b1e..ab025cc5a 100755
--- a/chrome/chromeFiles/content/scholar/ingester/browser.xul
+++ b/chrome/chromeFiles/content/scholar/ingester/browser.xul
@@ -12,10 +12,4 @@
-
-
-
-
-
-
diff --git a/chrome/chromeFiles/content/scholar/ingester/selectitems.js b/chrome/chromeFiles/content/scholar/ingester/selectitems.js
index 4f78d6389..e09f30b3e 100644
--- a/chrome/chromeFiles/content/scholar/ingester/selectitems.js
+++ b/chrome/chromeFiles/content/scholar/ingester/selectitems.js
@@ -19,26 +19,26 @@ Scholar_Ingester_Interface_SelectItems = function() {}
* loading
*/
Scholar_Ingester_Interface_SelectItems.init = function() {
- this.documentObject = window.arguments[0];
+ this.io = window.arguments[0];
+ this.Scholar_Ingester_Interface = window.arguments[1];
this.listbox = document.getElementById("scholar-selectitems-links");
- for(i in this.documentObject.scrapeURLList) { // we could use a tree for this if we wanted to
+ for(i in this.io.dataIn) { // we could use a tree for this if we wanted to
var itemNode = document.createElement("listitem");
itemNode.setAttribute("type", "checkbox");
itemNode.setAttribute("value", i);
- itemNode.setAttribute("label", this.documentObject.scrapeURLList[i]);
+ itemNode.setAttribute("label", this.io.dataIn[i]);
itemNode.setAttribute("checked", false);
this.listbox.appendChild(itemNode);
}
}
Scholar_Ingester_Interface_SelectItems.acceptSelection = function() {
- // clear scrapeURLList
- this.documentObject.scrapeURLList = new Object();
+ this.io.dataOut = new Object();
// collect scrapeURLList from listbox
for(var i=0; i]+>/g, "");
}
+/*
+ * Allows a user to select which items to scrape
+ */
+Scholar.Ingester.Utilities.prototype.selectItems = function(itemList) {
+ // mozillazine made me do it! honest!
+ var io = { dataIn:itemList, dataOut:null }
+ var newDialog = this.window.openDialog("chrome://scholar/content/ingester/selectitems.xul",
+ "_blank","chrome,modal,centerscreen,resizable=yes", io);
+ return io.dataOut;
+}
+
+/*
+ * Grabs items based on URLs
+ */
+Scholar.Ingester.Utilities.prototype.getItemArray = function(doc, inHere, urlRe, rejectRe) {
+ var availableItems = new Object(); // Technically, associative arrays are objects
+
+ // Require link to match this
+ var tagRegexp = new RegExp();
+ tagRegexp.compile(urlRe);
+ // Do not allow text to match this
+ var rejectRegexp = new RegExp();
+ rejectRegexp.compile(rejectRe);
+
+ var links = inHere.getElementsByTagName("a");
+ for(var i=0; i