mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-25 14:45:55 -05:00
Whohoho!!! This is the first commit where you actually can
save the changes made on config.html. The result of the save is displayed as an ugly alert with the xml response, but it works!
This commit is contained in:
parent
5d611fe52a
commit
1804fdf595
@ -17,16 +17,10 @@ function init() {
|
||||
Config.init();
|
||||
}
|
||||
var ConfigXML = {
|
||||
config: [],
|
||||
config: {},
|
||||
configIndex: {},
|
||||
getOptionFromElementName: function (name) {
|
||||
var id = name.replace(/.*:/,'');
|
||||
return Try.these(
|
||||
function () {ConfigXml.config['Server'][id];},
|
||||
function () {ConfigXml.config['Music_Files'][id];},
|
||||
function () {ConfigXml.config['Database'][id];},
|
||||
function () {ConfigXml.config['Plugins'][id];},
|
||||
function () {ConfigXml.config['Transcoding'][id];}
|
||||
);
|
||||
return this.configIndex[name];
|
||||
},
|
||||
getOption: function (section,id) {
|
||||
return this.config[section][id];
|
||||
@ -67,7 +61,10 @@ var ConfigXML = {
|
||||
});
|
||||
}
|
||||
});
|
||||
// Double index everything one as [section][id]
|
||||
// and one as [config_section:id]
|
||||
items[item.getAttribute('id')] = returnItem;
|
||||
ConfigXML.configIndex[returnItem.config_section+ ':' +returnItem.id] = returnItem;
|
||||
});
|
||||
ConfigXML.config[section.getAttribute('name')] = items;
|
||||
});
|
||||
@ -334,15 +331,29 @@ function saved(req) {
|
||||
alert(req.responseText);
|
||||
}
|
||||
function saveForm() {
|
||||
var getString = [];
|
||||
$A($('theform').getElementsByTagName('input')).each(function (input,i) {
|
||||
if (input.value != '') {
|
||||
getString.push(Form.Element.serialize(input.id));
|
||||
}
|
||||
var postVars = [];
|
||||
var multiple = {};
|
||||
$A($('theform').getElementsByTagName('select')).each(function (select) {
|
||||
postVars.push(Form.Element.serialize(select.id));
|
||||
});
|
||||
getString = getString.join('&');
|
||||
new Ajax.Request('/xml-rpc?method=updateconfig&'+getString,{method: 'get',
|
||||
onComplete: saved
|
||||
$A($('theform').getElementsByTagName('input')).each(function (input) {
|
||||
if (ConfigXML.getOptionFromElementName(input.name).multiple) {
|
||||
if (multiple[input.name]) {
|
||||
multiple[input.name].push(encodeURIComponent(input.value));
|
||||
} else {
|
||||
multiple[input.name] = [input.value];
|
||||
}
|
||||
} else {
|
||||
postVars.push(Form.Element.serialize(input.id));
|
||||
};
|
||||
});
|
||||
$H(multiple).each(function (item) {
|
||||
postVars.push(item.key + '=' + item.value.join(','));
|
||||
});
|
||||
new Ajax.Request('/xml-rpc?method=updateconfig',
|
||||
{method: 'post',
|
||||
parameters: postVars.join('&'),
|
||||
onComplete: saved
|
||||
});
|
||||
}
|
||||
function cancelForm() {
|
||||
|
@ -60,7 +60,7 @@
|
||||
<option value="1">Yes</option>
|
||||
</options>
|
||||
</item>
|
||||
<item id="debug" config_section="general">
|
||||
<item id="debuglevel" config_section="general">
|
||||
<name>Debug Level</name>
|
||||
<short_description>
|
||||
Possible values are 0 to 9, 9 being the most detailed debug level.
|
||||
|
Loading…
Reference in New Issue
Block a user