mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-24 13:13:17 -05:00
Added debugging to config.html
If you open the page /config.html?debug There will be debug messages to the javascript console when you press the Save button In Safari activate the javascript console like this http://getahead.ltd.uk/ajax/debug-safari In Firefox install the extension Firebug and activate the console there
This commit is contained in:
parent
7f84afb786
commit
62c3ac542a
@ -9,6 +9,7 @@ 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
|
||||||
|
var DEBUG = window.location.toString().match(/debug/);
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
Config.init();
|
Config.init();
|
||||||
@ -387,9 +388,15 @@ function saved(req) {
|
|||||||
function saveForm() {
|
function saveForm() {
|
||||||
var postVars = [];
|
var postVars = [];
|
||||||
var multiple = {};
|
var multiple = {};
|
||||||
|
|
||||||
$A($('theform').getElementsByTagName('select')).each(function (select) {
|
$A($('theform').getElementsByTagName('select')).each(function (select) {
|
||||||
postVars.push(Form.Element.serialize(select.id));
|
if (DEBUG) {
|
||||||
|
debug(select.id,select.value);
|
||||||
|
} else {
|
||||||
|
postVars.push(Form.Element.serialize(select.id));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$A($('theform').getElementsByTagName('input')).each(function (input) {
|
$A($('theform').getElementsByTagName('input')).each(function (input) {
|
||||||
if (ConfigXML.getOptionFromElementName(input.name).multiple) {
|
if (ConfigXML.getOptionFromElementName(input.name).multiple) {
|
||||||
if (multiple[input.name]) {
|
if (multiple[input.name]) {
|
||||||
@ -398,16 +405,43 @@ function saveForm() {
|
|||||||
multiple[input.name] = [input.value];
|
multiple[input.name] = [input.value];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
postVars.push(Form.Element.serialize(input.id));
|
if (DEBUG) {
|
||||||
|
debug(input.id,input.value);
|
||||||
|
} else {
|
||||||
|
postVars.push(Form.Element.serialize(input.id));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$H(multiple).each(function (item) {
|
$H(multiple).each(function (item) {
|
||||||
postVars.push(item.key + '=' + item.value.join(','));
|
if (DEBUG) {
|
||||||
|
debug(item.key,item.value.join(','));
|
||||||
|
} else {
|
||||||
|
postVars.push(item.key + '=' + item.value.join(','));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
if (DEBUG) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
new Ajax.Request('/xml-rpc?method=updateconfig',
|
new Ajax.Request('/xml-rpc?method=updateconfig',
|
||||||
{method: 'post',
|
{method: 'post',
|
||||||
parameters: postVars.join('&'),
|
parameters: postVars.join('&'),
|
||||||
onComplete: saved});
|
onComplete: saved});
|
||||||
|
function debug(id,value) {
|
||||||
|
var getArr = [];
|
||||||
|
var a = id.split(':');
|
||||||
|
getArr.push('section='+encodeURIComponent(a[0]));
|
||||||
|
getArr.push('key='+encodeURIComponent(a[1]));
|
||||||
|
getArr.push('value='+encodeURIComponent(value));
|
||||||
|
getArr.push('verify_only=1');
|
||||||
|
var url = a[1] + '=' + value;
|
||||||
|
new Ajax.Request('/xml-rpc?method=setconfig&' + getArr.join('&'),
|
||||||
|
{method: 'get',
|
||||||
|
onComplete: function(req){console.log(url + ' => ' +
|
||||||
|
Element.textContent(req.responseXML.getElementsByTagName('statusstring')[0]));
|
||||||
|
} });
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function cancelForm() {
|
function cancelForm() {
|
||||||
ConfigXML.getSections().each(function (section){
|
ConfigXML.getSections().each(function (section){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user