move connection count refreshing into the header

pull/34/head
Zlatin Balevsky 2019-12-04 23:34:21 +00:00
parent 54b8628435
commit 06bd9c80e8
4 changed files with 20 additions and 37 deletions

View File

@ -31,21 +31,6 @@
<script>
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();
}
class Downloader {
constructor(xmlNode) {
this.name = xmlNode.getElementsByTagName("Name")[0].childNodes[0].nodeValue;
@ -107,8 +92,6 @@
xmlhttp.send();
}
setInterval(refreshConnectionsCount, 3000);
setTimeout(refreshConnectionsCount, 1);
setInterval(refreshDownloader, 3000)
setTimeout(refreshDownloader,1);
</script>

View File

@ -184,21 +184,6 @@
var lastXML = null;
var infoHash = null;
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 updateSender(senderName) {
sender = senderName;
@ -402,9 +387,6 @@
setInterval(refreshGroupByFile, 3000);
setTimeout(refreshGroupByFile, 1);
<% } %>
setInterval(refreshConnectionsCount, 3000);
setTimeout(refreshConnectionsCount, 1);
</script>
</body>
</html>

View File

@ -6,8 +6,27 @@
<div class="subtitle">
${persona}
<br>
Connections: <%=connectionCounter.getConnections() %>
<span id="connectionsCount">Connections : 0</span>
<br>
<script>
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();
}
setInterval(refreshConnectionsCount, 3000);
setTimeout(refreshConnectionsCount, 1);
</script>
<% if ("Home".equals(pagetitle)) { %>
<form action="/MuWire/Search" method="post">
<input type="text" name="search" />

View File

@ -1,6 +1,5 @@
<%
MuWireClient client = (MuWireClient) application.getAttribute("mwClient");
ConnectionCounter connectionCounter = (ConnectionCounter) client.getServletContext().getAttribute("connectionCounter");
String persona = client.getCore().getMe().getHumanReadableName();
String version = client.getCore().getVersion();
%>