summaryrefslogtreecommitdiff
path: root/share/www/script
diff options
context:
space:
mode:
Diffstat (limited to 'share/www/script')
-rw-r--r--share/www/script/browse.js5
-rw-r--r--share/www/script/pprint.js16
2 files changed, 18 insertions, 3 deletions
diff --git a/share/www/script/browse.js b/share/www/script/browse.js
index c1127608..927f110d 100644
--- a/share/www/script/browse.js
+++ b/share/www/script/browse.js
@@ -41,8 +41,9 @@ function CouchIndexPage() {
var info = new CouchDB(dbName).info();
$("#databases tbody.content").append(
"<tr><th><a href='database.html?" + dbName + "'>" +
- dbName + "</a></th><td>" + info.doc_count +"</td><td>" +
- info.update_seq + "</td></tr>");
+ dbName + "</a></th><td class='size'>" + prettyPrintSize(info.size) +
+ "</td><td class='count'>" + info.doc_count +
+ "</td><td class='seq'>" + info.update_seq + "</td></tr>");
$("#databases tbody tr:odd").addClass("odd");
$("#databases tbody.footer tr td").text(allDbs.length + " database(s)");
}
diff --git a/share/www/script/pprint.js b/share/www/script/pprint.js
index 981db0f2..1499a128 100644
--- a/share/www/script/pprint.js
+++ b/share/www/script/pprint.js
@@ -10,7 +10,7 @@
// License for the specific language governing permissions and limitations under
// the License.
-/* JSON pretty printing */
+// JSON pretty printing
function prettyPrintJSON(val, indent, linesep, depth) {
indent = indent != null ? indent : 4;
@@ -58,3 +58,17 @@ function prettyPrintJSON(val, indent, linesep, depth) {
}
}
}
+
+// File size pretty printing
+
+function prettyPrintSize(size) {
+ var jump = 512;
+ if (size < jump) return size + " bytes";
+ var units = ["KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
+ var i = 0;
+ while (size >= jump && i < units.length) {
+ i += 1;
+ size /= 1024
+ }
+ return size.toFixed(1) + ' ' + units[i - 1];
+}