2006-03-31 15:08:40 -05:00
|
|
|
Event.observe(window,'load',initStatus);
|
|
|
|
|
2006-06-25 16:33:47 -04:00
|
|
|
var UPDATE_FREQUENCY = 5000; // number of milliseconds between page updates
|
2006-03-31 15:08:40 -05:00
|
|
|
|
|
|
|
function initStatus(e) {
|
2006-06-27 18:08:26 -04:00
|
|
|
Updater.update();
|
|
|
|
// Bind events to the buttons
|
|
|
|
Event.observe('button_stop_server','click',Updater.stopServer);
|
|
|
|
Event.observe('button_start_scan','click',Updater.startScan);
|
|
|
|
Event.observe('button_start_full_scan','click',Updater.startFullScan);
|
2006-04-06 17:00:47 -04:00
|
|
|
}
|
|
|
|
var Updater = {
|
2006-06-27 18:08:26 -04:00
|
|
|
stop: false,
|
|
|
|
wait: function () {
|
|
|
|
Updater.updateTimeout = window.setTimeout(Updater.update,UPDATE_FREQUENCY);
|
|
|
|
Updater.spinnerTimeout = window.setTimeout(Util.startSpinner,UPDATE_FREQUENCY-1000);
|
2006-04-06 17:00:47 -04:00
|
|
|
},
|
|
|
|
update: function () {
|
2006-06-27 18:08:26 -04:00
|
|
|
if (Updater.updateTimeout) {
|
|
|
|
window.clearTimeout(Updater.updateTimeout);
|
|
|
|
}
|
|
|
|
if (Updater.spinnerTimeout) {
|
2006-06-27 20:01:39 -04:00
|
|
|
window.clearTimeout(Updater.spinnerTimeout);
|
|
|
|
}
|
|
|
|
if (Updater.stop) {
|
|
|
|
return;
|
2006-06-27 18:08:26 -04:00
|
|
|
}
|
2006-06-25 16:33:47 -04:00
|
|
|
new Ajax.Request('xml-rpc?method=stats',{method: 'get',onComplete: Updater.rsStats});
|
2006-04-06 17:00:47 -04:00
|
|
|
},
|
2006-06-25 16:33:47 -04:00
|
|
|
rsStats: function(request) {
|
2006-06-27 18:08:26 -04:00
|
|
|
Util.stopSpinner();
|
2006-06-25 16:33:47 -04:00
|
|
|
['service','stat'].each(function (tag) {
|
|
|
|
$A(request.responseXML.getElementsByTagName(tag)).each(function (element) {
|
2006-06-27 18:08:26 -04:00
|
|
|
var node = $(Element.textContent(element.firstChild).toLowerCase().replace(/\ /,'_'));
|
|
|
|
var status = Element.textContent(element.childNodes[1]);
|
|
|
|
node.replaceChild(document.createTextNode(status),node.firstChild);
|
|
|
|
if ('Idle' == status) {
|
|
|
|
$('button_start_scan').disabled = false;
|
|
|
|
$('button_start_full_scan').disabled = false;
|
|
|
|
}
|
2006-06-25 16:33:47 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
var thread = $A(request.responseXML.getElementsByTagName('thread'));
|
|
|
|
var threadTable = new Table('thread');
|
|
|
|
threadTable.removeTBodyRows();
|
|
|
|
var users = 0;
|
|
|
|
thread.each(function (element) {
|
|
|
|
users++;
|
|
|
|
row = [];
|
|
|
|
row.push(Element.textContent(element.childNodes[1]));
|
|
|
|
row.push(Element.textContent(element.childNodes[2]));
|
|
|
|
threadTable.addTbodyRow(row);
|
2006-03-31 15:08:40 -05:00
|
|
|
});
|
2007-04-04 16:34:29 -04:00
|
|
|
|
|
|
|
// Monkey see, monkey do
|
|
|
|
var plugin = $A(request.responseXML.getElementsByTagName('plugin'));
|
|
|
|
var pluginTable = new Table('plugin');
|
|
|
|
pluginTable.removeTBodyRows();
|
|
|
|
plugin.each(function(element) {
|
|
|
|
row = [];
|
|
|
|
info = Element.textContent(element.childNodes[0]).split('/',2);
|
|
|
|
row.push(info[0]);
|
|
|
|
row.push(info[1]);
|
|
|
|
pluginTable.addTbodyRow(row);
|
|
|
|
});
|
|
|
|
|
2006-06-25 16:33:47 -04:00
|
|
|
// $('session_count').replaceChild(document.createTextNode(users + ' Connected Users'),$('session_count').firstChild);
|
2006-06-27 18:08:26 -04:00
|
|
|
if (!Updater.stop) {
|
|
|
|
Updater.wait();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
stopServer: function() {
|
|
|
|
Util.stopSpinner();
|
2006-06-27 20:01:39 -04:00
|
|
|
new Ajax.Request('xml-rpc',{method:'post',parameters: 'method=shutdown',onComplete: Updater.rsStopServer});
|
2006-06-27 18:08:26 -04:00
|
|
|
},
|
|
|
|
rsStopServer: function(request) {
|
|
|
|
Updater.stop = true;
|
2006-06-27 20:01:39 -04:00
|
|
|
Updater.update(); // To clear the spinner timeout
|
2006-06-27 18:08:26 -04:00
|
|
|
Element.show('grey_screen');
|
|
|
|
Effect.Appear('server_stopped_message');
|
|
|
|
},
|
|
|
|
startScan: function(e) {
|
|
|
|
Event.element(e).disabled = true;
|
|
|
|
new Ajax.Request('xml-rpc',{method:'post',parameters: 'method=rescan',onComplete: Updater.rsStartScan});
|
|
|
|
},
|
|
|
|
rsStartScan: function(request) {
|
|
|
|
Updater.update();
|
|
|
|
},
|
|
|
|
startFullScan: function(e) {
|
|
|
|
Event.element(e).disabled = true;
|
|
|
|
new Ajax.Request('xml-rpc',{method:'post',parameters: 'method=rescan&full=1',onComplete: Updater.rsStartFullScan});
|
|
|
|
},
|
|
|
|
rsStartFullScan: function(request) {
|
|
|
|
Updater.update();
|
|
|
|
}
|
2006-03-31 15:08:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Table = Class.create();
|
|
|
|
Object.extend(Table.prototype,{
|
|
|
|
initialize: function (id) {
|
|
|
|
this.tbody = $(id).getElementsByTagName('tbody')[0];
|
|
|
|
},
|
|
|
|
removeTBodyRows: function () {
|
|
|
|
Element.removeChildren(this.tbody);
|
|
|
|
},
|
|
|
|
addTbodyRow: function (cells) {
|
|
|
|
var tr = document.createElement('tr');
|
|
|
|
cells.each(function (cell) {
|
|
|
|
var td = document.createElement('td');
|
|
|
|
td.appendChild(document.createTextNode(cell));
|
|
|
|
tr.appendChild(td);
|
|
|
|
});
|
|
|
|
this.tbody.appendChild(tr);
|
|
|
|
}
|
2006-05-27 17:04:19 -04:00
|
|
|
});
|