diff --git a/attachments/pages/index.html b/attachments/pages/index.html
index 0bea4252..38ea828a 100644
--- a/attachments/pages/index.html
+++ b/attachments/pages/index.html
@@ -88,13 +88,13 @@
diff --git a/attachments/script/removalist.js b/attachments/script/removalist.js
index 41a43d6a..961103d0 100644
--- a/attachments/script/removalist.js
+++ b/attachments/script/removalist.js
@@ -5,7 +5,9 @@ var removalist = function() {
}
function renderRows(rows) {
+
var tableRows = [];
+
rows.map(function(row) {
var cells = [];
app.headers.map(function(header) {
@@ -18,19 +20,22 @@ var removalist = function() {
})
tableRows.push({cells: cells});
})
+
util.render('dataTable', 'dataTableContainer', {
rows: tableRows,
headers: app.headers
})
+
app.newest = rows[0].id;
app.oldest = rows[rows.length - 1].id;
+
}
function getPageSize() {
return parseInt($(".viewpanel-pagesize .selected").text());
}
- function fetchRows(id) {
+ function fetchRows(id, skip) {
var query = {
"limit" : getPageSize()
@@ -41,6 +46,8 @@ var removalist = function() {
if (id !== app.newest) $.extend( query, {"skip": 1});
}
+ if (skip) $.extend( query, {"skip": skip});
+
var req = {url: app.baseURL + 'api/rows?' + $.param(query)};
couch.request(req).then(function(response) {
diff --git a/attachments/script/site.js b/attachments/script/site.js
index 8b1e1f5d..0c16a067 100644
--- a/attachments/script/site.js
+++ b/attachments/script/site.js
@@ -23,7 +23,7 @@ app.routes = {
},
page: function(id) {
- removalist.getPageSize()
+ removalist.getPageSize();
}
}
@@ -35,8 +35,11 @@ app.after = {
removalist.fetchRows(app.newest);
});
$( '.viewpanel-paging a' ).click(function( e ) {
- // var action = $(e.target).attr('id').split('paging-')[1];
- removalist.fetchRows(app.oldest);
+ var action = $(e.target);
+ if (action.hasClass("last")) removalist.fetchRows(false, app.dbInfo.doc_count - removalist.getPageSize());
+ if (action.hasClass("next")) removalist.fetchRows(app.oldest);
+ if (action.hasClass("previous")) removalist.fetchRows(app.oldest);
+ if (action.hasClass("first")) removalist.fetchRows();
});
}