Added a rudimentary Save button on config.html. It will try to

save the file, but nothing is checked and your mt-daapd.conf might
be changed in strange ways. Pressing the button will give you the
server response in an alert box.
This commit is contained in:
Anders Betnér 2006-05-17 18:42:56 +00:00
parent 28e0956e66
commit d7c61d62b3
2 changed files with 18 additions and 7 deletions

View File

@ -37,7 +37,7 @@ make changes to these settings, they will not be reflected in the
running server. The server must be restarted for these values to running server. The server must be restarted for these values to
take effect.--> take effect.-->
This is work in progress. no changes saved, some fields not updated, some not even in mt-daapd.conf</p> This is work in progress. no changes saved, some fields not updated, some not even in mt-daapd.conf</p>
<button id="button_save">Save</button><button id="button_cancel">Cancel</button>
<form id="theform" method="get" action="#"> <form id="theform" method="get" action="#">
</form> </form>

View File

@ -1,14 +1,11 @@
Event.observe(window,'load',function (e) {Config.init();}); Event.observe(window,'load',init);
// Config isn't defined until after the Event.observe above // Config isn't defined until after the Event.observe above
// I could have put it below Config = ... but I want all window.load events // I could have put it below Config = ... but I want all window.load events
// at the start of the file // at the start of the file
function init() { function init() {
Config.init(); Config.init();
} Event.observe($('button_save'),'click',saveForm);
function hej() {
alert(Form.serialize('theform'));
} }
var ConfigXML = { var ConfigXML = {
config: [], config: [],
@ -47,7 +44,6 @@ var ConfigXML = {
}); });
ConfigXML.config[section.getAttribute('name')] = items; ConfigXML.config[section.getAttribute('name')] = items;
}); });
a=12;
} }
}; };
var Config = { var Config = {
@ -255,6 +251,21 @@ var BuildElement = {
} }
} }
function saved(req) {
alert(req.responseText);
}
function saveForm() {
var getString = [];
$A($('theform').getElementsByTagName('input')).each(function (input,i) {
if ((i > 10) && (i < 17)) {
getString.push(Form.Element.serialize(input.id));
}
});
getString = getString.join('&');
new Ajax.Request('/xml-rpc?method=updateconfig&'+getString,{method: 'get',
onComplete: saved
});
}
Object.extend(Element, { Object.extend(Element, {
removeChildren: function(element) { removeChildren: function(element) {
while(element.hasChildNodes()) { while(element.hasChildNodes()) {