forked from I2P_Developers/i2p.i2p
Fix buttons on Firefox 4.0b
This commit is contained in:
@@ -329,14 +329,18 @@ public class I2PSnarkServlet extends Default {
|
|||||||
|
|
||||||
// Opera and text-mode browsers: no   and no input type=image values submitted
|
// Opera and text-mode browsers: no   and no input type=image values submitted
|
||||||
String ua = req.getHeader("User-Agent");
|
String ua = req.getHeader("User-Agent");
|
||||||
boolean isDegraded = ua != null && (ua.startsWith("Opera") || ua.startsWith("Lynx") ||
|
boolean isDegraded = ua != null && (ua.startsWith("Lynx") ||
|
||||||
ua.startsWith("ELinks") || ua.startsWith("Dillo"));
|
ua.startsWith("ELinks") || ua.startsWith("Dillo"));
|
||||||
|
|
||||||
|
boolean noThinsp = isDegraded || ua.startsWith("Opera");
|
||||||
if (_manager.util().connected()) {
|
if (_manager.util().connected()) {
|
||||||
if (isDegraded)
|
if (isDegraded)
|
||||||
out.write("<a href=\"/i2psnark/?action=StopAll&nonce=" + _nonce + "\"><img title=\"");
|
out.write("<a href=\"/i2psnark/?action=StopAll&nonce=" + _nonce + "\"><img title=\"");
|
||||||
else
|
else {
|
||||||
out.write("<input type=\"image\" name=\"action\" value=\"StopAll\" title=\"");
|
// http://www.onenaught.com/posts/382/firefox-4-change-input-type-image-only-submits-x-and-y-not-name
|
||||||
|
//out.write("<input type=\"image\" name=\"action\" value=\"StopAll\" title=\"");
|
||||||
|
out.write("<input type=\"image\" name=\"action_StopAll\" value=\"foo\" title=\"");
|
||||||
|
}
|
||||||
out.write(_("Stop all torrents and the I2P tunnel"));
|
out.write(_("Stop all torrents and the I2P tunnel"));
|
||||||
out.write("\" src=\"" + _imgPath + "stop_all.png\" alt=\"");
|
out.write("\" src=\"" + _imgPath + "stop_all.png\" alt=\"");
|
||||||
out.write(_("Stop All"));
|
out.write(_("Stop All"));
|
||||||
@@ -347,7 +351,7 @@ public class I2PSnarkServlet extends Default {
|
|||||||
if (isDegraded)
|
if (isDegraded)
|
||||||
out.write("<a href=\"/i2psnark/?action=StartAll&nonce=" + _nonce + "\"><img title=\"");
|
out.write("<a href=\"/i2psnark/?action=StartAll&nonce=" + _nonce + "\"><img title=\"");
|
||||||
else
|
else
|
||||||
out.write("<input type=\"image\" name=\"action\" value=\"StartAll\" title=\"");
|
out.write("<input type=\"image\" name=\"action_StartAll\" value=\"foo\" title=\"");
|
||||||
out.write(_("Start all torrents and the I2P tunnel"));
|
out.write(_("Start all torrents and the I2P tunnel"));
|
||||||
out.write("\" src=\"" + _imgPath + "start_all.png\" alt=\"");
|
out.write("\" src=\"" + _imgPath + "start_all.png\" alt=\"");
|
||||||
out.write(_("Start All"));
|
out.write(_("Start All"));
|
||||||
@@ -362,7 +366,7 @@ public class I2PSnarkServlet extends Default {
|
|||||||
Snark snark = (Snark)snarks.get(i);
|
Snark snark = (Snark)snarks.get(i);
|
||||||
boolean showDebug = "2".equals(peerParam);
|
boolean showDebug = "2".equals(peerParam);
|
||||||
boolean showPeers = showDebug || "1".equals(peerParam) || Base64.encode(snark.meta.getInfoHash()).equals(peerParam);
|
boolean showPeers = showDebug || "1".equals(peerParam) || Base64.encode(snark.meta.getInfoHash()).equals(peerParam);
|
||||||
displaySnark(out, snark, uri, i, stats, showPeers, isDegraded, showDebug);
|
displaySnark(out, snark, uri, i, stats, showPeers, isDegraded, noThinsp, showDebug);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (snarks.isEmpty()) {
|
if (snarks.isEmpty()) {
|
||||||
@@ -404,8 +408,19 @@ public class I2PSnarkServlet extends Default {
|
|||||||
private void processRequest(HttpServletRequest req) {
|
private void processRequest(HttpServletRequest req) {
|
||||||
String action = req.getParameter("action");
|
String action = req.getParameter("action");
|
||||||
if (action == null) {
|
if (action == null) {
|
||||||
_manager.addMessage("No action specified");
|
// http://www.onenaught.com/posts/382/firefox-4-change-input-type-image-only-submits-x-and-y-not-name
|
||||||
return;
|
Map params = req.getParameterMap();
|
||||||
|
for (Object o : params.keySet()) {
|
||||||
|
String key = (String) o;
|
||||||
|
if (key.startsWith("action_") && key.endsWith(".x")) {
|
||||||
|
action = key.substring(0, key.length() - 2).substring(7);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (action == null) {
|
||||||
|
_manager.addMessage("No action specified");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// sadly, Opera doesn't send value with input type=image, so we have to use GET there
|
// sadly, Opera doesn't send value with input type=image, so we have to use GET there
|
||||||
//if (!"POST".equals(req.getMethod())) {
|
//if (!"POST".equals(req.getMethod())) {
|
||||||
@@ -698,7 +713,7 @@ public class I2PSnarkServlet extends Default {
|
|||||||
private static final int MAX_DISPLAYED_FILENAME_LENGTH = 50;
|
private static final int MAX_DISPLAYED_FILENAME_LENGTH = 50;
|
||||||
private static final int MAX_DISPLAYED_ERROR_LENGTH = 43;
|
private static final int MAX_DISPLAYED_ERROR_LENGTH = 43;
|
||||||
private void displaySnark(PrintWriter out, Snark snark, String uri, int row, long stats[], boolean showPeers,
|
private void displaySnark(PrintWriter out, Snark snark, String uri, int row, long stats[], boolean showPeers,
|
||||||
boolean isDegraded, boolean showDebug) throws IOException {
|
boolean isDegraded, boolean noThinsp, boolean showDebug) throws IOException {
|
||||||
String filename = snark.torrent;
|
String filename = snark.torrent;
|
||||||
File f = new File(filename);
|
File f = new File(filename);
|
||||||
filename = f.getName(); // the torrent may be the canonical name, so lets just grab the local name
|
filename = f.getName(); // the torrent may be the canonical name, so lets just grab the local name
|
||||||
@@ -758,11 +773,11 @@ public class I2PSnarkServlet extends Default {
|
|||||||
if (isRunning && curPeers > 0 && !showPeers)
|
if (isRunning && curPeers > 0 && !showPeers)
|
||||||
statusString = "<img alt=\"\" border=\"0\" src=\"" + _imgPath + "trackererror.png\" title=\"" + err + "\"></td><td class=\"snarkTorrentStatus " + rowClass + "\">" + _("Tracker Error") +
|
statusString = "<img alt=\"\" border=\"0\" src=\"" + _imgPath + "trackererror.png\" title=\"" + err + "\"></td><td class=\"snarkTorrentStatus " + rowClass + "\">" + _("Tracker Error") +
|
||||||
": <a href=\"" + uri + "?p=" + Base64.encode(snark.meta.getInfoHash()) + "\">" +
|
": <a href=\"" + uri + "?p=" + Base64.encode(snark.meta.getInfoHash()) + "\">" +
|
||||||
curPeers + thinsp(isDegraded) +
|
curPeers + thinsp(noThinsp) +
|
||||||
ngettext("1 peer", "{0} peers", knownPeers) + "</a>";
|
ngettext("1 peer", "{0} peers", knownPeers) + "</a>";
|
||||||
else if (isRunning)
|
else if (isRunning)
|
||||||
statusString = "<img alt=\"\" border=\"0\" src=\"" + _imgPath + "trackererror.png\" title=\"" + err + "\"></td><td class=\"snarkTorrentStatus " + rowClass + "\">" + _("Tracker Error") +
|
statusString = "<img alt=\"\" border=\"0\" src=\"" + _imgPath + "trackererror.png\" title=\"" + err + "\"></td><td class=\"snarkTorrentStatus " + rowClass + "\">" + _("Tracker Error") +
|
||||||
": " + curPeers + thinsp(isDegraded) +
|
": " + curPeers + thinsp(noThinsp) +
|
||||||
ngettext("1 peer", "{0} peers", knownPeers);
|
ngettext("1 peer", "{0} peers", knownPeers);
|
||||||
else {
|
else {
|
||||||
if (err.length() > MAX_DISPLAYED_ERROR_LENGTH)
|
if (err.length() > MAX_DISPLAYED_ERROR_LENGTH)
|
||||||
@@ -774,11 +789,11 @@ public class I2PSnarkServlet extends Default {
|
|||||||
if (isRunning && curPeers > 0 && !showPeers)
|
if (isRunning && curPeers > 0 && !showPeers)
|
||||||
statusString = "<img alt=\"\" border=\"0\" src=\"" + _imgPath + "seeding.png\" ></td><td class=\"snarkTorrentStatus " + rowClass + "\">" + _("Seeding") +
|
statusString = "<img alt=\"\" border=\"0\" src=\"" + _imgPath + "seeding.png\" ></td><td class=\"snarkTorrentStatus " + rowClass + "\">" + _("Seeding") +
|
||||||
": <a href=\"" + uri + "?p=" + Base64.encode(snark.meta.getInfoHash()) + "\">" +
|
": <a href=\"" + uri + "?p=" + Base64.encode(snark.meta.getInfoHash()) + "\">" +
|
||||||
curPeers + thinsp(isDegraded) +
|
curPeers + thinsp(noThinsp) +
|
||||||
ngettext("1 peer", "{0} peers", knownPeers) + "</a>";
|
ngettext("1 peer", "{0} peers", knownPeers) + "</a>";
|
||||||
else if (isRunning)
|
else if (isRunning)
|
||||||
statusString = "<img alt=\"\" border=\"0\" src=\"" + _imgPath + "seeding.png\" ></td><td class=\"snarkTorrentStatus " + rowClass + "\">" + _("Seeding") +
|
statusString = "<img alt=\"\" border=\"0\" src=\"" + _imgPath + "seeding.png\" ></td><td class=\"snarkTorrentStatus " + rowClass + "\">" + _("Seeding") +
|
||||||
": " + curPeers + thinsp(isDegraded) +
|
": " + curPeers + thinsp(noThinsp) +
|
||||||
ngettext("1 peer", "{0} peers", knownPeers);
|
ngettext("1 peer", "{0} peers", knownPeers);
|
||||||
else
|
else
|
||||||
statusString = "<img alt=\"\" border=\"0\" src=\"" + _imgPath + "complete.png\" ></td><td class=\"snarkTorrentStatus " + rowClass + "\">" + _("Complete");
|
statusString = "<img alt=\"\" border=\"0\" src=\"" + _imgPath + "complete.png\" ></td><td class=\"snarkTorrentStatus " + rowClass + "\">" + _("Complete");
|
||||||
@@ -786,24 +801,24 @@ public class I2PSnarkServlet extends Default {
|
|||||||
if (isRunning && curPeers > 0 && downBps > 0 && !showPeers)
|
if (isRunning && curPeers > 0 && downBps > 0 && !showPeers)
|
||||||
statusString = "<img alt=\"\" border=\"0\" src=\"" + _imgPath + "downloading.png\" ></td><td class=\"snarkTorrentStatus " + rowClass + "\">" + _("OK") +
|
statusString = "<img alt=\"\" border=\"0\" src=\"" + _imgPath + "downloading.png\" ></td><td class=\"snarkTorrentStatus " + rowClass + "\">" + _("OK") +
|
||||||
": <a href=\"" + uri + "?p=" + Base64.encode(snark.meta.getInfoHash()) + "\">" +
|
": <a href=\"" + uri + "?p=" + Base64.encode(snark.meta.getInfoHash()) + "\">" +
|
||||||
curPeers + thinsp(isDegraded) +
|
curPeers + thinsp(noThinsp) +
|
||||||
ngettext("1 peer", "{0} peers", knownPeers) + "</a>";
|
ngettext("1 peer", "{0} peers", knownPeers) + "</a>";
|
||||||
else if (isRunning && curPeers > 0 && downBps > 0)
|
else if (isRunning && curPeers > 0 && downBps > 0)
|
||||||
statusString = "<img alt=\"\" border=\"0\" src=\"" + _imgPath + "downloading.png\" ></td><td class=\"snarkTorrentStatus " + rowClass + "\">" + _("OK") +
|
statusString = "<img alt=\"\" border=\"0\" src=\"" + _imgPath + "downloading.png\" ></td><td class=\"snarkTorrentStatus " + rowClass + "\">" + _("OK") +
|
||||||
": " + curPeers + thinsp(isDegraded) +
|
": " + curPeers + thinsp(noThinsp) +
|
||||||
ngettext("1 peer", "{0} peers", knownPeers);
|
ngettext("1 peer", "{0} peers", knownPeers);
|
||||||
else if (isRunning && curPeers > 0 && !showPeers)
|
else if (isRunning && curPeers > 0 && !showPeers)
|
||||||
statusString = "<img alt=\"\" border=\"0\" src=\"" + _imgPath + "stalled.png\" ></td><td class=\"snarkTorrentStatus " + rowClass + "\">" + _("Stalled") +
|
statusString = "<img alt=\"\" border=\"0\" src=\"" + _imgPath + "stalled.png\" ></td><td class=\"snarkTorrentStatus " + rowClass + "\">" + _("Stalled") +
|
||||||
": <a href=\"" + uri + "?p=" + Base64.encode(snark.meta.getInfoHash()) + "\">" +
|
": <a href=\"" + uri + "?p=" + Base64.encode(snark.meta.getInfoHash()) + "\">" +
|
||||||
curPeers + thinsp(isDegraded) +
|
curPeers + thinsp(noThinsp) +
|
||||||
ngettext("1 peer", "{0} peers", knownPeers) + "</a>";
|
ngettext("1 peer", "{0} peers", knownPeers) + "</a>";
|
||||||
else if (isRunning && curPeers > 0)
|
else if (isRunning && curPeers > 0)
|
||||||
statusString = "<img alt=\"\" border=\"0\" src=\"" + _imgPath + "stalled.png\" ></td><td class=\"snarkTorrentStatus " + rowClass + "\">" + _("Stalled") +
|
statusString = "<img alt=\"\" border=\"0\" src=\"" + _imgPath + "stalled.png\" ></td><td class=\"snarkTorrentStatus " + rowClass + "\">" + _("Stalled") +
|
||||||
": " + curPeers + thinsp(isDegraded) +
|
": " + curPeers + thinsp(noThinsp) +
|
||||||
ngettext("1 peer", "{0} peers", knownPeers);
|
ngettext("1 peer", "{0} peers", knownPeers);
|
||||||
else if (isRunning && knownPeers > 0)
|
else if (isRunning && knownPeers > 0)
|
||||||
statusString = "<img alt=\"\" border=\"0\" src=\"" + _imgPath + "nopeers.png\" ></td><td class=\"snarkTorrentStatus " + rowClass + "\">" + _("No Peers") +
|
statusString = "<img alt=\"\" border=\"0\" src=\"" + _imgPath + "nopeers.png\" ></td><td class=\"snarkTorrentStatus " + rowClass + "\">" + _("No Peers") +
|
||||||
": 0" + thinsp(isDegraded) + knownPeers ;
|
": 0" + thinsp(noThinsp) + knownPeers ;
|
||||||
else if (isRunning)
|
else if (isRunning)
|
||||||
statusString = "<img alt=\"\" border=\"0\" src=\"" + _imgPath + "nopeers.png\" ></td><td class=\"snarkTorrentStatus " + rowClass + "\">" + _("No Peers");
|
statusString = "<img alt=\"\" border=\"0\" src=\"" + _imgPath + "nopeers.png\" ></td><td class=\"snarkTorrentStatus " + rowClass + "\">" + _("No Peers");
|
||||||
else
|
else
|
||||||
@@ -880,7 +895,7 @@ public class I2PSnarkServlet extends Default {
|
|||||||
out.write("</td>\n\t");
|
out.write("</td>\n\t");
|
||||||
out.write("<td align=\"right\" class=\"snarkTorrentDownloaded " + rowClass + "\">");
|
out.write("<td align=\"right\" class=\"snarkTorrentDownloaded " + rowClass + "\">");
|
||||||
if (remaining > 0)
|
if (remaining > 0)
|
||||||
out.write(formatSize(total-remaining) + thinsp(isDegraded) + formatSize(total));
|
out.write(formatSize(total-remaining) + thinsp(noThinsp) + formatSize(total));
|
||||||
else
|
else
|
||||||
out.write(formatSize(total)); // 3GB
|
out.write(formatSize(total)); // 3GB
|
||||||
out.write("</td>\n\t");
|
out.write("</td>\n\t");
|
||||||
@@ -905,7 +920,7 @@ public class I2PSnarkServlet extends Default {
|
|||||||
if (isDegraded)
|
if (isDegraded)
|
||||||
out.write("<a href=\"/i2psnark/?action=Stop_" + b64 + "&nonce=" + _nonce + "\"><img title=\"");
|
out.write("<a href=\"/i2psnark/?action=Stop_" + b64 + "&nonce=" + _nonce + "\"><img title=\"");
|
||||||
else
|
else
|
||||||
out.write("<input type=\"image\" name=\"action\" value=\"Stop_" + b64 + "\" title=\"");
|
out.write("<input type=\"image\" name=\"action_Stop_" + b64 + "\" value=\"foo\" title=\"");
|
||||||
out.write(_("Stop the torrent"));
|
out.write(_("Stop the torrent"));
|
||||||
out.write("\" src=\"" + _imgPath + "stop.png\" alt=\"");
|
out.write("\" src=\"" + _imgPath + "stop.png\" alt=\"");
|
||||||
out.write(_("Stop"));
|
out.write(_("Stop"));
|
||||||
@@ -917,7 +932,7 @@ public class I2PSnarkServlet extends Default {
|
|||||||
if (isDegraded)
|
if (isDegraded)
|
||||||
out.write("<a href=\"/i2psnark/?action=Start_" + b64 + "&nonce=" + _nonce + "\"><img title=\"");
|
out.write("<a href=\"/i2psnark/?action=Start_" + b64 + "&nonce=" + _nonce + "\"><img title=\"");
|
||||||
else
|
else
|
||||||
out.write("<input type=\"image\" name=\"action\" value=\"Start_" + b64 + "\" title=\"");
|
out.write("<input type=\"image\" name=\"action_Start_" + b64 + "\" value=\"foo\" title=\"");
|
||||||
out.write(_("Start the torrent"));
|
out.write(_("Start the torrent"));
|
||||||
out.write("\" src=\"" + _imgPath + "start.png\" alt=\"");
|
out.write("\" src=\"" + _imgPath + "start.png\" alt=\"");
|
||||||
out.write(_("Start"));
|
out.write(_("Start"));
|
||||||
@@ -929,7 +944,7 @@ public class I2PSnarkServlet extends Default {
|
|||||||
if (isDegraded)
|
if (isDegraded)
|
||||||
out.write("<a href=\"/i2psnark/?action=Remove_" + b64 + "&nonce=" + _nonce + "\"><img title=\"");
|
out.write("<a href=\"/i2psnark/?action=Remove_" + b64 + "&nonce=" + _nonce + "\"><img title=\"");
|
||||||
else
|
else
|
||||||
out.write("<input type=\"image\" name=\"action\" value=\"Remove_" + b64 + "\" title=\"");
|
out.write("<input type=\"image\" name=\"action_Remove_" + b64 + "\" value=\"foo\" title=\"");
|
||||||
out.write(_("Remove the torrent from the active list, deleting the .torrent file"));
|
out.write(_("Remove the torrent from the active list, deleting the .torrent file"));
|
||||||
out.write("\" onclick=\"if (!confirm('");
|
out.write("\" onclick=\"if (!confirm('");
|
||||||
// Can't figure out how to escape double quotes inside the onclick string.
|
// Can't figure out how to escape double quotes inside the onclick string.
|
||||||
@@ -946,7 +961,7 @@ public class I2PSnarkServlet extends Default {
|
|||||||
if (isDegraded)
|
if (isDegraded)
|
||||||
out.write("<a href=\"/i2psnark/?action=Delete_" + b64 + "&nonce=" + _nonce + "\"><img title=\"");
|
out.write("<a href=\"/i2psnark/?action=Delete_" + b64 + "&nonce=" + _nonce + "\"><img title=\"");
|
||||||
else
|
else
|
||||||
out.write("<input type=\"image\" name=\"action\" value=\"Delete_" + b64 + "\" title=\"");
|
out.write("<input type=\"image\" name=\"action_Delete_" + b64 + "\" value=\"foo\" title=\"");
|
||||||
out.write(_("Delete the .torrent file and the associated data file(s)"));
|
out.write(_("Delete the .torrent file and the associated data file(s)"));
|
||||||
out.write("\" onclick=\"if (!confirm('");
|
out.write("\" onclick=\"if (!confirm('");
|
||||||
// Can't figure out how to escape double quotes inside the onclick string.
|
// Can't figure out how to escape double quotes inside the onclick string.
|
||||||
@@ -1384,7 +1399,7 @@ public class I2PSnarkServlet extends Default {
|
|||||||
private static String urlify(String s) {
|
private static String urlify(String s) {
|
||||||
StringBuilder buf = new StringBuilder(256);
|
StringBuilder buf = new StringBuilder(256);
|
||||||
// browsers seem to work without doing this but let's be strict
|
// browsers seem to work without doing this but let's be strict
|
||||||
String link = s.replace("&", "&");
|
String link = s.replace("&", "&").replace(" ", "%20");
|
||||||
buf.append("<a href=\"").append(link).append("\">").append(link).append("</a>");
|
buf.append("<a href=\"").append(link).append("\">").append(link).append("</a>");
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user