2009-06-11 18:05:05 +00:00
|
|
|
package net.i2p.router.web;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Copied and modded from I2PTunnel IndexBean (GPL)
|
|
|
|
* @author zzz
|
|
|
|
*/
|
|
|
|
public class CSSHelper extends HelperBase {
|
|
|
|
public CSSHelper() {}
|
|
|
|
|
|
|
|
public static final String PROP_THEME_NAME = "routerconsole.theme";
|
2009-07-15 22:56:53 +00:00
|
|
|
public static final String DEFAULT_THEME = "light";
|
2009-06-11 18:05:05 +00:00
|
|
|
private static final String BASE = "/themes/console/";
|
2009-07-10 13:38:09 +00:00
|
|
|
private static final String FORCE = "classic";
|
2010-01-02 02:43:18 +00:00
|
|
|
public static final String PROP_REFRESH = "routerconsole.summaryRefresh";
|
|
|
|
public static final String DEFAULT_REFRESH = "60";
|
2009-06-11 18:05:05 +00:00
|
|
|
|
2009-07-10 13:38:09 +00:00
|
|
|
public String getTheme(String userAgent) {
|
2009-06-11 18:05:05 +00:00
|
|
|
String url = BASE;
|
2009-07-10 13:38:09 +00:00
|
|
|
if (userAgent != null && userAgent.contains("MSIE")) {
|
|
|
|
url += FORCE + "/";
|
|
|
|
} else {
|
2009-07-15 22:56:53 +00:00
|
|
|
String theme = _context.getProperty(PROP_THEME_NAME, DEFAULT_THEME);
|
|
|
|
url += theme + "/";
|
2009-07-10 13:38:09 +00:00
|
|
|
}
|
2009-06-11 18:05:05 +00:00
|
|
|
return url;
|
|
|
|
}
|
2009-10-18 14:06:07 +00:00
|
|
|
|
|
|
|
/** change default language for the router but don't save it */
|
|
|
|
public void setLang(String lang) {
|
|
|
|
if (lang != null && lang.length() > 0)
|
|
|
|
_context.router().setConfigSetting(Messages.PROP_LANG, lang);
|
|
|
|
}
|
2009-10-20 12:12:26 +00:00
|
|
|
|
2009-10-22 22:25:53 +00:00
|
|
|
/** needed for conditional css loads for zh */
|
|
|
|
public String getLang() {
|
|
|
|
return Messages.getLanguage(_context);
|
|
|
|
}
|
|
|
|
|
2010-01-02 02:43:18 +00:00
|
|
|
/** change refresh and save it */
|
|
|
|
public void setRefresh(String r) {
|
|
|
|
_context.router().setConfigSetting(PROP_REFRESH, r);
|
|
|
|
_context.router().saveConfig();
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @return refresh time in seconds, as a string */
|
|
|
|
public String getRefresh() {
|
|
|
|
return _context.getProperty(PROP_REFRESH, DEFAULT_REFRESH);
|
|
|
|
}
|
|
|
|
|
2009-10-20 12:12:26 +00:00
|
|
|
/** translate the title and display consistently */
|
|
|
|
public String title(String s) {
|
|
|
|
StringBuilder buf = new StringBuilder(128);
|
|
|
|
buf.append("<title>")
|
|
|
|
.append(_("I2P Router Console"))
|
|
|
|
.append(" - ")
|
|
|
|
.append(_(s))
|
|
|
|
.append("</title>");
|
|
|
|
return buf.toString();
|
|
|
|
}
|
2009-06-11 18:05:05 +00:00
|
|
|
}
|