//timers
__myself.statTime = paramArray.stattime || 2000;
__myself.statTimer = null;
- __myself.termTime = paramArray.termtime || 1000;
+ __myself.termTime = paramArray.termtime || 2000;
__myself.termTimer = null;
- __myself.showTime = paramArray.showtime || 1000;
+ __myself.showTime = paramArray.showtime || 2000;
__myself.showTimer = null;
__myself.bytargetTime = paramArray.bytargettime || 1000;
__myself.bytargetTimer = null;
if ( __myself.statCallback )
__myself.statTimer = setTimeout("__myself.stat()", __myself.statTime / 2);
if ( __myself.termlistCallback )
- __myself.termTimer = setTimeout("__myself.termlist()", __myself.termTime / 2);
+ __myself.termlist();
+ //__myself.termTimer = setTimeout("__myself.termlist()", __myself.termTime / 2);
if ( __myself.bytargetCallback )
__myself.bytargetTimer = setTimeout("__myself.bytarget()", __myself.bytargetTime / 2);
}
var step = page || 1;
var newStart = __myself.currentStart - (step * __myself.currentNum );
__myself.show( newStart > 0 ? newStart : 0 );
+ },
+ showPage: function(pageNum)
+ {
+ //var page = pageNum || 1;
+ __myself.show(pageNum * __myself.currentNum);
}
};
}
<h2>Limit your search by:</h2>
</div>
</div>
- <div class="margin">
+ <div class="margin" style="padding-top: 15px;">
<div id="termlists"></div>
</div>
</div>
<div class="content" style="display: none">
- <div class="results">
- Sort results by:
- <select name="sort">
- <option value="relevance">Relevance</option>
- <option value="title">Title</option>
+ <div class="head"><div class="margin"><div class="sortBox">
+ Sort by
+ <select name="sort" id="sort">
+ <option value="relevance" selected="true">relevance</option>
+ <option value="title">title</option>
</select>
- <div class="showing"> </div>
- <div class="pages"> </div>
+ and show
+ <select name="perpage" id="perpage">
+ <option value="15">15</option>
+ <option value="20" selected="true">20</option>
+ <option value="30">30</option>
+ <option value="50">50</option>
+ </select>
+ results per page.
</div>
+ <div class="showing"> </div></div></div>
+ <div class="bottom"><div class="pages"> </div></div>
<br />
<br />
<div class="records"></div>
var currentSort = 'relevance';
var currentResultsPerPage = 20;
var currentQuery = null;
+var currentPage = 0;
var currentDetailedId = null;
var currentDetailedData = null;
function onFormSubmitEventHandler() {
currentQuery = document.search.query.value;
+ $('#sort').change(function(){
+ currentSort = this.value;
+ currentPage = 0;
+ my_paz.show(0, currentResultsPerPage, currentSort);
+ });
+ $('#perpage').change(function(){
+ currentResultsPerPage = this.value;
+ currentPage = 0;
+ my_paz.show(0, currentResultsPerPage, currentSort);
+ });
my_paz.search(document.search.query.value, 20, 'relevance');
$('div.content').show();
$("div.leftbar").show();
//
function my_onshow(data)
{
+ global = data;
var recsBody = $('div.records');
recsBody.empty();
var id = data.hits[i].recid;
var count = data.hits[i].count || 1;
- recsBody.append('<div class="resultNum">'+(i+1)+'.</a>');
-
- var recBody = $('<div class="record" id="rec_'+id+'></div>').appendTo(recsBody);
+ var recBody = $('<div class="record" id="rec_'+id+'></div>');
var aTitle = $('<a class="recTitle">'+title+'</a>').appendTo(recBody);
aTitle.click(function(){
var clickedId = this.parentNode.id.split('_')[1];
var detailBox = $('<div class="detail"></div>').appendTo(recBody);
drawDetailedRec(detailBox);
}
+
+ recsBody.append('<div class="resultNum">'+(currentPage*currentResultsPerPage+i+1)+'.</a>');
+ recsBody.append(recBody);
+
}
+
+ drawPager(data.merged, data.total);
}
/*
for(var i = 0; i < data[key].length; i++){
if (key == "xtargets"){
var listItem = $('<a class="sub" name="xtarget" value="'+data[key][i].id+'">'+data[key][i].name+
- '<span> ('+data[key][i].freq+')</span></a>').appendTo(listEntries);
- listItem.click(function(){
- refine(this.name, this.attributes[0].nodeValue) });
+ '<span> ('+data[key][i].freq+')</span></a>').click(function(){
+ refine(this.name, this.attributes[0].nodeValue) });
+ listItem.appendTo(listEntries);
} else {
var listItem = $('<a class="sub" name="'+key+'">'+data[key][i].name+
- '<span> ('+data[key][i].freq+')</span></a>').appendTo(listEntries);
- listItem.click(function(){ refine(this.name, this.firstChild.nodeValue) });
+ '<span> ('+data[key][i].freq+')</span></a>').click(function(){
+ refine(this.name, this.firstChild.nodeValue) });
+ listItem.appendTo(listEntries);
}
}
}
case "subject": query = ' and su="'+value+'"'; break;
case "xtarget": filter = 'id='+value; break;
}
-
+
+ currentPage = 0;
my_paz.search(currentQuery + query, currentResultsPerPage, currentSort, filter);
}
+
+function drawPager(max, hits)
+{
+ var firstOnPage = currentPage * currentResultsPerPage + 1;
+ var lastOnPage = (firstOnPage + currentResultsPerPage - 1) < max ? (firstOnPage + currentResultsPerPage - 1) : max;
+
+ var results = $('div.showing');
+ results.empty();
+ results.append('Displaying: <b>'+firstOnPage+'</b> to <b>'+lastOnPage+
+ '</b> of <b>'+max+'</b>'); //(total hits: '+hits+')');
+ var pager = $('div.pages');
+ pager.empty();
+
+ if ( currentPage > 0 ){
+ $('<a class="previous_active">Previous</a>').click(function() { my_paz.showPrev(1); currentPage--; }).appendTo(pager.eq(0));
+ $('<a class="previous_active">Previous</a>').click(function() { my_paz.showPrev(1); currentPage--; }).appendTo(pager.eq(1));
+ }
+ else
+ pager.append('<a class="previous_inactive">Previous</a>');
+
+ var numPages = Math.ceil(max / currentResultsPerPage);
+
+ for(var i = 1; i <= numPages; i++)
+ {
+ if( i == (currentPage + 1) ){
+ $('<a class="select">'+i+'</a>').appendTo(pager);
+ continue;
+ }
+ var pageLink = $('<a class="page">'+i+'</a>');
+ var plClone = pageLink.clone();
+
+ pageLink.click(function() {
+ my_paz.showPage(this.firstChild.nodeValue - 1);
+ currentPage = (this.firstChild.nodeValue - 1);
+ });
+
+ plClone.click(function() {
+ my_paz.showPage(this.firstChild.nodeValue - 1);
+ currentPage = (this.firstChild.nodeValue - 1);
+ });
+
+ //nasty hack
+ pager.eq(0).append(pageLink);
+ pager.eq(1).append(plClone);
+ }
+
+ if ( currentPage < (numPages-1) ){
+ $('<a class="next_active">Next</a>').click(function() { my_paz.showNext(1); currentPage++; }).appendTo(pager.eq(0));
+ $('<a class="next_active">Next</a>').click(function() { my_paz.showNext(1); currentPage++; }).appendTo(pager.eq(1));
+ }
+ else
+ pager.append('<a class="next_inactive">Next</a>');
+}