forked from I2P_Developers/i2p.i2p
- Add tooltip support for plugin links
- Make target=_blank for plugin links
This commit is contained in:
@ -10,6 +10,7 @@ import net.i2p.I2PAppContext;
|
||||
|
||||
public class NavHelper {
|
||||
private static Map<String, String> _apps = new ConcurrentHashMap(4);
|
||||
private static Map<String, String> _tooltips = new ConcurrentHashMap(4);
|
||||
|
||||
/**
|
||||
* To register a new client application so that it shows up on the router
|
||||
@ -22,8 +23,15 @@ public class NavHelper {
|
||||
public static void registerApp(String name, String path) {
|
||||
_apps.put(name, path);
|
||||
}
|
||||
|
||||
public static void registerApp(String name, String path, String tooltip) {
|
||||
_apps.put(name, path);
|
||||
_tooltips.put(name, tooltip);
|
||||
}
|
||||
|
||||
public static void unregisterApp(String name) {
|
||||
_apps.remove(name);
|
||||
_tooltips.remove(name);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -39,8 +47,11 @@ public class NavHelper {
|
||||
String path = _apps.get(name);
|
||||
if (path == null)
|
||||
continue;
|
||||
buf.append(" <a target=\"_top\" href=\"").append(path).append("\">");
|
||||
buf.append(name).append("</a>");
|
||||
buf.append(" <a target=\"_blank\" href=\"").append(path).append("\" ");
|
||||
String tip = _tooltips.get(name);
|
||||
if (tip != null)
|
||||
buf.append("title=\"").append(tip).append("\" ");
|
||||
buf.append('>').append(name).append("</a>");
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
@ -170,8 +170,15 @@ public class PluginStarter implements Runnable {
|
||||
if (name == null)
|
||||
name = ConfigClientsHelper.stripHTML(props, "consoleLinkName");
|
||||
String url = ConfigClientsHelper.stripHTML(props, "consoleLinkURL");
|
||||
if (name != null && url != null && name.length() > 0 && url.length() > 0)
|
||||
NavHelper.registerApp(name, url);
|
||||
if (name != null && url != null && name.length() > 0 && url.length() > 0) {
|
||||
String tip = ConfigClientsHelper.stripHTML(props, "consoleLinkTooltip_" + Messages.getLanguage(ctx));
|
||||
if (tip == null)
|
||||
tip = ConfigClientsHelper.stripHTML(props, "consoleLinkTooltip");
|
||||
if (tip != null)
|
||||
NavHelper.registerApp(name, url, tip);
|
||||
else
|
||||
NavHelper.registerApp(name, url);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user