Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
trimmed trailing whitespace
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@791350 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
norosa committed Jul 6, 2009
1 parent d47faa5 commit 05e0d7401a6b51aa416b4241e56d704c97a9f8b3
Showing 43 changed files with 473 additions and 474 deletions.
@@ -26,7 +26,7 @@
<script src="script/futon.js?0.9.0"></script>
<script src="script/couch_test_runner.js"></script>
<script>
$(function() {
$(function() {
updateTestsListing();
$("#toolbar button.run").click(runAllTests);
$("#toolbar button.load").click(function() {
@@ -17,7 +17,7 @@ <h2>Compact Database</h2>
<fieldset>
<p class="help">
Compacting a database removes deleted documents and previous revisions.
It is an <strong>irreversible operation</strong> and my take
It is an <strong>irreversible operation</strong> and my take
a while to complete for large databases.
</p>
</fieldset>
@@ -16,11 +16,11 @@
function CouchDB(name, httpHeaders) {
this.name = name;
this.uri = "/" + encodeURIComponent(name) + "/";

// The XMLHttpRequest object from the most recent request. Callers can
// use this to check result http status and headers.
this.last_req = null;

this.request = function(method, uri, requestOptions) {
requestOptions = requestOptions || {}
requestOptions.headers = combine(requestOptions.headers, httpHeaders)
@@ -48,7 +48,7 @@ function CouchDB(name, httpHeaders) {
if (doc._id == undefined)
doc._id = CouchDB.newUuids(1)[0];

this.last_req = this.request("PUT", this.uri +
this.last_req = this.request("PUT", this.uri +
encodeURIComponent(doc._id) + encodeOptions(options),
{body: JSON.stringify(doc)});
CouchDB.maybeThrowError(this.last_req);
@@ -84,7 +84,7 @@ function CouchDB(name, httpHeaders) {
doc._rev = result.rev; //record rev in input document
return result;
}

this.bulkSave = function(docs, options) {
// first prepoulate the UUIDs for new documents
var newCount = 0
@@ -119,7 +119,7 @@ function CouchDB(name, httpHeaders) {
return results;
}
}

this.ensureFullCommit = function() {
this.last_req = this.request("POST", this.uri + "_ensure_full_commit");
CouchDB.maybeThrowError(this.last_req);
@@ -130,7 +130,7 @@ function CouchDB(name, httpHeaders) {
this.query = function(mapFun, reduceFun, options, keys) {
var body = {language: "javascript"};
if(keys) {
body.keys = keys ;
body.keys = keys ;
}
if (typeof(mapFun) != "string")
mapFun = mapFun.toSource ? mapFun.toSource() : "(" + mapFun.toString() + ")";
@@ -154,15 +154,15 @@ function CouchDB(name, httpHeaders) {

this.view = function(viewname, options, keys) {
var viewParts = viewname.split('/');
var viewPath = this.uri + "_design/" + viewParts[0] + "/_view/"
var viewPath = this.uri + "_design/" + viewParts[0] + "/_view/"
+ viewParts[1] + encodeOptions(options);
if(!keys) {
this.last_req = this.request("GET", viewPath);
this.last_req = this.request("GET", viewPath);
} else {
this.last_req = this.request("POST", viewPath, {
headers: {"Content-Type": "application/json"},
body: JSON.stringify({keys:keys})
});
});
}
if (this.last_req.status == 404)
return null;
@@ -183,7 +183,7 @@ function CouchDB(name, httpHeaders) {
CouchDB.maybeThrowError(this.last_req);
return JSON.parse(this.last_req.responseText);
}

this.viewCleanup = function() {
this.last_req = this.request("POST", this.uri + "_view_cleanup");
CouchDB.maybeThrowError(this.last_req);
@@ -192,30 +192,30 @@ function CouchDB(name, httpHeaders) {

this.allDocs = function(options,keys) {
if(!keys) {
this.last_req = this.request("GET", this.uri + "_all_docs" + encodeOptions(options));
this.last_req = this.request("GET", this.uri + "_all_docs" + encodeOptions(options));
} else {
this.last_req = this.request("POST", this.uri + "_all_docs" + encodeOptions(options), {
headers: {"Content-Type": "application/json"},
body: JSON.stringify({keys:keys})
});
});
}
CouchDB.maybeThrowError(this.last_req);
return JSON.parse(this.last_req.responseText);
}

this.designDocs = function() {
return this.allDocs({startkey:"_design", endkey:"_design0"});
};

this.allDocsBySeq = function(options,keys) {
var req = null;
if(!keys) {
req = this.request("GET", this.uri + "_all_docs_by_seq" + encodeOptions(options));
req = this.request("GET", this.uri + "_all_docs_by_seq" + encodeOptions(options));
} else {
req = this.request("POST", this.uri + "_all_docs_by_seq" + encodeOptions(options), {
headers: {"Content-Type": "application/json"},
body: JSON.stringify({keys:keys})
});
});
}
CouchDB.maybeThrowError(req);
return JSON.parse(req.responseText);
@@ -226,35 +226,35 @@ function CouchDB(name, httpHeaders) {
CouchDB.maybeThrowError(this.last_req);
return JSON.parse(this.last_req.responseText);
}

this.setDbProperty = function(propId, propValue) {
this.last_req = this.request("PUT", this.uri + propId,{
body:JSON.stringify(propValue)
});
CouchDB.maybeThrowError(this.last_req);
return JSON.parse(this.last_req.responseText);
}

this.getDbProperty = function(propId) {
this.last_req = this.request("GET", this.uri + propId);
CouchDB.maybeThrowError(this.last_req);
return JSON.parse(this.last_req.responseText);
}

this.setAdmins = function(adminsArray) {
this.last_req = this.request("PUT", this.uri + "_admins",{
body:JSON.stringify(adminsArray)
});
CouchDB.maybeThrowError(this.last_req);
return JSON.parse(this.last_req.responseText);
}

this.getAdmins = function() {
this.last_req = this.request("GET", this.uri + "_admins");
CouchDB.maybeThrowError(this.last_req);
return JSON.parse(this.last_req.responseText);
}

// Convert a options object to an url query string.
// ex: {key:'value',key2:'value2'} becomes '?key="value"&key2="value2"'
function encodeOptions(options) {
@@ -278,26 +278,26 @@ function CouchDB(name, httpHeaders) {
function toJSON(obj) {
return obj !== null ? JSON.stringify(obj) : null;
}

function combine(object1, object2) {
if (!object2)
return object1;
if (!object1)
return object2;

for (var name in object2)
object1[name] = object2[name];

return object1;
}


}

// this is the XMLHttpRequest object from last request made by the following
// CouchDB.* functions (except for calls to request itself).
// Use this from callers to check HTTP status or header values of requests.
CouchDB.last_req = null;
CouchDB.last_req = null;


CouchDB.allDbs = function() {
@@ -12,7 +12,7 @@

// *********************** Test Framework of Sorts ************************* //

function loadScript(url) {
function loadScript(url) {
if (typeof document != "undefined") document.write('<script src="'+url+'"></script>');
};

@@ -49,7 +49,7 @@
var dbsOnPage = dbs.slice(offset, offset + maxPerPage);

$.each(dbsOnPage, function(idx, dbName) {
$("#databases tbody.content").append("<tr>" +
$("#databases tbody.content").append("<tr>" +
"<th><a href='database.html?" + encodeURIComponent(dbName) + "'>" +
dbName + "</a></th>" +
"<td class='size'></td><td class='count'></td>" +
@@ -504,7 +504,7 @@
resp.rows = resp.rows.reverse();
}
var has_reduce_prev = resp.total_rows === undefined && (descending_reverse ? resp.rows.length > per_page : options.startkey !== undefined);
if (resp.rows !== null && (has_reduce_prev || (descending_reverse ?
if (resp.rows !== null && (has_reduce_prev || (descending_reverse ?
(resp.total_rows - resp.offset > per_page) :
(resp.offset > 0)))) {
$("#paging a.prev").attr("href", "#" + (resp.offset - per_page)).click(function() {
@@ -527,8 +527,8 @@
$("#paging a.prev").removeAttr("href");
}
var has_reduce_next = resp.total_rows === undefined && (descending_reverse ? options.startkey !== undefined : resp.rows.length > per_page);
if (resp.rows !== null && (has_reduce_next || (descending_reverse ?
(resp.offset - resp.total_rows < per_page) :
if (resp.rows !== null && (has_reduce_next || (descending_reverse ?
(resp.offset - resp.total_rows < per_page) :
(resp.total_rows - resp.offset > per_page)))) {
$("#paging a.next").attr("href", "#" + (resp.offset + per_page)).click(function() {
var opt = {
@@ -967,16 +967,16 @@
}

function _renderAttachmentItem(name, attachment) {
var attachmentHref = db.uri + encodeDocId(docId)
var attachmentHref = db.uri + encodeDocId(docId)
+ "/" + encodeAttachment(name);
var li = $("<li></li>");
$("<a href='' title='Download file' target='_top'></a>").text(name)
.attr("href", attachmentHref)
.wrapInner("<tt></tt>").appendTo(li);
$("<span>()</span>").text("" + $.futon.formatSize(attachment.length) +
$("<span>()</span>").text("" + $.futon.formatSize(attachment.length) +
", " + attachment.content_type).addClass("info").appendTo(li);
if (name == "tests.js") {
li.find('span.info').append(', <a href="/_utils/couch_tests.html?'
li.find('span.info').append(', <a href="/_utils/couch_tests.html?'
+ attachmentHref + '">open in test runner</a>');
}
_initAttachmentItem(name, attachment, li);
@@ -92,7 +92,7 @@
$.ajax({
type: "POST", url: this.uri + "_compact",
contentType: "application/json",
dataType: "json", data: "", processData: false,
dataType: "json", data: "", processData: false,
complete: function(req) {
var resp = $.httpData(req, "json");
if (req.status == 202) {
@@ -200,7 +200,7 @@
});
});
}
});
});
} else {
alert("please provide an eachApp function for allApps()");
}

0 comments on commit 05e0d74

Please sign in to comment.