Refactoring of jquery.couch.js
------------------------------
Key: COUCHDB-368
URL: https://issues.apache.org/jira/browse/COUCHDB-368
Project: CouchDB
Issue Type: Improvement
Components: JavaScript View Server
Affects Versions: 0.10
Environment: {"couchdb":"Welcome","version":"0.10.0a780214"}
Reporter: Yoan Blanc
Priority: Minor
When I dived into jquery.couch.js, I saw a lot of repetitions, I tried to
refactor it a little bit, centralizing all (but one) $.ajax into one place
(called ajax).
Before:
allDbs: function(options) {
options = options || {};
$.ajax({
type: "GET", url: "/_all_dbs",
complete: function(req) {
var resp = $.httpData(req, "json");
if (req.status == 200) {
if (options.success) options.success(resp);
} else if (options.error) {
options.error(req.status, resp.error, resp.reason);
} else {
alert("An error occurred retrieving the list of all databases: " +
resp.reason);
}
}
});
},
After:
allDbs: function(options) {
ajax(
{url: "/_all_dbs"},
options,
"An error occurred retrieving the list of all databases"
);
}
Cheers,
--
Yoan
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.