From 3132843214251e3a68b7b3fe89618d323dffa546 Mon Sep 17 00:00:00 2001 From: John Christopher Anderson Date: Mon, 9 Feb 2009 01:00:33 +0000 Subject: row_info object for _list pagination. Thanks benoitc. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@742220 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/couch_tests.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'share/www/script/couch_tests.js') diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js index dd070958..2df262d7 100644 --- a/share/www/script/couch_tests.js +++ b/share/www/script/couch_tests.js @@ -2677,13 +2677,13 @@ db.createDb(); } }, lists: { - simpleForm: stringFun(function(head, row, req, row_number) { + simpleForm: stringFun(function(head, row, req, row_info) { if (row) { // we ignore headers on rows and tail return { body : '\n
  • Key: '+row.key +' Value: '+row.value - +' LineNo: '+row_number+'
  • ' + +' LineNo: '+row_info.row_number+'' }; } else if (head) { // we return an object (like those used by external and show) @@ -2696,10 +2696,12 @@ db.createDb(); }; } else { // tail - return {body : ''}; + return {body : ''+ + '

    FirstKey: '+row_info.first_key+ + ' LastKey: '+row_info.prev_key+'

    '}; } }), - acceptSwitch: stringFun(function(head, row, req, row_number) { + acceptSwitch: stringFun(function(head, row, req, row_info) { return respondWith(req, { html : function() { // If you're outputting text and you're not setting @@ -2709,9 +2711,10 @@ db.createDb(); } else if (row) { return '\n
  • Key: ' +row.key+' Value: '+row.value - +' LineNo: '+row_number+'
  • '; + +' LineNo: '+row_info.row_number+''; } else { // tail - return ""; + return ''; + } }, xml : function() { @@ -2754,6 +2757,9 @@ db.createDb(); T(/Key: 1/.test(xhr.responseText)); T(/LineNo: 0/.test(xhr.responseText)); T(/LineNo: 5/.test(xhr.responseText)); + T(/FirstKey: 0/.test(xhr.responseText)); + T(/LastKey: 9/.test(xhr.responseText)); + var lines = xhr.responseText.split('\n'); T(/LineNo: 5/.test(lines[6])); @@ -2763,6 +2769,9 @@ db.createDb(); T(xhr.status == 200); T(/Total Rows/.test(xhr.responseText)); T(!(/Key: 1/.test(xhr.responseText))); + T(/FirstKey: 3/.test(xhr.responseText)); + T(/LastKey: 9/.test(xhr.responseText)); + // with 0 rows var xhr = CouchDB.request("GET", "/test_suite_db/_list/lists/simpleForm/basicView?startkey=30"); -- cgit v1.2.3