From fe36482063e85a62dda3788dd4195f8dec3778b9 Mon Sep 17 00:00:00 2001 From: zzz Date: Tue, 12 May 2020 18:57:29 +0000 Subject: [PATCH] Console: onchange removal --- .../router/web/helpers/StatsGenerator.java | 3 ++- apps/routerconsole/jsp/csp-unsafe.jsi | 4 ---- apps/routerconsole/jsp/js/stats.js | 20 +++++++++++++++++++ apps/routerconsole/jsp/stats.jsp | 2 +- 4 files changed, 23 insertions(+), 6 deletions(-) delete mode 100644 apps/routerconsole/jsp/csp-unsafe.jsi create mode 100644 apps/routerconsole/jsp/js/stats.js diff --git a/apps/routerconsole/java/src/net/i2p/router/web/helpers/StatsGenerator.java b/apps/routerconsole/java/src/net/i2p/router/web/helpers/StatsGenerator.java index f04df83c6..a34d1661d 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/helpers/StatsGenerator.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/helpers/StatsGenerator.java @@ -69,7 +69,7 @@ public class StatsGenerator { buf.append("

"); buf.append("
"); - buf.append(_t("Jump to section")).append(": "); out.write(buf.toString()); buf.setLength(0); @@ -92,6 +92,7 @@ public class StatsGenerator { //out.write(buf.toString()); //buf.setLength(0); } + // TODO this is broken for non-js buf.append(" "); buf.append("
"); diff --git a/apps/routerconsole/jsp/csp-unsafe.jsi b/apps/routerconsole/jsp/csp-unsafe.jsi deleted file mode 100644 index 720a26a17..000000000 --- a/apps/routerconsole/jsp/csp-unsafe.jsi +++ /dev/null @@ -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'"); -%> diff --git a/apps/routerconsole/jsp/js/stats.js b/apps/routerconsole/jsp/js/stats.js new file mode 100644 index 000000000..9685c5aed --- /dev/null +++ b/apps/routerconsole/jsp/js/stats.js @@ -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); diff --git a/apps/routerconsole/jsp/stats.jsp b/apps/routerconsole/jsp/stats.jsp index 0e14ef6b1..4be78bb69 100644 --- a/apps/routerconsole/jsp/stats.jsp +++ b/apps/routerconsole/jsp/stats.jsp @@ -4,9 +4,9 @@ <%@include file="css.jsi" %> -<%@include file="csp-unsafe.jsi" %> <%=intl.title("statistics")%> <%@include file="summaryajax.jsi" %> + <%@include file="summary.jsi" %>