/config.html?debug will save all options one by one

and report errors to the console (Firefox with Firebug or Safari
other browsers might explode)
/config.html?debug=validate will validate all options
one by one and report errors to the very same console
This commit is contained in:
Anders Betnér 2006-05-31 20:10:21 +00:00
parent 03ec76d36c
commit a02298ca0d

View File

@ -9,8 +9,10 @@ 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/); var DEBUG = window.location.toString().match(/debug.*/);
if ('debug=validate' == DEBUG) {
DEBUG = 'validate';
}
function init() { function init() {
Config.init(); Config.init();
} }
@ -427,15 +429,23 @@ function saveForm() {
{method: 'post', {method: 'post',
parameters: postVars.join('&'), parameters: postVars.join('&'),
onComplete: saved}); onComplete: saved});
function debug(id,value) { function debug(id,value) {
var getArr = []; var getArr = [];
var a = id.split(':'); var getString;
getArr.push('section='+encodeURIComponent(a[0])); if ('validate' == DEBUG) {
getArr.push('key='+encodeURIComponent(a[1])); var a = id.split(':');
getArr.push('value='+encodeURIComponent(value)); getArr.push('section='+encodeURIComponent(a[0]));
getArr.push('verify_only=1'); getArr.push('key='+encodeURIComponent(a[1]));
var output = a[0] + ':' + a[1] + '=' + value; getArr.push('value='+encodeURIComponent(value));
new Ajax.Request('/xml-rpc?method=setconfig&' + getArr.join('&'), getArr.push('verify_only=1');
getString = '/xml-rpc?method=setconfig&' + getArr.join('&');
} else {
getString = '/xml-rpc?method=updateconfig&' + Form.Element.serialize(id);
}
var output = id + '=' + value;
new Ajax.Request(getString,
{method: 'get', {method: 'get',
onComplete: function(req){ onComplete: function(req){
var errorString = Element.textContent(req.responseXML.getElementsByTagName('statusstring')[0]); var errorString = Element.textContent(req.responseXML.getElementsByTagName('statusstring')[0]);
@ -443,6 +453,7 @@ function saveForm() {
console.log(output + ' => ' + errorString); console.log(output + ' => ' + errorString);
} }
}}); }});
} }
} }