From fe135f33f6c817b96ff0f59f93c1040a087491e8 Mon Sep 17 00:00:00 2001 From: Christopher Lenz Date: Wed, 14 Jan 2009 16:48:07 +0000 Subject: Allow modification of existing config option values from Futon. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@734443 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/jquery.couch.js | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'share/www/script/jquery.couch.js') diff --git a/share/www/script/jquery.couch.js b/share/www/script/jquery.couch.js index 915918d8..f3547b8d 100644 --- a/share/www/script/jquery.couch.js +++ b/share/www/script/jquery.couch.js @@ -33,8 +33,23 @@ }, config: function(options, section, option, value) { + options = options || {}; + var url = "/_config/"; + if (section) { + url += encodeURIComponent(section) + "/"; + if (option) { + url += encodeURIComponent(option); + } + } + if (value === undefined) { + var method = "GET"; + } else { + var method = "PUT"; + var data = toJSON(value); + } $.ajax({ - type: "GET", url: "/_config/", + type: method, url: url, contentType: "application/json", + dataType: "json", data: toJSON(value), processData: false, complete: function(req) { var resp = $.httpData(req, "json"); if (req.status == 200) { @@ -42,8 +57,8 @@ } else if (options.error) { options.error(req.status, resp.error, resp.reason); } else { - alert("An error occurred retrieving the server configuration: " + - resp.reason); + alert("An error occurred retrieving/updating the server " + + "configuration: " + resp.reason); } } }); @@ -76,7 +91,7 @@ options = options || {}; $.ajax({ type: "PUT", url: this.uri, contentType: "application/json", - dataType: "json", data: "", processData: false, + dataType: "json", data: "", processData: false, complete: function(req) { var resp = $.httpData(req, "json"); if (req.status == 201) { -- cgit v1.2.3