Skip to content

Commit

Permalink
fix for page navigation bar
Browse files Browse the repository at this point in the history
  • Loading branch information
Orbiter committed Mar 21, 2014
1 parent deae992 commit f0f22e6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 46 deletions.
13 changes: 8 additions & 5 deletions htroot/js/yacysearch.js
Expand Up @@ -31,12 +31,15 @@ function statistics(offset, itemscount, itemsperpage, totalcount, localResourceS
if (document.getElementById("remotePeerCount") != null) document.getElementById("remotePeerCount").firstChild.nodeValue = remotePeerCount;
// compose page navigation

var percent = 100 * (itemscount - offset + 1) / itemsperpage;
if (percent == 100) {
window.setTimeout(fadeOutBar, 500);
document.getElementById("progressbar").setAttribute('class',"progress-bar progress-bar-success");
if (document.getElementById("progressbar").getAttribute('class') != "progress-bar progress-bar-success") {
var percent = 100 * (itemscount - offset + 1) / itemsperpage;
if (percent == 100) {
document.getElementById("progressbar").setAttribute('style',"transition:transform 0s;");
document.getElementById("progressbar").setAttribute('class',"progress-bar progress-bar-success");
window.setTimeout(fadeOutBar, 500);
}
document.getElementById("progressbar").setAttribute('style',"width:" + percent + "%");
}
document.getElementById("progressbar").setAttribute('style',"width:" + percent + "%");

var resnav = "<ul class=\"pagination\">";
thispage = Math.floor(offset / itemsperpage);
Expand Down
6 changes: 3 additions & 3 deletions htroot/yacysearch.html
Expand Up @@ -208,13 +208,11 @@ <h4 class="linktitle">
#(resultTable)#::</table>#(/resultTable)#
<!-- linklist end -->

<!-- attach the bottomline (customer option) -->
<!--#(pageNavBottom)#::<div id="pageNavBottom" style="text-align:center">#[resnav]#</div>#(/pageNavBottom)#-->
#(num-results)#
::
::
::
<span id="resNav" style="display: inline;">#[resnav]#</span>
<span id="resNav" style="display: inline;"></span>
</div>
::
#(/num-results)#
Expand Down Expand Up @@ -254,6 +252,8 @@ <h4 class="linktitle">
};
self.xmlHttpReq.send(null);
}
window.setTimeout('latestinfo();',500); // we need that to get a correct pagination bar at the end of the page
window.setTimeout('latestinfo();',1000);
// TODO: resets statistic on navigating to next page in Jetty implementation
/*
window.setTimeout('latestinfo();',500);
Expand Down
38 changes: 0 additions & 38 deletions htroot/yacysearch.java
Expand Up @@ -830,44 +830,6 @@ public static serverObjects respond(
prop.put("num-results_globalresults_remoteIndexCount", Formatter.number(theSearch.remote_rwi_available.get() + theSearch.remote_solr_available.get(), true));
prop.put("num-results_globalresults_remotePeerCount", Formatter.number(theSearch.remote_rwi_peerCount.get() + theSearch.remote_solr_peerCount.get(), true));

// compose page navigation
final StringBuilder resnav = new StringBuilder(200);
resnav.append("<ul class=\"pagination\">");
final int thispage = startRecord / theQuery.itemsPerPage();
if (thispage == 0) {
resnav.append("<li class=\"disabled\"><a href=\"#\">&laquo;</a></li>");
} else {
resnav.append("<li><a id=\"prevpage\" href=\"");
resnav.append(QueryParams.navurl("html", thispage - 1, theQuery, null).toString());
resnav.append("\">&laquo;</a></li>");
}

final int numberofpages = Math.min(10, 1 + ((theSearch.getResultCount() - 1) / theQuery.itemsPerPage()));
for (int i = 0; i < numberofpages; i++) {
if (i == thispage) {
resnav.append("<li class=\"active\"><a href=\"#\">");
resnav.append(i + 1);
resnav.append("</a></li>");
} else {
resnav.append("<li><a href=\"");
resnav.append(QueryParams.navurl("html", i, theQuery, null).toString());
resnav.append("\">" + (i + 1) + "</a></li>");
}
}
if (thispage >= numberofpages) {
resnav.append("<li><a href=\"#\">&raquo;</a></li>");
} else {
resnav.append("<li><a id=\"nextpage\" href=\"");
resnav.append(QueryParams.navurl("html", thispage + 1, theQuery, null).toString());
resnav.append("\">&raquo;</a>");
}
resnav.append("</ul>");
final String resnavs = resnav.toString();

prop.put("num-results_resnav", resnavs);
prop.put("pageNavBottom", (theSearch.getResultCount() - startRecord > 6) ? 1 : 0); // if there are more results than may fit on the page we add a navigation at the bottom
prop.put("pageNavBottom_resnav", resnavs);

// generate the search result lines; the content will be produced by another servlet
for ( int i = 0; i < theQuery.itemsPerPage(); i++ ) {
prop.put("results_" + i + "_item", startRecord + i);
Expand Down

0 comments on commit f0f22e6

Please sign in to comment.