I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit aae801ef authored by zzz's avatar zzz
Browse files

sort config tabs

parent e02d4443
No related branches found
No related tags found
No related merge requests found
package net.i2p.router.web; package net.i2p.router.web;
import java.io.IOException; import java.io.IOException;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
/** /**
* Render the configuration menu at the top of all the config pages. * Render the configuration menu at the top of all the config pages.
...@@ -21,6 +27,27 @@ public class ConfigNavHelper extends HelperBase { ...@@ -21,6 +27,27 @@ public class ConfigNavHelper extends HelperBase {
_x("Clients"), _x("Peers"), _x("Keyring"), _x("Logging"), _x("Stats"), _x("Clients"), _x("Peers"), _x("Keyring"), _x("Logging"), _x("Stats"),
_x("Reseeding"), _x("Advanced") }; _x("Reseeding"), _x("Advanced") };
private static class Tab {
public final String page, title;
public Tab(String p, String t) {
page = p; title = t;
}
}
private class TabComparator implements Comparator<Tab> {
private static final long serialVersionUID = 1L;
private final Collator coll;
public TabComparator() {
super();
coll = Collator.getInstance(new Locale(Messages.getLanguage(_context)));
}
public int compare(Tab l, Tab r) {
return coll.compare(l.title, r.title);
}
}
/** /**
* @param graphical false for text-mode browsers * @param graphical false for text-mode browsers
*/ */
...@@ -31,18 +58,23 @@ public class ConfigNavHelper extends HelperBase { ...@@ -31,18 +58,23 @@ public class ConfigNavHelper extends HelperBase {
boolean span = graphical && (theme == null || theme.equals(CSSHelper.DEFAULT_THEME)); boolean span = graphical && (theme == null || theme.equals(CSSHelper.DEFAULT_THEME));
if (!span) if (!span)
buf.append("<center>"); buf.append("<center>");
List<Tab> tabs = new ArrayList<Tab>(pages.length);
for (int i = 0; i < pages.length; i++) { for (int i = 0; i < pages.length; i++) {
String page = "config" + pages[i]; tabs.add(new Tab(pages[i], _(titles[i])));
}
Collections.sort(tabs, new TabComparator());
for (int i = 0; i < tabs.size(); i++) {
String page = "config" + tabs.get(i).page;
if (requestURI.endsWith(page) || requestURI.endsWith(page + ".jsp")) { if (requestURI.endsWith(page) || requestURI.endsWith(page + ".jsp")) {
// we are there // we are there
if (span) if (span)
buf.append("<span class=\"tab2\">"); buf.append("<span class=\"tab2\">");
buf.append(_(titles[i])); buf.append(tabs.get(i).title);
} else { } else {
// we are not there, make a link // we are not there, make a link
if (span) if (span)
buf.append("<span class=\"tab\">"); buf.append("<span class=\"tab\">");
buf.append("<a href=\"").append(page).append("\">").append(_(titles[i])).append("</a>"); buf.append("<a href=\"").append(page).append("\">").append(tabs.get(i).title).append("</a>");
} }
if (span) if (span)
buf.append(" </span>\n"); buf.append(" </span>\n");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment