forked from I2P_Developers/i2p.i2p
* i2psnark: Improve page nav
This commit is contained in:
@ -547,7 +547,9 @@ public class SnarkManager implements CompleteListener {
|
||||
int size = Integer.parseInt(pageSize.trim());
|
||||
if (size <= 0)
|
||||
size = 999999;
|
||||
if (size != getPageSize() && size >= 5) {
|
||||
else if (size < 5)
|
||||
size = 5;
|
||||
if (size != getPageSize()) {
|
||||
changed = true;
|
||||
pageSize = Integer.toString(size);
|
||||
_config.setProperty(PROP_PAGE_SIZE, pageSize);
|
||||
|
@ -522,23 +522,60 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
} else /** if (snarks.size() > 1) */ {
|
||||
out.write("<tfoot><tr>\n" +
|
||||
" <th align=\"left\" colspan=\"6\">");
|
||||
// Page nav
|
||||
if (start > 0) {
|
||||
int prev = Math.max(0, start - pageSize);
|
||||
out.write(" <a href=\"" + _contextPath + "?st=" + prev);
|
||||
// First
|
||||
out.write(" <a href=\"" + _contextPath);
|
||||
if (peerParam != null)
|
||||
out.write("&p=" + peerParam);
|
||||
out.write("?p=" + peerParam);
|
||||
out.write("\">" +
|
||||
"<img alt=\"" + _("Prev") + "\" title=\"" + _("Previous page") + "\" border=\"0\" src=\"" +
|
||||
"<img alt=\"" + _("First") + "\" title=\"" + _("First page") + "\" border=\"0\" src=\"" +
|
||||
_imgPath + "control_rewind_blue.png\">" +
|
||||
"</a> ");
|
||||
int prev = Math.max(0, start - pageSize);
|
||||
if (prev > 0) {
|
||||
// Back
|
||||
out.write(" <a href=\"" + _contextPath + "?st=" + prev);
|
||||
if (peerParam != null)
|
||||
out.write("&p=" + peerParam);
|
||||
out.write("\">" +
|
||||
"<img alt=\"" + _("Prev") + "\" title=\"" + _("Previous page") + "\" border=\"0\" src=\"" +
|
||||
_imgPath + "control_back_blue.png\">" +
|
||||
"</a> ");
|
||||
}
|
||||
}
|
||||
if (start + pageSize < snarks.size()) {
|
||||
// Page count
|
||||
int total = snarks.size();
|
||||
int pages = 1 + (total / pageSize);
|
||||
if (pages == 1 && start > 0)
|
||||
pages = 2;
|
||||
if (pages > 1) {
|
||||
int page;
|
||||
if (start + pageSize >= total)
|
||||
page = pages;
|
||||
else
|
||||
page = 1 + (start / pageSize);
|
||||
out.write(" " + _("Page {0}", page) + thinsp(noThinsp) + pages + " ");
|
||||
}
|
||||
if (start + pageSize < total) {
|
||||
int next = start + pageSize;
|
||||
out.write(" <a href=\"" + _contextPath + "?st=" + next);
|
||||
if (next + pageSize < total) {
|
||||
// Next
|
||||
out.write(" <a href=\"" + _contextPath + "?st=" + next);
|
||||
if (peerParam != null)
|
||||
out.write("&p=" + peerParam);
|
||||
out.write("\">" +
|
||||
"<img alt=\"" + _("Next") + "\" title=\"" + _("Next page") + "\" border=\"0\" src=\"" +
|
||||
_imgPath + "control_play_blue.png\">" +
|
||||
"</a> ");
|
||||
}
|
||||
// Last
|
||||
int last = ((total - 1) / pageSize) * pageSize;
|
||||
out.write(" <a href=\"" + _contextPath + "?st=" + last);
|
||||
if (peerParam != null)
|
||||
out.write("&p=" + peerParam);
|
||||
out.write("\">" +
|
||||
"<img alt=\"" + _("Next") + "\" title=\"" + _("Next page") + "\" border=\"0\" src=\"" +
|
||||
"<img alt=\"" + _("Last") + "\" title=\"" + _("Last page") + "\" border=\"0\" src=\"" +
|
||||
_imgPath + "control_fastforward_blue.png\">" +
|
||||
"</a> ");
|
||||
}
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 807 B |
Binary file not shown.
After Width: | Height: | Size: 717 B |
Binary file not shown.
After Width: | Height: | Size: 807 B |
Binary file not shown.
After Width: | Height: | Size: 717 B |
Binary file not shown.
After Width: | Height: | Size: 807 B |
Binary file not shown.
After Width: | Height: | Size: 717 B |
Reference in New Issue
Block a user