From d46fbd66f065c7240e62bd854872ed9017e30f87 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Thu, 5 Dec 2019 10:38:24 +0000 Subject: [PATCH] move connection count into a separate js file, thanks zzz --- webui/build.gradle | 5 ++++- webui/src/main/js/conncount.js | 19 +++++++++++++++++++ webui/src/main/webapp/Downloads.jsp | 2 +- webui/src/main/webapp/Home.jsp | 2 +- webui/src/main/webapp/css.jsi | 1 + webui/src/main/webapp/header.jsi | 19 ------------------- 6 files changed, 26 insertions(+), 22 deletions(-) create mode 100644 webui/src/main/js/conncount.js diff --git a/webui/build.gradle b/webui/build.gradle index dc6fba49..90743ccd 100644 --- a/webui/build.gradle +++ b/webui/build.gradle @@ -17,11 +17,14 @@ war { from ('src/main/images', { into "images" }) + from ('src/main/js', { + into "js" + }) webInf { from "$buildDir/compiledJsps" into "classes" } - excludes = new HashSet(['**/*.jsp']) + excludes = new HashSet(['**/*.jsp', '**/*.jsi']) webXml = file("$buildDir/tmp_jsp/web.xml") } diff --git a/webui/src/main/js/conncount.js b/webui/src/main/js/conncount.js new file mode 100644 index 00000000..0b7d21c0 --- /dev/null +++ b/webui/src/main/js/conncount.js @@ -0,0 +1,19 @@ +function refreshConnectionsCount() { + var xmlhttp = new XMLHttpRequest(); + xmlhttp.onreadystatechange = function() { + if (this.readyState == 4 && this.status == 200) { + var connections = this.responseXML.getElementsByTagName("Connections"); + var count = connections[0].childNodes[0].nodeValue + var connectionCountSpan = document.getElementById("connectionsCount"); + var countString = "Connections: "+count; + connectionCountSpan.innerHTML = countString; + } + } + xmlhttp.open("GET", "/MuWire/Search?section=connectionsCount", true); + xmlhttp.send(); +} + +function initConnectionsCount() { + setInterval(refreshConnectionsCount, 3000); + setTimeout(refreshConnectionsCount, 1); +} diff --git a/webui/src/main/webapp/Downloads.jsp b/webui/src/main/webapp/Downloads.jsp index bc2bb272..28f4992e 100644 --- a/webui/src/main/webapp/Downloads.jsp +++ b/webui/src/main/webapp/Downloads.jsp @@ -16,7 +16,7 @@ <%@include file="css.jsi"%> - + <%@include file="header.jsi"%>

Downloads:

diff --git a/webui/src/main/webapp/Home.jsp b/webui/src/main/webapp/Home.jsp index d6664f6f..59734f0f 100644 --- a/webui/src/main/webapp/Home.jsp +++ b/webui/src/main/webapp/Home.jsp @@ -20,7 +20,7 @@ <%@include file="css.jsi"%> - + <%@include file="header.jsi"%> <% if (groupBy.equals("sender")) { %>
Group By File
diff --git a/webui/src/main/webapp/css.jsi b/webui/src/main/webapp/css.jsi index 1849982a..031f4c26 100644 --- a/webui/src/main/webapp/css.jsi +++ b/webui/src/main/webapp/css.jsi @@ -1,3 +1,4 @@ MuWire ${version} + diff --git a/webui/src/main/webapp/header.jsi b/webui/src/main/webapp/header.jsi index 3aa246ee..90797d5a 100644 --- a/webui/src/main/webapp/header.jsi +++ b/webui/src/main/webapp/header.jsi @@ -8,25 +8,6 @@
Connections : 0
- <% if ("Home".equals(pagetitle)) { %>