From: Sebastian Hammer Date: Tue, 16 Jan 2007 19:42:20 +0000 (+0000) Subject: Hyperlink searching off author and subject field in full view X-Git-Tag: stable.27032007~87 X-Git-Url: http://git.indexdata.com/?a=commitdiff_plain;h=d5691695e6a22fc0db9c9bffc9ed6f85e908d8c1;p=pazpar2-moved-to-github.git Hyperlink searching off author and subject field in full view --- diff --git a/src/pazpar2.c b/src/pazpar2.c index 93be2e3..ef6e054 100644 --- a/src/pazpar2.c +++ b/src/pazpar2.c @@ -1,4 +1,4 @@ -/* $Id: pazpar2.c,v 1.37 2007-01-16 18:44:25 adam Exp $ */ +/* $Id: pazpar2.c,v 1.38 2007-01-16 19:42:20 quinn Exp $ */ #include #include @@ -1550,7 +1550,8 @@ int main(int argc, char **argv) " -h [host:]port (REST protocol listener)\n" " -C cclconfig\n" " -s simpletargetfile\n" - " -p hostname[:portno] (HTTP proxy)\n"); + " -p hostname[:portno] (HTTP proxy)\n" + " -d (show internal records)\n"); exit(1); } } diff --git a/www/demo/search.js b/www/demo/search.js index 40c418f..feed8f8 100644 --- a/www/demo/search.js +++ b/www/demo/search.js @@ -1,4 +1,4 @@ -/* $Id: search.js,v 1.31 2007-01-16 19:24:44 quinn Exp $ +/* $Id: search.js,v 1.32 2007-01-16 19:42:20 quinn Exp $ * --------------------------------------------------- * Javascript container */ @@ -226,6 +226,16 @@ function displayname(name) return name; } +function hyperlink_field(name) +{ + if (name == 'md-author') + return 'au'; + else if (name == 'md-subject') + return 'su'; + else + return 0; +} + function paint_details_tr(name, dn) { //emit a table row @@ -243,6 +253,7 @@ function paint_details_tr(name, dn) function paint_details(body, xml) { + // This is some ugly display code. Replace with your own ting o'beauty clear_cell(body); //body.appendChild(document.createElement('br')); var nodes = xml.childNodes[0].childNodes; @@ -273,8 +284,19 @@ function paint_details(body, xml) continue; var value = nodes[i].childNodes[0].nodeValue; if (dn.childNodes[0]) - value = '; ' + value; - var nv = document.createTextNode(value); + dn.appendChild(document.createTextNode('; ')); + var hyl = hyperlink_field(name); + var nv; + if (hyl) + { + nv = create_element('a', value); + nv.setAttribute('href', '#'); + nv.setAttribute('term', value); + nv.setAttribute('searchfield', hyl); + nv.onclick = function() { hyperlink_search(this); return false; }; + } + else + nv = document.createTextNode(value); dn.appendChild(nv); } if (dn) @@ -300,8 +322,6 @@ function show_details() return; } - // This is some ugly display code. Replace with your own ting o'beauty - var idn = xml.getElementsByTagName('recid'); if (!idn[0]) return; @@ -315,8 +335,9 @@ function show_details() paint_details(body, xml); } -function hyperlink_search(field, obj) +function hyperlink_search(obj) { + var field = obj.getAttribute('searchfield'); var term = obj.getAttribute('term'); var queryfield = document.getElementById('query'); queryfield.value = field + '=' + term; @@ -423,7 +444,8 @@ function show_records() var al = create_element('a', author); al.setAttribute('href', '#'); al.setAttribute('term', author); - al.onclick = function() { hyperlink_search('au', this); return false; }; + al.setAttribute('searchfield', 'au'); + al.onclick = function() { hyperlink_search(this); return false; }; record_div.appendChild(al); } if (count > 1)