From b1d1bd7c6dbf7af16d5047d91b39827d9a8c4252 Mon Sep 17 00:00:00 2001 From: "Anders S. Mortensen" Date: Mon, 8 Jan 2007 14:51:35 +0000 Subject: [PATCH] Decent pager. --- www/demo/search.js | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/www/demo/search.js b/www/demo/search.js index 41b19b5..6e90aa0 100644 --- a/www/demo/search.js +++ b/www/demo/search.js @@ -1,4 +1,4 @@ -/* $Id: search.js,v 1.7 2007-01-08 11:13:07 sondberg Exp $ +/* $Id: search.js,v 1.8 2007-01-08 14:51:35 sondberg Exp $ * --------------------------------------------------- * Javascript container */ @@ -21,6 +21,7 @@ var session_cells = Array('query', 'startrec', 'action_type'); var old_session = session_read(); var url_surveillence; var recstoshow = 15; +var page_window = 5; // Number of pages prior to and after the current page var facet_list; var cur_facet = 0; @@ -146,7 +147,37 @@ function update_action (new_action) { function make_pager (hits, offset, max) { - return '1 Next'; + var html = ''; + var off; + + for (off = offset - page_window * max; + off < hits && off < (offset + page_window * max); + off += max) { + + var class = ''; + + if (off < 0) + off = 0; + + var p = off / max + 1; + + if ((offset >= off) && (offset < (off + max))) + class = ' class="select"'; + + html += '' + p + '\n'; + } + + return html; +} + + +function update_offset (offset) { + document.search.startrec.value = offset; + update_action('page'); + check_search(); + update_history(); + return false; } @@ -172,7 +203,7 @@ function show_records() var num = Number(xml.getElementsByTagName('num')[0].childNodes[0].nodeValue); var clients = Number(xml.getElementsByTagName("activeclients")[0].childNodes[0].nodeValue); body.innerHTML = '
' + - make_pager(merged, start, 20) + + make_pager(merged, start, recstoshow) + '
'; body.innerHTML += '
Records : ' + (start + 1) + -- 1.7.10.4