forked from I2P_Developers/i2p.i2p
add sort links for details page
fix tooltips on images
This commit is contained in:
@ -2611,6 +2611,10 @@ public class I2PSnarkServlet extends BasicServlet {
|
|||||||
if (showPriority) {
|
if (showPriority) {
|
||||||
buf.append("<form action=\"").append(base).append("\" method=\"POST\">\n");
|
buf.append("<form action=\"").append(base).append("\" method=\"POST\">\n");
|
||||||
buf.append("<input type=\"hidden\" name=\"nonce\" value=\"").append(_nonce).append("\" >\n");
|
buf.append("<input type=\"hidden\" name=\"nonce\" value=\"").append(_nonce).append("\" >\n");
|
||||||
|
if (sortParam != null) {
|
||||||
|
buf.append("<input type=\"hidden\" name=\"sort\" value=\"")
|
||||||
|
.append(DataHelper.stripHTML(sortParam)).append("\" >\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (snark != null) {
|
if (snark != null) {
|
||||||
// first table - torrent info
|
// first table - torrent info
|
||||||
@ -2843,7 +2847,9 @@ public class I2PSnarkServlet extends BasicServlet {
|
|||||||
for (int i = 0; i < ls.length; i++) {
|
for (int i = 0; i < ls.length; i++) {
|
||||||
fileList.add(new Sorters.FileAndIndex(ls[i], storage));
|
fileList.add(new Sorters.FileAndIndex(ls[i], storage));
|
||||||
}
|
}
|
||||||
if (fileList.size() > 1) {
|
|
||||||
|
boolean showSort = fileList.size() > 1;
|
||||||
|
if (showSort) {
|
||||||
int sort = 0;
|
int sort = 0;
|
||||||
if (sortParam != null) {
|
if (sortParam != null) {
|
||||||
try {
|
try {
|
||||||
@ -2858,17 +2864,63 @@ public class I2PSnarkServlet extends BasicServlet {
|
|||||||
buf.append("<tr>\n")
|
buf.append("<tr>\n")
|
||||||
.append("<th colspan=2>");
|
.append("<th colspan=2>");
|
||||||
String tx = _("Directory");
|
String tx = _("Directory");
|
||||||
toThemeImg(buf, "file", tx, tx + ": " + directory);
|
// cycle through sort by name or type
|
||||||
|
String sort;
|
||||||
|
boolean isTypeSort = false;
|
||||||
|
if (showSort) {
|
||||||
|
if (sortParam == null || "0".equals(sortParam) || "1".equals(sortParam)) {
|
||||||
|
sort = "-1";
|
||||||
|
} else if ("-1".equals(sortParam)) {
|
||||||
|
sort = "12";
|
||||||
|
isTypeSort = true;
|
||||||
|
} else if ("12".equals(sortParam)) {
|
||||||
|
sort = "-12";
|
||||||
|
isTypeSort = true;
|
||||||
|
} else {
|
||||||
|
sort = "";
|
||||||
|
}
|
||||||
|
buf.append("<a href=\"").append(base)
|
||||||
|
.append(getQueryString(sort)).append("\">");
|
||||||
|
}
|
||||||
|
toThemeImg(buf, "file", tx,
|
||||||
|
showSort ? _("Sort by {0}", (isTypeSort ? _("File type") : _("Name")))
|
||||||
|
: tx + ": " + directory);
|
||||||
|
if (showSort)
|
||||||
|
buf.append("</a>");
|
||||||
buf.append("</th>\n<th align=\"right\">");
|
buf.append("</th>\n<th align=\"right\">");
|
||||||
|
if (showSort) {
|
||||||
|
sort = ("5".equals(sortParam)) ? "-5" : "5";
|
||||||
|
buf.append("<a href=\"").append(base)
|
||||||
|
.append(getQueryString(sort)).append("\">");
|
||||||
|
}
|
||||||
tx = _("Size");
|
tx = _("Size");
|
||||||
toThemeImg(buf, "size", tx, tx);
|
toThemeImg(buf, "size", tx,
|
||||||
|
showSort ? _("Sort by {0}", tx) : tx);
|
||||||
|
if (showSort)
|
||||||
|
buf.append("</a>");
|
||||||
buf.append("</th>\n<th class=\"headerstatus\">");
|
buf.append("</th>\n<th class=\"headerstatus\">");
|
||||||
|
if (showSort) {
|
||||||
|
sort = ("10".equals(sortParam)) ? "-10" : "10";
|
||||||
|
buf.append("<a href=\"").append(base)
|
||||||
|
.append(getQueryString(sort)).append("\">");
|
||||||
|
}
|
||||||
tx = _("Status");
|
tx = _("Status");
|
||||||
toThemeImg(buf, "status", tx, tx);
|
toThemeImg(buf, "status", tx,
|
||||||
|
showSort ? _("Sort by {0}", _("Remaining")) : tx);
|
||||||
|
if (showSort)
|
||||||
|
buf.append("</a>");
|
||||||
if (showPriority) {
|
if (showPriority) {
|
||||||
buf.append("</th>\n<th class=\"headerpriority\">");
|
buf.append("</th>\n<th class=\"headerpriority\">");
|
||||||
|
if (showSort) {
|
||||||
|
sort = ("13".equals(sortParam)) ? "-13" : "13";
|
||||||
|
buf.append("<a href=\"").append(base)
|
||||||
|
.append(getQueryString(sort)).append("\">");
|
||||||
|
}
|
||||||
tx = _("Priority");
|
tx = _("Priority");
|
||||||
toThemeImg(buf, "priority", tx, tx);
|
toThemeImg(buf, "priority", tx,
|
||||||
|
showSort ? _("Sort by {0}", tx) : tx);
|
||||||
|
if (showSort)
|
||||||
|
buf.append("</a>");
|
||||||
}
|
}
|
||||||
buf.append("</th>\n</tr>\n</thead>\n");
|
buf.append("</th>\n</tr>\n</thead>\n");
|
||||||
buf.append("<tr><td colspan=\"" + (showPriority ? '5' : '4') + "\" class=\"ParentDir\"><A HREF=\"");
|
buf.append("<tr><td colspan=\"" + (showPriority ? '5' : '4') + "\" class=\"ParentDir\"><A HREF=\"");
|
||||||
@ -3013,6 +3065,17 @@ public class I2PSnarkServlet extends BasicServlet {
|
|||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param null ok
|
||||||
|
* @return query string or ""
|
||||||
|
* @since 0.9.16
|
||||||
|
*/
|
||||||
|
private static String getQueryString(String so) {
|
||||||
|
if (so != null && !so.equals(""))
|
||||||
|
return "?sort=" + DataHelper.stripHTML(so);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pick an icon; try to catch the common types in an i2p environment.
|
* Pick an icon; try to catch the common types in an i2p environment.
|
||||||
*
|
*
|
||||||
@ -3147,7 +3210,7 @@ public class I2PSnarkServlet extends BasicServlet {
|
|||||||
private void toThemeImg(StringBuilder buf, String image, String altText, String titleText) {
|
private void toThemeImg(StringBuilder buf, String image, String altText, String titleText) {
|
||||||
buf.append("<img alt=\"").append(altText).append("\" src=\"").append(_imgPath).append(image).append(".png\"");
|
buf.append("<img alt=\"").append(altText).append("\" src=\"").append(_imgPath).append(image).append(".png\"");
|
||||||
if (titleText.length() > 0)
|
if (titleText.length() > 0)
|
||||||
buf.append(" title=\"").append(altText).append('"');
|
buf.append(" title=\"").append(titleText).append('"');
|
||||||
buf.append('>');
|
buf.append('>');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,7 +368,7 @@ class Sorters {
|
|||||||
} else {
|
} else {
|
||||||
isDirectory = file.isDirectory();
|
isDirectory = file.isDirectory();
|
||||||
remaining = -1;
|
remaining = -1;
|
||||||
priority = 0;
|
priority = -999;
|
||||||
}
|
}
|
||||||
length = isDirectory ? 0 : file.length();
|
length = isDirectory ? 0 : file.length();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user