2006-06-24 09:08:12 +00:00
|
|
|
// Scholar for Firefox Ingester Browser Functions
|
2006-06-02 18:22:34 +00:00
|
|
|
// Based on code taken from Greasemonkey and PiggyBank
|
2006-06-01 06:53:39 +00:00
|
|
|
// This code is licensed according to the GPL
|
|
|
|
|
2006-06-02 18:22:34 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2006-06-20 00:52:15 +00:00
|
|
|
// Scholar_Ingester_Interface
|
2006-06-02 18:22:34 +00:00
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Class to interface with the browser when ingesting data
|
|
|
|
|
2006-06-20 00:52:15 +00:00
|
|
|
Scholar_Ingester_Interface = function() {}
|
2006-06-29 03:22:10 +00:00
|
|
|
Scholar_Ingester_Interface._scrapeProgress = new Array();
|
2006-06-01 06:53:39 +00:00
|
|
|
|
2006-06-02 18:22:34 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2006-06-20 00:52:15 +00:00
|
|
|
// Public Scholar_Ingester_Interface methods
|
2006-06-02 18:22:34 +00:00
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2006-06-02 03:19:12 +00:00
|
|
|
/*
|
|
|
|
* Initialize some variables and prepare event listeners for when chrome is done
|
|
|
|
* loading
|
|
|
|
*/
|
2006-06-20 00:52:15 +00:00
|
|
|
Scholar_Ingester_Interface.init = function() {
|
|
|
|
Scholar_Ingester_Interface.browsers = new Array();
|
|
|
|
Scholar_Ingester_Interface.browserDocuments = new Object();
|
2006-06-24 21:39:36 +00:00
|
|
|
Scholar_Ingester_Interface.browserUris = new Array();
|
2006-06-29 00:56:50 +00:00
|
|
|
Scholar_Ingester_Interface._scrapePopupShowing = false;
|
2006-06-27 04:08:21 +00:00
|
|
|
Scholar.Ingester.ProxyMonitor.init();
|
2006-06-01 06:53:39 +00:00
|
|
|
|
2006-06-25 04:30:43 +00:00
|
|
|
window.addEventListener("load", Scholar_Ingester_Interface.chromeLoad, false);
|
|
|
|
window.addEventListener("unload", Scholar_Ingester_Interface.chromeUnload, false);
|
2006-06-01 06:53:39 +00:00
|
|
|
}
|
|
|
|
|
2006-06-02 03:19:12 +00:00
|
|
|
/*
|
|
|
|
* When chrome loads, register our event handlers with the appropriate interfaces
|
|
|
|
*/
|
2006-06-20 00:52:15 +00:00
|
|
|
Scholar_Ingester_Interface.chromeLoad = function() {
|
|
|
|
Scholar_Ingester_Interface.tabBrowser = document.getElementById("content");
|
|
|
|
Scholar_Ingester_Interface.appContent = document.getElementById("appcontent");
|
|
|
|
Scholar_Ingester_Interface.statusImage = document.getElementById("scholar-status-image");
|
2006-06-01 06:53:39 +00:00
|
|
|
|
2006-06-25 04:30:43 +00:00
|
|
|
// this gives us onLocationChange, for updating when tabs are switched/created
|
2006-06-20 00:52:15 +00:00
|
|
|
Scholar_Ingester_Interface.tabBrowser.addProgressListener(Scholar_Ingester_Interface.Listener,
|
2006-06-01 06:53:39 +00:00
|
|
|
Components.interfaces.nsIWebProgress.NOTIFY_LOCATION);
|
2006-06-25 04:30:43 +00:00
|
|
|
// this is for pageshow, for updating the status of the book icon
|
|
|
|
Scholar_Ingester_Interface.appContent.addEventListener("pageshow",
|
|
|
|
Scholar_Ingester_Interface.contentLoad, true);
|
2006-06-01 06:53:39 +00:00
|
|
|
}
|
|
|
|
|
2006-06-02 03:19:12 +00:00
|
|
|
/*
|
|
|
|
* When chrome unloads, delete our document objects and remove our listeners
|
|
|
|
*/
|
2006-06-20 00:52:15 +00:00
|
|
|
Scholar_Ingester_Interface.chromeUnload = function() {
|
|
|
|
delete Scholar_Ingester_Interface.browserDocuments;
|
2006-06-02 03:19:12 +00:00
|
|
|
this.tabBrowser.removeProgressListener(this);
|
2006-06-01 06:53:39 +00:00
|
|
|
}
|
|
|
|
|
2006-06-02 03:19:12 +00:00
|
|
|
/*
|
|
|
|
* Scrapes a page (called when the capture icon is clicked)
|
|
|
|
*/
|
2006-06-27 21:02:26 +00:00
|
|
|
Scholar_Ingester_Interface.scrapeThisPage = function(saveLocation) {
|
2006-06-20 00:52:15 +00:00
|
|
|
var documentObject = Scholar_Ingester_Interface._getDocument(Scholar_Ingester_Interface.tabBrowser.selectedBrowser);
|
2006-06-02 18:22:34 +00:00
|
|
|
if(documentObject.scraper) {
|
2006-06-27 21:02:26 +00:00
|
|
|
var scrapeProgress = new Scholar_Ingester_Interface.Progress(window);
|
2006-06-29 03:22:10 +00:00
|
|
|
Scholar_Ingester_Interface._scrapeProgress.push(scrapeProgress);
|
2006-06-27 21:02:26 +00:00
|
|
|
documentObject.scrapePage(function(obj, returnValue) { Scholar_Ingester_Interface._finishScraping(obj, returnValue, scrapeProgress, saveLocation) });
|
2006-06-01 06:53:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-02 03:19:12 +00:00
|
|
|
/*
|
|
|
|
* Updates the status of the capture icon to reflect the scrapability or lack
|
|
|
|
* thereof of the current page
|
|
|
|
*/
|
2006-06-24 21:39:36 +00:00
|
|
|
Scholar_Ingester_Interface.updateStatus = function() {
|
|
|
|
var documentObject = Scholar_Ingester_Interface._getDocument(Scholar_Ingester_Interface.tabBrowser.selectedBrowser);
|
2006-06-02 18:22:34 +00:00
|
|
|
if(documentObject && documentObject.scraper) {
|
2006-06-26 18:05:23 +00:00
|
|
|
if(documentObject.type == "multiple") {
|
|
|
|
// Use folder icon for multiple types, for now
|
|
|
|
Scholar_Ingester_Interface.statusImage.src = "chrome://scholar/skin/treesource-collection.png";
|
|
|
|
} else {
|
|
|
|
Scholar_Ingester_Interface.statusImage.src = "chrome://scholar/skin/treeitem-"+documentObject.type+".png";
|
|
|
|
}
|
2006-06-22 00:13:21 +00:00
|
|
|
Scholar_Ingester_Interface.statusImage.hidden = false;
|
2006-06-01 06:53:39 +00:00
|
|
|
} else {
|
2006-06-22 00:13:21 +00:00
|
|
|
Scholar_Ingester_Interface.statusImage.hidden = true;
|
2006-06-01 06:53:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-02 03:19:12 +00:00
|
|
|
/*
|
|
|
|
* An event handler called when a new document is loaded. Creates a new document
|
|
|
|
* object, and updates the status of the capture icon
|
2006-06-24 21:39:36 +00:00
|
|
|
|
2006-06-02 03:19:12 +00:00
|
|
|
*/
|
2006-06-24 21:39:36 +00:00
|
|
|
Scholar_Ingester_Interface.contentLoad = function(event) {
|
|
|
|
if (event.originalTarget instanceof HTMLDocument) {
|
|
|
|
// Stolen off the Mozilla extension developer's website, a routine to
|
|
|
|
// determine the root document loaded from a frameset
|
|
|
|
if (event.originalTarget.defaultView.frameElement) {
|
|
|
|
var doc = event.originalTarget;
|
|
|
|
while (doc.defaultView.frameElement) {
|
|
|
|
doc=doc.defaultView.frameElement.ownerDocument;
|
|
|
|
}
|
|
|
|
// Frame within a tab was loaded. doc is the root document of the frameset
|
|
|
|
} else {
|
|
|
|
var doc = event.originalTarget;
|
|
|
|
// Page was loaded. doc is the document that loaded.
|
|
|
|
}
|
|
|
|
|
|
|
|
// Figure out what browser this contentDocument is associated with
|
|
|
|
var browser;
|
|
|
|
for(var i=0; i<Scholar_Ingester_Interface.tabBrowser.browsers.length; i++) {
|
|
|
|
if(doc == Scholar_Ingester_Interface.tabBrowser.browsers[i].contentDocument) {
|
|
|
|
browser = Scholar_Ingester_Interface.tabBrowser.browsers[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!browser) {
|
|
|
|
Scholar.debug("Could not find browser!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Scholar_Ingester_Interface._setDocument(browser);
|
|
|
|
Scholar_Ingester_Interface.updateStatus();
|
|
|
|
}
|
2006-06-01 06:53:39 +00:00
|
|
|
}
|
|
|
|
|
2006-06-02 03:19:12 +00:00
|
|
|
/*
|
|
|
|
* Dummy event handlers for all the events we don't care about
|
|
|
|
*/
|
2006-06-20 00:52:15 +00:00
|
|
|
Scholar_Ingester_Interface.Listener = function() {}
|
|
|
|
Scholar_Ingester_Interface.Listener.onStatusChange = function() {}
|
|
|
|
Scholar_Ingester_Interface.Listener.onSecurityChange = function() {}
|
|
|
|
Scholar_Ingester_Interface.Listener.onProgressChange = function() {}
|
|
|
|
Scholar_Ingester_Interface.Listener.onStateChange = function() {}
|
2006-06-02 03:19:12 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* onLocationChange is called when tabs are switched. Use it to retrieve the
|
|
|
|
* appropriate status indicator for the current tab, and to free useless objects
|
|
|
|
*/
|
2006-06-20 00:52:15 +00:00
|
|
|
Scholar_Ingester_Interface.Listener.onLocationChange = function(progressObject) {
|
2006-06-25 04:30:43 +00:00
|
|
|
var browsers = Scholar_Ingester_Interface.tabBrowser.browsers;
|
2006-06-01 06:53:39 +00:00
|
|
|
|
2006-06-25 04:30:43 +00:00
|
|
|
// Remove document object of any browser that no longer exists
|
|
|
|
for (var i = 0; i < Scholar_Ingester_Interface.browsers.length; i++) {
|
|
|
|
var browser = Scholar_Ingester_Interface.browsers[i];
|
|
|
|
var exists = false;
|
2006-06-01 06:53:39 +00:00
|
|
|
|
2006-06-25 04:30:43 +00:00
|
|
|
for (var j = 0; j < browsers.length; j++) {
|
|
|
|
if (browser == browsers[j]) {
|
|
|
|
exists = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-06-01 06:53:39 +00:00
|
|
|
|
2006-06-25 04:30:43 +00:00
|
|
|
if (!exists) {
|
|
|
|
Scholar_Ingester_Interface.browsers.splice(i,1);
|
2006-06-01 06:53:39 +00:00
|
|
|
|
2006-06-25 04:30:43 +00:00
|
|
|
// To execute if document object does not exist
|
|
|
|
Scholar_Ingester_Interface._deleteDocument(browser);
|
|
|
|
}
|
|
|
|
}
|
2006-06-27 02:03:10 +00:00
|
|
|
Scholar_Ingester_Interface.updateStatus();
|
|
|
|
|
|
|
|
// Make sure scrape progress is gone
|
2006-06-29 03:22:10 +00:00
|
|
|
var scrapeProgress;
|
|
|
|
while(scrapeProgress = Scholar_Ingester_Interface._scrapeProgress.pop()) {
|
|
|
|
scrapeProgress.kill();
|
2006-06-27 02:03:10 +00:00
|
|
|
}
|
2006-06-02 18:22:34 +00:00
|
|
|
}
|
|
|
|
|
2006-06-27 21:02:26 +00:00
|
|
|
Scholar_Ingester_Interface.hidePopup = function(collectionID) {
|
|
|
|
Scholar_Ingester_Interface._scrapePopupShowing = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Scholar_Ingester_Interface.showPopup = function(collectionID, parentElement) {
|
|
|
|
if(Scholar_Ingester_Interface._scrapePopupShowing && parentElement.hasChildNodes()) {
|
|
|
|
return false; // Don't dynamically reload popups that are already showing
|
|
|
|
}
|
|
|
|
Scholar_Ingester_Interface._scrapePopupShowing = true;
|
|
|
|
|
|
|
|
while(parentElement.hasChildNodes()) {
|
|
|
|
parentElement.removeChild(parentElement.firstChild);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(collectionID == null) { // show library
|
|
|
|
var newItem = document.createElement("menuitem");
|
|
|
|
newItem.setAttribute("label", Scholar.getString("pane.collections.library"));
|
|
|
|
newItem.setAttribute("class", "menuitem-iconic scholar-scrape-popup-library");
|
|
|
|
newItem.setAttribute("oncommand", 'Scholar_Ingester_Interface.scrapeThisPage()');
|
|
|
|
parentElement.appendChild(newItem);
|
|
|
|
}
|
|
|
|
|
|
|
|
var childrenList = Scholar.getCollections(collectionID);
|
|
|
|
for(var i = 0; i < childrenList.length; i++) {
|
|
|
|
if(childrenList[i].hasChildCollections()) {
|
|
|
|
var newItem = document.createElement("menu");
|
|
|
|
var subMenu = document.createElement("menupopup");
|
|
|
|
subMenu.setAttribute("onpopupshowing", 'Scholar_Ingester_Interface.showPopup("'+childrenList[i].getID()+'", this)');
|
|
|
|
newItem.setAttribute("class", "menu-iconic scholar-scrape-popup-collection");
|
|
|
|
newItem.appendChild(subMenu);
|
|
|
|
} else {
|
|
|
|
var newItem = document.createElement("menuitem");
|
|
|
|
newItem.setAttribute("class", "menuitem-iconic scholar-scrape-popup-collection");
|
|
|
|
}
|
|
|
|
newItem.setAttribute("label", childrenList[i].getName());
|
|
|
|
newItem.setAttribute("oncommand", 'Scholar_Ingester_Interface.scrapeThisPage("'+childrenList[i].getID()+'")');
|
|
|
|
|
|
|
|
parentElement.appendChild(newItem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-02 18:22:34 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2006-06-26 20:02:30 +00:00
|
|
|
// Private Scholar_Ingester_Interface methods
|
2006-06-02 18:22:34 +00:00
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Gets a document object given a browser window object
|
|
|
|
*
|
|
|
|
* NOTE: Browser objects are associated with document objects via keys generated
|
|
|
|
* from the time the browser object is opened. I'm not sure if this is the
|
|
|
|
* appropriate mechanism for handling this, but it's what PiggyBank used and it
|
|
|
|
* appears to work.
|
|
|
|
*/
|
2006-06-20 00:52:15 +00:00
|
|
|
Scholar_Ingester_Interface._getDocument = function(browser) {
|
2006-06-02 18:22:34 +00:00
|
|
|
try {
|
|
|
|
var key = browser.getAttribute("scholar-key");
|
2006-06-20 00:52:15 +00:00
|
|
|
if(Scholar_Ingester_Interface.browserDocuments[key]) {
|
|
|
|
return Scholar_Ingester_Interface.browserDocuments[key];
|
2006-06-02 18:22:34 +00:00
|
|
|
}
|
|
|
|
} finally {}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Creates a new document object for a browser window object, attempts to
|
|
|
|
* retrieve appropriate scraper
|
|
|
|
*/
|
2006-06-20 00:52:15 +00:00
|
|
|
Scholar_Ingester_Interface._setDocument = function(browser) {
|
2006-06-02 18:22:34 +00:00
|
|
|
try {
|
|
|
|
var key = browser.getAttribute("scholar-key");
|
|
|
|
} finally {
|
|
|
|
if(!key) {
|
|
|
|
var key = (new Date()).getTime();
|
|
|
|
browser.setAttribute("scholar-key", key);
|
|
|
|
}
|
|
|
|
}
|
2006-06-24 21:39:36 +00:00
|
|
|
|
|
|
|
// Only re-load the scraper if it's a new document
|
2006-06-25 16:13:47 +00:00
|
|
|
//if(Scholar_Ingester_Interface.browserUris[key] != browser.contentDocument.location.href) {
|
2006-06-24 21:39:36 +00:00
|
|
|
Scholar_Ingester_Interface.browserUris[key] = browser.contentDocument.location.href;
|
|
|
|
Scholar_Ingester_Interface.browserDocuments[key] = new Scholar.Ingester.Document(browser, window);
|
|
|
|
Scholar_Ingester_Interface.browserDocuments[key].retrieveScraper();
|
2006-06-25 16:13:47 +00:00
|
|
|
//}
|
2006-06-02 18:22:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Deletes the document object associated with a given browser window object
|
|
|
|
*/
|
2006-06-20 00:52:15 +00:00
|
|
|
Scholar_Ingester_Interface._deleteDocument = function(browser) {
|
2006-06-02 18:22:34 +00:00
|
|
|
try {
|
|
|
|
var key = browser.getAttribute("scholar-key");
|
2006-06-20 00:52:15 +00:00
|
|
|
if(Scholar_Ingester_Interface.browserDocuments[key]) {
|
|
|
|
delete Scholar_Ingester_Interface.browserDocuments[key];
|
2006-06-02 18:22:34 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} finally {}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Callback to be executed when scraping is complete
|
|
|
|
*/
|
2006-06-27 21:02:26 +00:00
|
|
|
Scholar_Ingester_Interface._finishScraping = function(obj, returnValue, scrapeProgress, saveLocation) {
|
2006-06-17 21:21:15 +00:00
|
|
|
if(obj.items.length) {
|
2006-06-29 03:22:10 +00:00
|
|
|
scrapeProgress.changeHeadline(Scholar.getString("ingester.scrapeComplete"));
|
|
|
|
|
|
|
|
// Display title and creators
|
|
|
|
var labels = new Array();
|
|
|
|
var icons = new Array();
|
|
|
|
for(var i in obj.items) {
|
|
|
|
labels.push(obj.items[i].getField("title"));
|
|
|
|
icons.push("chrome://scholar/skin/treeitem-"+Scholar.ItemTypes.getName(obj.items[i].getField("itemTypeID"))+".png");
|
2006-06-02 23:53:42 +00:00
|
|
|
}
|
2006-06-29 03:22:10 +00:00
|
|
|
scrapeProgress.addLines(labels, icons);
|
2006-06-17 21:21:15 +00:00
|
|
|
|
2006-06-27 21:02:26 +00:00
|
|
|
// Get collection if the user used the drop-down menu
|
|
|
|
if(saveLocation) {
|
|
|
|
var saveCollection = Scholar.Collections.get(saveLocation);
|
|
|
|
}
|
2006-06-17 21:21:15 +00:00
|
|
|
// Save items
|
2006-06-27 04:08:21 +00:00
|
|
|
for(i in obj.items) {
|
2006-06-17 21:21:15 +00:00
|
|
|
obj.items[i].save();
|
2006-06-27 21:02:26 +00:00
|
|
|
if(saveLocation) {
|
|
|
|
saveCollection.addItem(obj.items[i].getID());
|
|
|
|
}
|
2006-06-27 04:08:21 +00:00
|
|
|
}
|
2006-06-27 21:02:26 +00:00
|
|
|
|
|
|
|
setTimeout(function() { scrapeProgress.fade() }, 2500);
|
2006-06-22 15:50:46 +00:00
|
|
|
} else if(returnValue) {
|
2006-06-27 21:02:26 +00:00
|
|
|
scrapeProgress.kill();
|
2006-06-02 23:53:42 +00:00
|
|
|
} else {
|
2006-06-27 21:02:26 +00:00
|
|
|
scrapeProgress.changeHeadline(Scholar.getString("ingester.scrapeError"));
|
|
|
|
scrapeProgress.addDescription(Scholar.getString("ingester.scrapeErrorDescription"));
|
|
|
|
setTimeout(function() { scrapeProgress.fade() }, 2500);
|
2006-06-02 18:22:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Scholar.Ingester.Progress
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Handles the display of a div showing progress in scraping
|
|
|
|
|
2006-06-27 02:03:10 +00:00
|
|
|
Scholar_Ingester_Interface.Progress = function(myWindow) {
|
|
|
|
this.openerWindow = myWindow;
|
|
|
|
this.progressWindow = myWindow.openDialog("chrome://scholar/chrome/ingester/progress.xul", "", "chrome,dialog=no,titlebar=no,popup=yes");
|
|
|
|
var me = this;
|
|
|
|
this.progressWindow.addEventListener("load", function() { me.windowLoaded() }, false);
|
2006-06-02 18:22:34 +00:00
|
|
|
|
2006-06-27 02:03:10 +00:00
|
|
|
this._loadDescription = null;
|
|
|
|
this._loadLines = new Array();
|
|
|
|
this._loadIcons = new Array();
|
|
|
|
this._loadHeadline = Scholar.getString("ingester.scraping");
|
|
|
|
}
|
|
|
|
|
|
|
|
Scholar_Ingester_Interface.Progress.prototype.windowLoaded = function() {
|
|
|
|
this._windowLoaded = true;
|
|
|
|
this._move();
|
2006-06-02 18:22:34 +00:00
|
|
|
|
2006-06-27 02:03:10 +00:00
|
|
|
this.changeHeadline(this._loadHeadline);
|
|
|
|
this.addLines(this._loadLines, this._loadIcons);
|
|
|
|
if(this._loadDescription) {
|
|
|
|
this.addDescription(this._loadDescription);
|
|
|
|
}
|
2006-06-02 18:22:34 +00:00
|
|
|
}
|
|
|
|
|
2006-06-20 00:52:15 +00:00
|
|
|
Scholar_Ingester_Interface.Progress.prototype.changeHeadline = function(headline) {
|
2006-06-27 02:03:10 +00:00
|
|
|
if(this._windowLoaded) {
|
|
|
|
this.progressWindow.document.getElementById("scholar-progress-text-headline").value = headline;
|
|
|
|
} else {
|
|
|
|
this._loadHeadline = headline;
|
|
|
|
}
|
2006-06-02 18:22:34 +00:00
|
|
|
}
|
|
|
|
|
2006-06-27 02:03:10 +00:00
|
|
|
Scholar_Ingester_Interface.Progress.prototype.addLines = function(label, icon) {
|
|
|
|
if(this._windowLoaded) {
|
|
|
|
for(i in label) {
|
|
|
|
var newLabel = this.progressWindow.document.createElement("label");
|
|
|
|
newLabel.setAttribute("class", "scholar-progress-item-label");
|
|
|
|
newLabel.setAttribute("crop", "end");
|
|
|
|
newLabel.setAttribute("value", label[i]);
|
|
|
|
|
|
|
|
var newImage = this.progressWindow.document.createElement("image");
|
|
|
|
newImage.setAttribute("class", "scholar-progress-item-icon");
|
|
|
|
newImage.setAttribute("src", icon[i]);
|
|
|
|
|
|
|
|
var newHB = this.progressWindow.document.createElement("hbox");
|
|
|
|
newHB.setAttribute("class", "scholar-progress-item-hbox");
|
|
|
|
newHB.setAttribute("valign", "center");
|
|
|
|
newHB.appendChild(newImage);
|
|
|
|
newHB.appendChild(newLabel);
|
|
|
|
|
|
|
|
this.progressWindow.document.getElementById("scholar-progress-text-box").appendChild(newHB);
|
|
|
|
}
|
|
|
|
|
|
|
|
this._move();
|
|
|
|
} else {
|
|
|
|
this._loadLines = this._loadLines.concat(label);
|
|
|
|
this._loadIcons = this._loadIcons.concat(icon);
|
|
|
|
}
|
2006-06-02 18:22:34 +00:00
|
|
|
}
|
|
|
|
|
2006-06-27 02:03:10 +00:00
|
|
|
Scholar_Ingester_Interface.Progress.prototype.addDescription = function(text) {
|
|
|
|
if(this._windowLoaded) {
|
|
|
|
var newHB = this.progressWindow.document.createElement("hbox");
|
|
|
|
newHB.setAttribute("class", "scholar-progress-item-hbox");
|
|
|
|
var newDescription = this.progressWindow.document.createElement("description");
|
|
|
|
newDescription.setAttribute("class", "scholar-progress-description");
|
|
|
|
var newText = this.progressWindow.document.createTextNode(text);
|
|
|
|
|
|
|
|
newDescription.appendChild(newText);
|
|
|
|
newHB.appendChild(newDescription);
|
|
|
|
this.progressWindow.document.getElementById("scholar-progress-text-box").appendChild(newHB);
|
|
|
|
|
|
|
|
this._move();
|
|
|
|
} else {
|
|
|
|
this._loadDescription = text;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Scholar_Ingester_Interface.Progress.prototype._move = function() {
|
|
|
|
this.progressWindow.sizeToContent();
|
|
|
|
this.progressWindow.moveTo(
|
|
|
|
this.openerWindow.screenX + this.openerWindow.outerWidth - this.progressWindow.outerWidth - 30,
|
|
|
|
this.openerWindow.screenY + this.openerWindow.outerHeight - this.progressWindow.outerHeight
|
|
|
|
);
|
2006-06-02 23:53:42 +00:00
|
|
|
}
|
|
|
|
|
2006-06-20 00:52:15 +00:00
|
|
|
Scholar_Ingester_Interface.Progress.prototype.fade = function() {
|
2006-06-29 03:22:10 +00:00
|
|
|
this.kill();
|
2006-06-02 18:22:34 +00:00
|
|
|
}
|
2006-06-22 15:50:46 +00:00
|
|
|
|
|
|
|
Scholar_Ingester_Interface.Progress.prototype.kill = function() {
|
2006-06-29 03:22:10 +00:00
|
|
|
try {
|
|
|
|
this.progressWindow.close();
|
|
|
|
} catch(ex) {}
|
2006-06-22 15:50:46 +00:00
|
|
|
}
|
|
|
|
|