mirror of
https://github.com/librespeed/speedtest.git
synced 2026-05-13 08:16:36 +00:00
Revert "Use server-list.json in classic frontend by default"
This reverts commit fdb1681aad.
This commit is contained in:
parent
8449b94ad6
commit
fd76790860
1 changed files with 41 additions and 47 deletions
|
|
@ -36,58 +36,52 @@
|
|||
|
||||
//SERVER AUTO SELECTION
|
||||
function initServers() {
|
||||
var showStandaloneUI = function () {
|
||||
if (SPEEDTEST_SERVERS.length == 0) { //standalone installation
|
||||
//just make the UI visible
|
||||
I("loading").className = "hidden";
|
||||
I("serverArea").style.display = "none";
|
||||
I("testWrapper").className = "visible";
|
||||
initUI();
|
||||
}
|
||||
var noServersAvailable = function () {
|
||||
I("message").innerHTML = "No servers available";
|
||||
}
|
||||
var runServerSelect = function () {
|
||||
s.selectServer(function (server) {
|
||||
if (server != null) { //at least 1 server is available
|
||||
I("loading").className = "hidden"; //hide loading message
|
||||
//populate server list for manual selection
|
||||
for (var i = 0; i < SPEEDTEST_SERVERS.length; i++) {
|
||||
if (SPEEDTEST_SERVERS[i].pingT == -1) continue;
|
||||
var option = document.createElement("option");
|
||||
option.value = i;
|
||||
option.textContent = SPEEDTEST_SERVERS[i].name;
|
||||
if (SPEEDTEST_SERVERS[i] === server) option.selected = true;
|
||||
I("server").appendChild(option);
|
||||
}
|
||||
//show test UI
|
||||
I("testWrapper").className = "visible";
|
||||
initUI();
|
||||
} else { //no servers are available, the test cannot proceed
|
||||
noServersAvailable();
|
||||
}
|
||||
});
|
||||
}
|
||||
var loadServerList = function (serverListUrl, onFailure) {
|
||||
s.loadServerList(serverListUrl, function (servers) {
|
||||
if (servers == null || servers.length == 0) {
|
||||
onFailure();
|
||||
} else {
|
||||
SPEEDTEST_SERVERS = servers;
|
||||
s.addTestPoints(SPEEDTEST_SERVERS);
|
||||
runServerSelect();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof SPEEDTEST_SERVERS === "string") {
|
||||
//need to fetch list of servers from specified URL
|
||||
loadServerList(SPEEDTEST_SERVERS, noServersAvailable);
|
||||
} else if (SPEEDTEST_SERVERS.length == 0) {
|
||||
//standalone installation by default, but use server-list.json if present
|
||||
loadServerList("server-list.json", showStandaloneUI);
|
||||
} else { //multiple servers
|
||||
//hardcoded server list
|
||||
s.addTestPoints(SPEEDTEST_SERVERS);
|
||||
runServerSelect();
|
||||
var noServersAvailable = function () {
|
||||
I("message").innerHTML = "No servers available";
|
||||
}
|
||||
var runServerSelect = function () {
|
||||
s.selectServer(function (server) {
|
||||
if (server != null) { //at least 1 server is available
|
||||
I("loading").className = "hidden"; //hide loading message
|
||||
//populate server list for manual selection
|
||||
for (var i = 0; i < SPEEDTEST_SERVERS.length; i++) {
|
||||
if (SPEEDTEST_SERVERS[i].pingT == -1) continue;
|
||||
var option = document.createElement("option");
|
||||
option.value = i;
|
||||
option.textContent = SPEEDTEST_SERVERS[i].name;
|
||||
if (SPEEDTEST_SERVERS[i] === server) option.selected = true;
|
||||
I("server").appendChild(option);
|
||||
}
|
||||
//show test UI
|
||||
I("testWrapper").className = "visible";
|
||||
initUI();
|
||||
} else { //no servers are available, the test cannot proceed
|
||||
noServersAvailable();
|
||||
}
|
||||
});
|
||||
}
|
||||
if (typeof SPEEDTEST_SERVERS === "string") {
|
||||
//need to fetch list of servers from specified URL
|
||||
s.loadServerList(SPEEDTEST_SERVERS, function (servers) {
|
||||
if (servers == null) { //failed to load server list
|
||||
noServersAvailable();
|
||||
} else { //server list loaded
|
||||
SPEEDTEST_SERVERS = servers;
|
||||
runServerSelect();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
//hardcoded server list
|
||||
s.addTestPoints(SPEEDTEST_SERVERS);
|
||||
runServerSelect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue