mirror of
https://github.com/owntone/owntone-server.git
synced 2025-04-01 10:13:45 -04:00
You can sort of cancel=revert you inputs on config.html and
I reenabled the save button if someone wants to play with it.
This commit is contained in:
parent
dffdfa56c6
commit
430b0ef9a4
@ -1,8 +1,6 @@
|
|||||||
Event.observe(window,'load',init);
|
Event.observe(window,'load',init);
|
||||||
//###TODO
|
//###TODO
|
||||||
//Check if writable
|
|
||||||
//Disable/enable save/cancel
|
//Disable/enable save/cancel
|
||||||
//swap buttons if navigator.platform == mac
|
|
||||||
/* platform = window.navigator.platform.toLowerCase();
|
/* platform = window.navigator.platform.toLowerCase();
|
||||||
if (platform.indexOf('win') != -1)
|
if (platform.indexOf('win') != -1)
|
||||||
navigator.OS = 'win';
|
navigator.OS = 'win';
|
||||||
@ -20,7 +18,7 @@ Event.observe(window,'load',init);
|
|||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
Config.init();
|
Config.init();
|
||||||
Event.observe($('button_save'),'click',saveForm);
|
|
||||||
}
|
}
|
||||||
var ConfigXML = {
|
var ConfigXML = {
|
||||||
config: [],
|
config: [],
|
||||||
@ -71,6 +69,34 @@ var ConfigXML = {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
var ConfigInitialValues = {
|
||||||
|
values: {},
|
||||||
|
getValues: function () {
|
||||||
|
return $H(this.values);
|
||||||
|
},
|
||||||
|
parseXML: function (xmldoc) {
|
||||||
|
// IE and w3c treat xmldoc differently make shore firstChild is firstchild of <config>
|
||||||
|
if (xmldoc.childNodes[1] && xmldoc.childNodes[1].nodeName == 'config') {
|
||||||
|
sections = $A(xmldoc.childNodes[1].childNodes);
|
||||||
|
} else {
|
||||||
|
sections = $A(xmldoc.firstChild.childNodes);
|
||||||
|
}
|
||||||
|
sections.each(function (section) {
|
||||||
|
var sectionName = section.nodeName;
|
||||||
|
$A(section.childNodes).each(function (node) {
|
||||||
|
if (node.childNodes.length > 1) {
|
||||||
|
var values = [];
|
||||||
|
$A(node.childNodes).each(function (n) {
|
||||||
|
values.push(Element.textContent(n));
|
||||||
|
});
|
||||||
|
ConfigInitialValues.values[sectionName+':'+node.nodeName] = values;
|
||||||
|
} else {
|
||||||
|
ConfigInitialValues.values[sectionName+':'+node.nodeName] = Element.textContent(node);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
var Config = {
|
var Config = {
|
||||||
configPath: '',
|
configPath: '',
|
||||||
configOptionValues: '',
|
configOptionValues: '',
|
||||||
@ -78,7 +104,6 @@ var Config = {
|
|||||||
new Ajax.Request('/config.xml',{method: 'get',onComplete: Config.storeConfigLayout});
|
new Ajax.Request('/config.xml',{method: 'get',onComplete: Config.storeConfigLayout});
|
||||||
},
|
},
|
||||||
storeConfigLayout: function (request) {
|
storeConfigLayout: function (request) {
|
||||||
Config.layout = request.responseXML;
|
|
||||||
ConfigXML.parseXML(request.responseXML);
|
ConfigXML.parseXML(request.responseXML);
|
||||||
new Ajax.Request('/xml-rpc?method=stats',{method: 'get',onComplete: Config.updateStatus});
|
new Ajax.Request('/xml-rpc?method=stats',{method: 'get',onComplete: Config.updateStatus});
|
||||||
},
|
},
|
||||||
@ -91,6 +116,7 @@ var Config = {
|
|||||||
new Ajax.Request('/xml-rpc?method=config',{method: 'get',onComplete: Config.showConfig});
|
new Ajax.Request('/xml-rpc?method=config',{method: 'get',onComplete: Config.showConfig});
|
||||||
},
|
},
|
||||||
showConfig: function (request) {
|
showConfig: function (request) {
|
||||||
|
ConfigInitialValues.parseXML(request.responseXML);
|
||||||
Config.configOptionValues = request.responseXML;
|
Config.configOptionValues = request.responseXML;
|
||||||
var sections = ConfigXML.getSections();
|
var sections = ConfigXML.getSections();
|
||||||
sections.each(function (section) {
|
sections.each(function (section) {
|
||||||
@ -115,8 +141,11 @@ var Config = {
|
|||||||
Effect.Appear('config_not_writable_warning');
|
Effect.Appear('config_not_writable_warning');
|
||||||
} else {
|
} else {
|
||||||
// Create save and cancel buttons
|
// Create save and cancel buttons
|
||||||
var save = Builder.node('button',{id: 'button_save', disabled: 'disabled'},'Save');
|
// var save = Builder.node('button',{id: 'button_save', disabled: 'disabled'},'Save');
|
||||||
|
var save = Builder.node('button',{id: 'button_save'},'Save');
|
||||||
|
Event.observe(save,'click',saveForm);
|
||||||
var cancel = Builder.node('button',{id: 'button_cancel'},'Cancel');
|
var cancel = Builder.node('button',{id: 'button_cancel'},'Cancel');
|
||||||
|
Event.observe(cancel,'click',cancelForm);
|
||||||
var spacer = document.createTextNode('\u00a0\u00a0');
|
var spacer = document.createTextNode('\u00a0\u00a0');
|
||||||
var buttons = $('buttons');
|
var buttons = $('buttons');
|
||||||
if (navigator.platform.indexOf('mac') != -1) {
|
if (navigator.platform.indexOf('mac') != -1) {
|
||||||
@ -131,6 +160,9 @@ var Config = {
|
|||||||
buttons.appendChild(cancel);
|
buttons.appendChild(cancel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
_parseConfigOptionValues: function (xmldoc) {
|
||||||
|
|
||||||
},
|
},
|
||||||
_getConfigOptionValue: function(id,multiple) {
|
_getConfigOptionValue: function(id,multiple) {
|
||||||
if (multiple) {
|
if (multiple) {
|
||||||
@ -312,6 +344,23 @@ function saveForm() {
|
|||||||
onComplete: saved
|
onComplete: saved
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function cancelForm() {
|
||||||
|
//###TODO Handle default values for elements not returned by method=config
|
||||||
|
ConfigInitialValues.getValues().each(function (option) {
|
||||||
|
if (typeof (option.value) == 'object') {
|
||||||
|
//###TODO what if user removed one of the multiplevalued options?
|
||||||
|
if (option.value != '') {
|
||||||
|
option.value.each(function (val,i) {
|
||||||
|
$(option.key + i).value = val;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var el = $(option.key);
|
||||||
|
if (el) {
|
||||||
|
el.value = option.value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
Object.extend(Element, {
|
Object.extend(Element, {
|
||||||
removeChildren: function(element) {
|
removeChildren: function(element) {
|
||||||
while(element.hasChildNodes()) {
|
while(element.hasChildNodes()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user