move connection count into a separate js file, thanks zzz

pull/34/head
Zlatin Balevsky 2019-12-05 10:38:24 +00:00
parent 06bd9c80e8
commit d46fbd66f0
6 changed files with 26 additions and 22 deletions

View File

@ -17,11 +17,14 @@ war {
from ('src/main/images', { from ('src/main/images', {
into "images" into "images"
}) })
from ('src/main/js', {
into "js"
})
webInf { webInf {
from "$buildDir/compiledJsps" from "$buildDir/compiledJsps"
into "classes" into "classes"
} }
excludes = new HashSet(['**/*.jsp']) excludes = new HashSet(['**/*.jsp', '**/*.jsi'])
webXml = file("$buildDir/tmp_jsp/web.xml") webXml = file("$buildDir/tmp_jsp/web.xml")
} }

View File

@ -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);
}

View File

@ -16,7 +16,7 @@
<head> <head>
<%@include file="css.jsi"%> <%@include file="css.jsi"%>
</head> </head>
<body> <body onload="initConnectionsCount()">
<%@include file="header.jsi"%> <%@include file="header.jsi"%>
<p>Downloads:</p> <p>Downloads:</p>

View File

@ -20,7 +20,7 @@
<head> <head>
<%@include file="css.jsi"%> <%@include file="css.jsi"%>
</head> </head>
<body> <body onload="initConnectionsCount()">
<%@include file="header.jsi"%> <%@include file="header.jsi"%>
<% if (groupBy.equals("sender")) { %> <% if (groupBy.equals("sender")) { %>
<center><a href="/MuWire/Home.jsp?groupBy=file">Group By File</a></center> <center><a href="/MuWire/Home.jsp?groupBy=file">Group By File</a></center>

View File

@ -1,3 +1,4 @@
<title>MuWire ${version}</title> <title>MuWire ${version}</title>
<link href="i2pbote.css?${version}" rel="stylesheet" type="text/css"> <link href="i2pbote.css?${version}" rel="stylesheet" type="text/css">
<link href="muwire.css?${version}" rel="stylesheet" type="text/css"> <link href="muwire.css?${version}" rel="stylesheet" type="text/css">
<script src="js/conncount.js" type="text/javascript"></script>

View File

@ -8,25 +8,6 @@
<br> <br>
<span id="connectionsCount">Connections : 0</span> <span id="connectionsCount">Connections : 0</span>
<br> <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)) { %> <% if ("Home".equals(pagetitle)) { %>
<form action="/MuWire/Search" method="post"> <form action="/MuWire/Search" method="post">
<input type="text" name="search" /> <input type="text" name="search" />