Changeset cce0d94


Ignore:
Timestamp:
Sep 11, 2014 2:13:13 PM (7 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
ef81a57
Parents:
22b5203
Message:
  • Conditionally enable sort links
File:
1 edited

Legend:

Unmodified
Added
Removed
  • apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java

    r22b5203 rcce0d94  
    424424
    425425        String currentSort = req.getParameter("sort");
     426        boolean showSort = total > 1;
    426427        out.write("<tr><th>");
    427428        String sort = ("2".equals(currentSort)) ? "-2" : "2";
    428         out.write("<a href=\"" + _contextPath + '/' + getQueryString(req, null, null, sort));
    429         out.write("\"><img border=\"0\" src=\"" + _imgPath + "status.png\" title=\"");
    430         out.write(_("Sort by {0}", _("Status")));
     429        if (showSort) {
     430            out.write("<a href=\"" + _contextPath + '/' + getQueryString(req, null, null, sort));
     431            out.write("\">");
     432        }
     433        out.write("<img border=\"0\" src=\"" + _imgPath + "status.png\" title=\"");
     434        if (showSort)
     435            out.write(_("Sort by {0}", _("Status")));
     436        else
     437            out.write(_("Status"));
    431438        out.write("\" alt=\"");
    432439        out.write(_("Status"));
    433         out.write("\"></a></th>\n<th>");
     440        out.write("\">");
     441        if (showSort)
     442            out.write("</a>");
     443        out.write("</th>\n<th>");
    434444        if (_manager.util().connected() && !snarks.isEmpty()) {
    435445            out.write(" <a href=\"" + _contextPath + '/');
     
    455465        }
    456466        out.write("</th>\n<th colspan=\"2\" align=\"left\">");
    457         sort = (currentSort == null || "0".equals(currentSort) || "1".equals(currentSort)) ? "-1" : "";
    458         out.write("<a href=\"" + _contextPath + '/' + getQueryString(req, null, null, sort));
    459         out.write("\"><img border=\"0\" src=\"" + _imgPath + "torrent.png\" title=\"");
    460         out.write(_("Sort by {0}", _("Torrent")));
     467        if (showSort) {
     468            sort = (currentSort == null || "0".equals(currentSort) || "1".equals(currentSort)) ? "-1" : "";
     469            out.write("<a href=\"" + _contextPath + '/' + getQueryString(req, null, null, sort));
     470            out.write("\">");
     471        }
     472        out.write("<img border=\"0\" src=\"" + _imgPath + "torrent.png\" title=\"");
     473        if (showSort)
     474            out.write(_("Sort by {0}", _("Torrent")));
     475        else
     476            out.write(_("Torrent"));
    461477        out.write("\" alt=\"");
    462478        out.write(_("Torrent"));
    463         out.write("\"></a></th>\n<th align=\"center\">");
     479        out.write("\">");
     480        if (showSort)
     481            out.write("</a>");
     482        out.write("</th>\n<th align=\"center\">");
    464483        if (total > 0 && (start > 0 || total > pageSize)) {
    465484            writePageNav(out, req, start, pageSize, total, noThinsp);
     
    467486        out.write("</th>\n<th align=\"right\">");
    468487        if (_manager.util().connected() && !snarks.isEmpty()) {
    469             sort = ("4".equals(currentSort)) ? "-4" : "4";
    470             out.write("<a href=\"" + _contextPath + '/' + getQueryString(req, null, null, sort));
    471             out.write("\"><img border=\"0\" src=\"" + _imgPath + "eta.png\" title=\"");
    472             out.write(_("Sort by {0}", _("Estimated time remaining")));
     488            if (showSort) {
     489                sort = ("4".equals(currentSort)) ? "-4" : "4";
     490                out.write("<a href=\"" + _contextPath + '/' + getQueryString(req, null, null, sort));
     491                out.write("\">");
     492            }
     493            out.write("<img border=\"0\" src=\"" + _imgPath + "eta.png\" title=\"");
     494            if (showSort)
     495                out.write(_("Sort by {0}", _("Estimated time remaining")));
     496            else
     497                out.write(_("Estimated time remaining"));
    473498            out.write("\" alt=\"");
    474499            // Translators: Please keep short or translate as " "
    475500            out.write(_("ETA"));
    476             out.write("\"></a>");
     501            out.write("\">");
     502            if (showSort)
     503                out.write("</a>");
    477504        }
    478505        out.write("</th>\n<th align=\"right\">");
    479506        // sort by size, not downloaded
    480         sort = ("5".equals(currentSort)) ? "-5" : "5";
    481         out.write("<a href=\"" + _contextPath + '/' + getQueryString(req, null, null, sort));
    482         out.write("\"><img border=\"0\" src=\"" + _imgPath + "head_rx.png\" title=\"");
    483         out.write(_("Sort by {0}", _("Size")));
     507        if (showSort) {
     508            sort = ("5".equals(currentSort)) ? "-5" : "5";
     509            out.write("<a href=\"" + _contextPath + '/' + getQueryString(req, null, null, sort));
     510            out.write("\">");
     511        }
     512        out.write("<img border=\"0\" src=\"" + _imgPath + "head_rx.png\" title=\"");
     513        if (showSort)
     514            out.write(_("Sort by {0}", _("Size")));
     515        else
     516            out.write(_("Downloaded"));
    484517        out.write("\" alt=\"");
    485518        // Translators: Please keep short or translate as " "
    486519        out.write(_("RX"));
    487         out.write("\"></a>");
     520        out.write("\">");
     521        if (showSort)
     522            out.write("</a>");
    488523        out.write("</th>\n<th align=\"right\">");
    489524        if (!snarks.isEmpty()) {
    490             sort = ("7".equals(currentSort)) ? "-7" : "7";
    491             out.write("<a href=\"" + _contextPath + '/' + getQueryString(req, null, null, sort));
    492             out.write("\"><img border=\"0\" src=\"" + _imgPath + "head_tx.png\" title=\"");
    493             out.write(_("Sort by {0}", _("Uploaded")));
     525            if (showSort) {
     526                sort = ("7".equals(currentSort)) ? "-7" : "7";
     527                out.write("<a href=\"" + _contextPath + '/' + getQueryString(req, null, null, sort));
     528                out.write("\">");
     529            }
     530            out.write("<img border=\"0\" src=\"" + _imgPath + "head_tx.png\" title=\"");
     531            if (showSort)
     532                out.write(_("Sort by {0}", _("Uploaded")));
     533            else
     534                out.write(_("Uploaded"));
    494535            out.write("\" alt=\"");
    495536            // Translators: Please keep short or translate as " "
    496537            out.write(_("TX"));
    497             out.write("\"></a>");
     538            out.write("\">");
     539            if (showSort)
     540                out.write("</a>");
    498541        }
    499542        out.write("</th>\n<th align=\"right\">");
    500543        if (_manager.util().connected() && !snarks.isEmpty()) {
    501             sort = ("8".equals(currentSort)) ? "-8" : "8";
    502             out.write("<a href=\"" + _contextPath + '/' + getQueryString(req, null, null, sort));
    503             out.write("\"><img border=\"0\" src=\"" + _imgPath + "head_rxspeed.png\" title=\"");
    504             out.write(_("Sort by {0}", _("Down Rate")));
     544            if (showSort) {
     545                sort = ("8".equals(currentSort)) ? "-8" : "8";
     546                out.write("<a href=\"" + _contextPath + '/' + getQueryString(req, null, null, sort));
     547                out.write("\">");
     548            }
     549            out.write("<img border=\"0\" src=\"" + _imgPath + "head_rxspeed.png\" title=\"");
     550            if (showSort)
     551                out.write(_("Sort by {0}", _("Down Rate")));
     552            else
     553                out.write(_("Down Rate"));
    505554            out.write("\" alt=\"");
    506555            // Translators: Please keep short or translate as " "
    507556            out.write(_("RX Rate"));
    508             out.write("\"></a>");
     557            out.write("\">");
     558            if (showSort)
     559                out.write("</a>");
    509560        }
    510561        out.write("</th>\n<th align=\"right\">");
    511562        if (_manager.util().connected() && !snarks.isEmpty()) {
    512             sort = ("9".equals(currentSort)) ? "-9" : "9";
    513             out.write("<a href=\"" + _contextPath + '/' + getQueryString(req, null, null, sort));
    514             out.write("\"><img border=\"0\" src=\"" + _imgPath + "head_txspeed.png\" title=\"");
    515             out.write(_("Sort by {0}", _("Up Rate")));
     563            if (showSort) {
     564                sort = ("9".equals(currentSort)) ? "-9" : "9";
     565                out.write("<a href=\"" + _contextPath + '/' + getQueryString(req, null, null, sort));
     566                out.write("\">");
     567            }
     568            out.write("<img border=\"0\" src=\"" + _imgPath + "head_txspeed.png\" title=\"");
     569            if (showSort)
     570                out.write(_("Sort by {0}", _("Up Rate")));
     571            else
     572                out.write(_("Up Rate"));
    516573            out.write("\" alt=\"");
    517574            // Translators: Please keep short or translate as " "
    518575            out.write(_("TX Rate"));
    519             out.write("\"></a>");
     576            out.write("\">");
     577            if (showSort)
     578                out.write("</a>");
    520579        }
    521580        out.write("</th>\n<th align=\"center\">");
Note: See TracChangeset for help on using the changeset viewer.