Console: onchange removal

This commit is contained in:
zzz
2020-05-12 18:57:29 +00:00
parent a47f6d1b2e
commit fe36482063
4 changed files with 23 additions and 6 deletions

View File

@ -69,7 +69,7 @@ public class StatsGenerator {
buf.append("</p>"); buf.append("</p>");
buf.append("<form action=\"\"><b>"); buf.append("<form action=\"\"><b>");
buf.append(_t("Jump to section")).append(":</b> <select name=\"go\" onChange='location.href=this.value'>"); buf.append(_t("Jump to section")).append(":</b> <select class=\"onchange\">");
out.write(buf.toString()); out.write(buf.toString());
buf.setLength(0); buf.setLength(0);
@ -92,6 +92,7 @@ public class StatsGenerator {
//out.write(buf.toString()); //out.write(buf.toString());
//buf.setLength(0); //buf.setLength(0);
} }
// TODO this is broken for non-js
buf.append("</select> <input type=\"submit\" value=\"").append(_t("GO")).append("\" />"); buf.append("</select> <input type=\"submit\" value=\"").append(_t("GO")).append("\" />");
buf.append("</form>"); buf.append("</form>");

View File

@ -1,4 +0,0 @@
<%
// Add this AFTER css.jsi if there's any onclick attributes in the page
response.setHeader("Content-Security-Policy", "default-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline'; form-action 'self'; frame-ancestors 'self'; object-src 'none'; media-src 'none'");
%>

View File

@ -0,0 +1,20 @@
function init()
{
var buttons = document.getElementsByClassName("onchange");
for(index = 0; index < buttons.length; index++)
{
var button = buttons[index];
addChangeHandler(button);
}
}
function addChangeHandler(elem)
{
elem.addEventListener("change", function() {
location.href=event.target.value;
});
}
document.addEventListener("DOMContentLoaded", function() {
init();
}, true);

View File

@ -4,9 +4,9 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head> <html><head>
<%@include file="css.jsi" %> <%@include file="css.jsi" %>
<%@include file="csp-unsafe.jsi" %>
<%=intl.title("statistics")%> <%=intl.title("statistics")%>
<%@include file="summaryajax.jsi" %> <%@include file="summaryajax.jsi" %>
<script src="/js/stats.js?<%=net.i2p.CoreVersion.VERSION%>" type="text/javascript"></script>
</head><body> </head><body>
<%@include file="summary.jsi" %> <%@include file="summary.jsi" %>
<jsp:useBean class="net.i2p.router.web.helpers.OldConsoleHelper" id="oldhelper" scope="request" /> <jsp:useBean class="net.i2p.router.web.helpers.OldConsoleHelper" id="oldhelper" scope="request" />