From 7da2ac9ef3d45eb6f090aaac02ac9a0b9eff9609 Mon Sep 17 00:00:00 2001 From: zzz Date: Mon, 11 May 2020 16:43:53 +0000 Subject: [PATCH] Console: Fix delete confirmation on /configplugins Replace /configclients and /configplugins onclick with js file Remove unsafe CSP on /configclients --- .../web/helpers/ConfigClientsHelper.java | 4 +--- apps/routerconsole/jsp/configclients.jsp | 5 +++- apps/routerconsole/jsp/configplugins.jsp | 4 ++++ apps/routerconsole/jsp/js/configclients.js | 23 +++++++++++++++++++ apps/routerconsole/jsp/js/configstats.js | 5 +++- 5 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 apps/routerconsole/jsp/js/configclients.js diff --git a/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigClientsHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigClientsHelper.java index 8e07d426a3..2cbca64f64 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigClientsHelper.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigClientsHelper.java @@ -401,9 +401,7 @@ public class ConfigClientsHelper extends HelperBase { } if (showDeleteButton && (!edit) && !ro) { buf.append(""); } buf.append(""); diff --git a/apps/routerconsole/jsp/configclients.jsp b/apps/routerconsole/jsp/configclients.jsp index ace704112c..45bafda37d 100644 --- a/apps/routerconsole/jsp/configclients.jsp +++ b/apps/routerconsole/jsp/configclients.jsp @@ -3,7 +3,6 @@ <%@include file="css.jsi" %> -<%@include file="csp-unsafe.jsi" %> <%=intl.title("config clients")%> <%@include file="summaryajax.jsi" %> + + <%@include file="summary.jsi" %> diff --git a/apps/routerconsole/jsp/configplugins.jsp b/apps/routerconsole/jsp/configplugins.jsp index c6bb9ca509..46b1be05c1 100644 --- a/apps/routerconsole/jsp/configplugins.jsp +++ b/apps/routerconsole/jsp/configplugins.jsp @@ -11,6 +11,10 @@ button span.hide{ input.default { width: 1px; height: 1px; visibility: hidden; } <%@include file="summaryajax.jsi" %> + + <%@include file="summary.jsi" %> diff --git a/apps/routerconsole/jsp/js/configclients.js b/apps/routerconsole/jsp/js/configclients.js new file mode 100644 index 0000000000..657e29f820 --- /dev/null +++ b/apps/routerconsole/jsp/js/configclients.js @@ -0,0 +1,23 @@ +function init() +{ + var buttons = document.getElementsByClassName("delete"); + for(index = 0; index < buttons.length; index++) + { + var button = buttons[index]; + addClickHandler(button); + } +} + +function addClickHandler(elem) +{ + elem.addEventListener("click", function() { + if (!confirm(deleteMessage.replace("{0}", elem.getAttribute("client")))) { + event.preventDefault(); + return false; + } + }); +} + +document.addEventListener("DOMContentLoaded", function() { + init(); +}, true); diff --git a/apps/routerconsole/jsp/js/configstats.js b/apps/routerconsole/jsp/js/configstats.js index bbfd27124b..81bf111510 100644 --- a/apps/routerconsole/jsp/js/configstats.js +++ b/apps/routerconsole/jsp/js/configstats.js @@ -62,4 +62,7 @@ function toggleAll(category) } } } -window.addEventListener("load", init); + +document.addEventListener("DOMContentLoaded", function() { + init(); +}, true);