Event.observe(window,'load',function (e) {Config.init();}); // Config isn't defined until after the Event.observe above // I could have put it below Config = ... but I want all window.load events // at the start of the file function init() { Config.init(); } var Config = { init: function () { new Ajax.Request('/xml-rpc?method=stats',{method: 'get',onComplete: Config.updateStatus}); new Ajax.Request('/xml-rpc?method=config',{method: 'get',onComplete: Config.showConfig}); }, showConfig: function (request) { $A(request.responseXML.getElementsByTagName('general')[0].childNodes).each(function (el) { $(el.nodeName).value = Element.textContent(el); }); }, updateStatus: function (request) { $('config_path').appendChild(document.createTextNode( Element.textContent(request.responseXML.getElementsByTagName('config_path')[0]))); } } Object.extend(Element, { removeChildren: function(element) { while(element.hasChildNodes()) { element.removeChild(element.firstChild); } }, textContent: function(node) { if ((!node) || !node.hasChildNodes()) { // Empty text node return ''; } else { if (node.textContent) { // W3C ? return node.textContent; } else if (node.text) { // IE return node.text; } } // We shouldn't end up here; return ''; } }); /* Detta script finns att hamta pa http://www.jojoxx.net och far anvandas fritt sa lange som dessa rader star kvar. */ function DataDumper(obj,n,prefix){ var str=""; prefix=(prefix)?prefix:""; n=(n)?n+1:1; var ind=""; for(var i=0;i"); } } else { for(var i in obj){ str+=DataDumper(obj[i],n,i+"=>"); } } str+=ind+"]\n"; } return str; }