2006-06-22 02:43:40 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Scholar_Ingester_Interface_SelectItems
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Class to interface with the browser when ingesting data
|
|
|
|
|
|
|
|
Scholar_Ingester_Interface_SelectItems = function() {}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Public Scholar_Ingester_Interface_SelectItems methods
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize some variables and prepare event listeners for when chrome is done
|
|
|
|
* loading
|
|
|
|
*/
|
|
|
|
Scholar_Ingester_Interface_SelectItems.init = function() {
|
2006-06-22 15:50:46 +00:00
|
|
|
this.io = window.arguments[0];
|
|
|
|
this.Scholar_Ingester_Interface = window.arguments[1];
|
2006-06-22 20:50:57 +00:00
|
|
|
var listbox = document.getElementById("scholar-selectitems-links");
|
2006-06-22 02:43:40 +00:00
|
|
|
|
2006-06-22 15:50:46 +00:00
|
|
|
for(i in this.io.dataIn) { // we could use a tree for this if we wanted to
|
2006-06-22 02:43:40 +00:00
|
|
|
var itemNode = document.createElement("listitem");
|
|
|
|
itemNode.setAttribute("type", "checkbox");
|
|
|
|
itemNode.setAttribute("value", i);
|
2006-06-22 15:50:46 +00:00
|
|
|
itemNode.setAttribute("label", this.io.dataIn[i]);
|
2006-06-22 02:43:40 +00:00
|
|
|
itemNode.setAttribute("checked", false);
|
2006-06-22 20:50:57 +00:00
|
|
|
listbox.appendChild(itemNode);
|
2006-06-22 02:43:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Scholar_Ingester_Interface_SelectItems.acceptSelection = function() {
|
2006-06-22 20:50:57 +00:00
|
|
|
var listbox = document.getElementById("scholar-selectitems-links");
|
|
|
|
|
|
|
|
var returnObject = false;
|
2006-06-22 15:50:46 +00:00
|
|
|
this.io.dataOut = new Object();
|
2006-06-22 02:43:40 +00:00
|
|
|
|
|
|
|
// collect scrapeURLList from listbox
|
2006-06-22 20:50:57 +00:00
|
|
|
for(var i=0; i<listbox.childNodes.length; i++) {
|
|
|
|
var itemNode = listbox.childNodes[i];
|
|
|
|
if(itemNode.getAttribute("checked") == "true") {
|
|
|
|
this.io.dataOut[itemNode.getAttribute("value")] = itemNode.getAttribute("label");
|
|
|
|
returnObject = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// What a hack! this makes code down the road much easier because otherwise
|
|
|
|
// an empty array is true but empty and we can't figure that out, because
|
|
|
|
// there's no length
|
|
|
|
if(!returnObject) {
|
|
|
|
this.io.dataOut = null;
|
2006-06-22 02:43:40 +00:00
|
|
|
}
|
|
|
|
}
|