Wizard: Ajax fixes for IE (thx zlatinb) (summary bar also)

Form notices on results panel
Hide results if skipped
This commit is contained in:
zzz
2018-11-18 13:43:18 +00:00
parent 09ea40ce8e
commit 13d80e604d
6 changed files with 35 additions and 2 deletions

View File

@ -224,7 +224,7 @@ public class MLabRunner {
results.put("down", down_bps);
results.put("server_host", server_host);
if (server_city != null)
results.put("server_city", server_city);
results.put("server_city", server_city.replace("_", ", "));
if (server_country != null)
results.put("server_country", server_country);
listener.complete(results);

View File

@ -46,6 +46,19 @@ public class WizardHandler extends FormHandler {
}
if ("4".equals(page)) {
startNDT();
} else if ("5".equals(page)) {
synchronized (_helper) {
if (_helper.isNDTSuccessful()) {
addFormNotice(_t("Bandwidth test completed successfully"));
} else if (_helper.isNDTComplete()) {
addFormError(_t("Bandwidth test failed"));
} else if (_helper.isNDTRunning()) {
addFormError(_t("Bandwidth test did not complete"));
} else {
// didn't run at all?
addFormError(_t("Bandwidth test did not complete"));
}
}
} else if ("6".equals(page)) {
Map<String, String> changes = new HashMap<String, String>();
boolean updated = updateRates(changes);

View File

@ -55,6 +55,10 @@ public class WizardHelper extends HelperBase {
return _listener != null && !_listener.isComplete();
}
public synchronized boolean isNDTSuccessful() {
return isNDTComplete() && getUpBandwidth() > 0 && getDownBandwidth() > 0;
}
/**
* @return HTML-escaped status string or ""
*/

View File

@ -6,6 +6,8 @@ function ajax(url, target, refresh) {
req = new XMLHttpRequest();
req.onreadystatechange = function() {ajaxDone(url, target, refresh);};
req.open("GET", url, true);
// IE https://www.jamesmaurer.com/ajax-refresh-problem-w-ie-not-refreshing.asp
req.setRequestHeader("If-Modified-Since","Sat, 1 Jan 2000 00:00:00 GMT");
req.send(null);
// IE/Windows ActiveX version
} else if (window.ActiveXObject) {
@ -13,6 +15,8 @@ function ajax(url, target, refresh) {
if (req) {
req.onreadystatechange = function() {ajaxDone(target);};
req.open("GET", url, true);
// IE https://www.jamesmaurer.com/ajax-refresh-problem-w-ie-not-refreshing.asp
req.setRequestHeader("If-Modified-Since","Sat, 1 Jan 2000 00:00:00 GMT");
req.send(null);
}
}

View File

@ -6,6 +6,8 @@ function ajax(url, target, refresh) {
req = new XMLHttpRequest();
req.onreadystatechange = function() {ajaxDone(url, target, refresh);};
req.open("GET", url, true);
// IE https://www.jamesmaurer.com/ajax-refresh-problem-w-ie-not-refreshing.asp
req.setRequestHeader("If-Modified-Since","Sat, 1 Jan 2000 00:00:00 GMT");
req.send(null);
// IE/Windows ActiveX version
} else if (window.ActiveXObject) {
@ -13,6 +15,8 @@ function ajax(url, target, refresh) {
if (req) {
req.onreadystatechange = function() {ajaxDone(target);};
req.open("GET", url, true);
// IE https://www.jamesmaurer.com/ajax-refresh-problem-w-ie-not-refreshing.asp
req.setRequestHeader("If-Modified-Since","Sat, 1 Jan 2000 00:00:00 GMT");
req.send(null);
}
}
@ -29,7 +33,8 @@ function ajaxDone(url, target, refresh) {
// output 1 for complete, 0 + status string for in progress
fails = 0;
var status;
if (req.responseText.startsWith("1")) {
// IE doesn't support startsWith()
if (req.responseText.indexOf("1") == 0) {
results = doneMessage;
running = false;
done = true;

View File

@ -163,6 +163,10 @@
%>
<jsp:useBean class="net.i2p.router.web.helpers.ConfigNetHelper" id="nethelper" scope="request" />
<jsp:setProperty name="nethelper" property="contextId" value="<%=i2pcontextId%>" />
<%
if (request.getParameter("skipbw") == null) {
// don't display this if we skipped the test
%>
<h3><%=intl._t("Bandwidth Test Results")%></h3>
<table class="configtable">
<tr><td><%=intl._t("Test running?")%></td><td><%=wizhelper.isNDTRunning()%></td></tr>
@ -174,6 +178,9 @@
<tr><td><%=intl._t("Upstream Bandwidth")%></td><td><%=net.i2p.data.DataHelper.formatSize2Decimal(wizhelper.getUpBandwidth())%>Bps</td></tr>
<tr><td><%=intl._t("Share of Bandwidth for I2P")%></td><td><%=Math.round(net.i2p.router.web.helpers.WizardHelper.BW_SCALE * 100)%>%</td></tr>
</table>
<%
} // skipbw
%>
<h3><%=intl._t("Bandwidth Configuration")%></h3>
<table id="bandwidthconfig" class="configtable">
<tr><td class="infohelp" colspan="2">