2007-12-03 18:16:38 +00:00
|
|
|
var GroupNodeTableUpdater = {};
|
2007-10-26 22:44:33 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Hides/shows the nodes in a node group table.
|
|
|
|
*/
|
2007-12-03 18:16:38 +00:00
|
|
|
GroupNodeTableUpdater.toggleSection = function(nodeGroupName) {
|
2007-10-26 22:44:33 +00:00
|
|
|
var tableId = "div_" + nodeGroupName;
|
|
|
|
var imageId = tableId + '-im';
|
|
|
|
var expandSpanId = "img_gr_" + nodeGroupName;
|
|
|
|
|
|
|
|
var tableObj = $(tableId);
|
|
|
|
|
|
|
|
if(null == tableObj) {
|
|
|
|
alert('Error: section ' + tableId + ' not found.');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
var imageTag = $(imageId);
|
|
|
|
var expandSpanObj = $(expandSpanId);
|
|
|
|
|
|
|
|
if(!tableObj.style.display || tableObj.style.display == 'inline') {
|
|
|
|
// the inner table is currently visible
|
|
|
|
tableObj.style.display = 'none';
|
2007-11-28 19:37:25 +00:00
|
|
|
imageTag.src = "../images/plus-sign.gif";
|
2007-10-26 22:44:33 +00:00
|
|
|
expandSpanObj.title = "Click to expand section";
|
|
|
|
} else {
|
|
|
|
// the inner table is currently invisible
|
|
|
|
tableObj.style.display = 'inline';
|
2007-11-28 19:37:25 +00:00
|
|
|
imageTag.src = "../images/minus-sign.gif";
|
2007-10-26 22:44:33 +00:00
|
|
|
expandSpanObj.title = "Click to collapse section";
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
2007-12-03 18:16:38 +00:00
|
|
|
GroupNodeTableUpdater.getFailureSpanHTML = function(nodeGroupName) {
|
2007-10-26 22:44:33 +00:00
|
|
|
var spanId = "nodegroup_" + nodeGroupName + "_failure";
|
|
|
|
var html = '<span id="' + spanId + '">There was a problem loading the node for the group ' + nodeGroupName + '</span>';
|
|
|
|
return html;
|
|
|
|
}
|
|
|
|
|
2007-12-03 18:16:38 +00:00
|
|
|
GroupNodeTableUpdater.getLoadingSpanHTML = function(nodeGroupName) {
|
2007-10-26 22:44:33 +00:00
|
|
|
var spanId = "nodegroup_" + nodeGroupName + "_loading";
|
2007-12-04 18:17:21 +00:00
|
|
|
var html = '<span id="' + spanId + '" style="padding-left: 0.5em; display: none;"><img alt="Loading ..." src="../images/ajax-loader.gif" /></span>';
|
2007-10-26 22:44:33 +00:00
|
|
|
return html;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2007-12-03 18:16:38 +00:00
|
|
|
* This is the onCreate callback for the AJAX request made in GroupNodeTableUpdater.updateNodeList.
|
2007-10-26 22:44:33 +00:00
|
|
|
* It updates the interface to show that the request is loading.
|
|
|
|
* See http://www.prototypejs.org/api/ajax/options
|
|
|
|
*/
|
2007-12-03 18:16:38 +00:00
|
|
|
GroupNodeTableUpdater.updateNodeListLoading = function(nodeGroupName) {
|
2007-10-26 22:44:33 +00:00
|
|
|
|
|
|
|
var spanId = 'img_gr_' + nodeGroupName;
|
2007-12-03 18:16:38 +00:00
|
|
|
new Insertion.Bottom(spanId, GroupNodeTableUpdater.getLoadingSpanHTML(nodeGroupName));
|
2007-10-26 22:44:33 +00:00
|
|
|
|
|
|
|
var loadingSpanId = "nodegroup_" + nodeGroupName + "_loading";
|
|
|
|
new Effect.Appear(loadingSpanId);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2007-12-03 18:16:38 +00:00
|
|
|
* This is the onFailure callback for the AJAX request made in GroupNodeTableUpdater.updateNodeList.
|
2007-10-26 22:44:33 +00:00
|
|
|
* It updates the interface to show that the request failed.
|
|
|
|
* See http://www.prototypejs.org/api/ajax/options
|
|
|
|
*/
|
2007-12-03 18:16:38 +00:00
|
|
|
GroupNodeTableUpdater.updateNodeListFailure = function(nodeGroupName) {
|
2007-10-26 22:44:33 +00:00
|
|
|
var spanId = 'img_gr_' + nodeGroupName;
|
2007-12-03 18:16:38 +00:00
|
|
|
new Insertion.Bottom(spanId, GroupNodeTableUpdater.getFailureSpanHTML(nodeGroupName));
|
2007-10-26 22:44:33 +00:00
|
|
|
|
|
|
|
var failureSpanId = "nodegroup_" + nodeGroupName + "_failure";
|
|
|
|
new Effect.Shake(failureSpanId);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add table rows representing nodes to the table that represents the node group
|
|
|
|
* identified by the given name.
|
|
|
|
*/
|
2007-12-03 18:16:38 +00:00
|
|
|
GroupNodeTableUpdater.updateNodeList = function(nodeGroupName) {
|
2007-10-26 22:44:33 +00:00
|
|
|
|
|
|
|
var tableId = "div_" + nodeGroupName;
|
|
|
|
var imageId = tableId + '-im';
|
|
|
|
var expandSpanId = "img_gr_" + nodeGroupName;
|
|
|
|
|
2007-12-03 18:16:38 +00:00
|
|
|
var tableObj = $(tableId);
|
2007-10-26 22:44:33 +00:00
|
|
|
|
|
|
|
if(null == tableObj) {
|
|
|
|
alert('Error: section ' + tableId + ' not found.');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-12-03 18:16:38 +00:00
|
|
|
var imageTag = $(imageId);
|
|
|
|
var expandSpanObj = $(expandSpanId);
|
2007-10-26 22:44:33 +00:00
|
|
|
|
|
|
|
if(!tableObj.style.display || tableObj.style.display == 'inline') {// currently visible
|
|
|
|
|
|
|
|
tableObj.style.display = 'none';
|
2007-11-28 19:37:25 +00:00
|
|
|
imageTag.src = "../images/plus-sign.gif";
|
2007-10-26 22:44:33 +00:00
|
|
|
expandSpanObj.title = "Click to expand section";
|
|
|
|
|
|
|
|
} else { //currently invisible
|
2007-11-28 19:37:25 +00:00
|
|
|
imageTag.src = "../images/minus-sign.gif";
|
2007-10-26 22:44:33 +00:00
|
|
|
expandSpanObj.title = "Click to collapse section";
|
|
|
|
|
|
|
|
var target = "div_" + nodeGroupName;
|
|
|
|
var pars = 'nodeGroupName=' + nodeGroupName;
|
|
|
|
var URL = 'nodes_by_group.php';
|
|
|
|
|
|
|
|
// Check whether the table already exists and has already been updated?
|
|
|
|
|
2007-12-03 18:16:38 +00:00
|
|
|
//alert('About to call Ajax.Updater');
|
2007-10-26 22:44:33 +00:00
|
|
|
new Ajax.Updater(target, URL, {
|
|
|
|
method: 'post', parameters: pars,
|
2007-12-03 18:16:38 +00:00
|
|
|
onCreate: function() { GroupNodeTableUpdater.updateNodeListLoading(nodeGroupName) }, // Needs Prototype 1.5.1
|
|
|
|
onFailure: function() {GroupNodeTableUpdater.updateNodeListFailure(nodeGroupName) },
|
2007-10-26 22:44:33 +00:00
|
|
|
onComplete: function() {new Effect.Fade("nodegroup_" + nodeGroupName + "_loading")}
|
|
|
|
});
|
|
|
|
|
|
|
|
// the inner table is currently invisible
|
|
|
|
tableObj.style.display = 'inline';
|
2007-12-03 18:16:38 +00:00
|
|
|
//alert('Back from Ajax.Updater');
|
2007-10-26 22:44:33 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-12-03 18:16:38 +00:00
|
|
|
//GroupNodeTableUpdater.toggleSection(nodeGroupName);
|
2007-10-26 22:44:33 +00:00
|
|
|
}
|