From 62c3ac542a997900ecad9c95b036db400a977c51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Betn=C3=A9r?= Date: Mon, 29 May 2006 20:00:58 +0000 Subject: [PATCH] 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 --- admin-root/config.js | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/admin-root/config.js b/admin-root/config.js index 82c039a9..5957fb3d 100644 --- a/admin-root/config.js +++ b/admin-root/config.js @@ -9,6 +9,7 @@ Event.observe(window,'load',init); // Config isn't defined until after the Event.observe above // I could have put it below Config = ... but I want all window.load events // at the start of the file +var DEBUG = window.location.toString().match(/debug/); function init() { Config.init(); @@ -387,9 +388,15 @@ function saved(req) { function saveForm() { var postVars = []; var multiple = {}; + $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) { if (ConfigXML.getOptionFromElementName(input.name).multiple) { if (multiple[input.name]) { @@ -398,16 +405,43 @@ function saveForm() { multiple[input.name] = [input.value]; } } 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) { - 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', {method: 'post', parameters: postVars.join('&'), 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() { ConfigXML.getSections().each(function (section){