X-Git-Url: http://lists.indexdata.dk/cgi-bin?a=blobdiff_plain;f=www%2Fdemo%2Fsearch.js;h=81be27de1f2bac982980f53798500f41d4c3b291;hb=9028635288ffc5ba9706923bc79ac3bddfdf5e68;hp=4c9549903fe9a07d1932d39ed2396915e19d83b1;hpb=f78b3fcf9a7f403cd5382470c99086db29c03053;p=pazpar2-moved-to-github.git diff --git a/www/demo/search.js b/www/demo/search.js index 4c95499..81be27d 100644 --- a/www/demo/search.js +++ b/www/demo/search.js @@ -1,4 +1,4 @@ -/* $Id: search.js,v 1.11 2007-01-10 09:50:57 sondberg Exp $ +/* $Id: search.js,v 1.14 2007-01-10 12:15:46 sondberg Exp $ * --------------------------------------------------- * Javascript container */ @@ -148,6 +148,9 @@ function make_pager (hits, offset, max) { var html = ''; var off; var start_offset = offset - page_window * max; + var div_elem = document.createElement('div'); + + div_elem.className = 'pages'; if (start_offset < 0) { start_offset = 0; @@ -156,22 +159,23 @@ function make_pager (hits, offset, max) { for (off = start_offset; off < hits && off < (start_offset + 2 * page_window * max); off += max) { - - var class = ''; - if (off < 0) - off = 0; - var p = off / max + 1; + var page_elem = create_element('a', p); + var newline_node = document.createTextNode('\n'); - if ((offset >= off) && (offset < (off + max))) - class = ' class="select"'; + if ((offset >= off) && (offset < (off + max))) { + page_elem.className = 'select'; + } - html += '' + p + '\n'; + page_elem.setAttribute('href', '#'); + page_elem.setAttribute('onclick', 'update_offset(' + off + ')'); + + div_elem.appendChild(page_elem); + div_elem.appendChild(newline_node); } - return html; + return div_elem; } @@ -184,6 +188,15 @@ function update_offset (offset) { } +function create_element (name, cdata) { + var elem_node = document.createElement(name); + var text_node = document.createTextNode(cdata); + elem_node.appendChild(text_node); + + return elem_node; +} + + function show_records() { if (xshow.readyState != 4) @@ -192,6 +205,9 @@ function show_records() var xml = xshow.responseXML; var body = document.getElementById("body"); var hits = xml.getElementsByTagName("hit"); + + body.innerHTML = ''; + if (!hits[0]) // We should never get here with blocking operations { body.innerHTML = "No records yet"; @@ -205,46 +221,40 @@ function show_records() var start = Number(xml.getElementsByTagName('start')[0].childNodes[0].nodeValue); var num = Number(xml.getElementsByTagName('num')[0].childNodes[0].nodeValue); var clients = Number(xml.getElementsByTagName("activeclients")[0].childNodes[0].nodeValue); - body.innerHTML = '