小无编辑摘要 |
无编辑摘要 |
||
| (未显示同一用户的2个中间版本) | |||
| 第3行: | 第3行: | ||
if ($("#live-delay-info").length > 0) { | if ($("#live-delay-info").length > 0) { | ||
$.getJSON(" | $.getJSON("https://seu.complexstudio.net/mirror/srcity.mc/mc/sysmap/data") | ||
.done(function (data) { | .done(function (data) { | ||
var routeNameSet = new Set(); | |||
var delayedNames = []; | var delayedNames = []; | ||
data[0].routes.forEach(function(route) { | data[0].routes.forEach(function(route) { | ||
var routeName = route.name.split("|")[0]; | |||
routeNameSet.add(routeName); | |||
if (route.maxWaitTime > 2400) { | if (route.maxWaitTime > 2400) { | ||
if (delayedNames.indexOf(routeName) < 0) { | if (delayedNames.indexOf(routeName) < 0) { | ||
delayedNames.push(routeName); | delayedNames.push(routeName); | ||
| 第14行: | 第16行: | ||
} | } | ||
}); | }); | ||
var statusText = "星海市现有 " + routeNameSet.size + " 条线路, " + Object.keys(data[0].stations).length + " 处车站。"; | |||
if (delayedNames.length > 0) { | if (delayedNames.length > 0) { | ||
statusText += "<br/><b style='color:red'>有线路发生阻塞:" + delayedNames.join("、") + "。</b>"; | |||
} | } | ||
$("#live-delay-info").html(statusText); | |||
}) | }) | ||
.fail(function (xhr, textStatus) { | .fail(function (xhr, textStatus) { | ||
2022年11月28日 (一) 23:06的最新版本
/* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */
$(function() {
if ($("#live-delay-info").length > 0) {
$.getJSON("https://seu.complexstudio.net/mirror/srcity.mc/mc/sysmap/data")
.done(function (data) {
var routeNameSet = new Set();
var delayedNames = [];
data[0].routes.forEach(function(route) {
var routeName = route.name.split("|")[0];
routeNameSet.add(routeName);
if (route.maxWaitTime > 2400) {
if (delayedNames.indexOf(routeName) < 0) {
delayedNames.push(routeName);
}
}
});
var statusText = "星海市现有 " + routeNameSet.size + " 条线路, " + Object.keys(data[0].stations).length + " 处车站。";
if (delayedNames.length > 0) {
statusText += "<br/><b style='color:red'>有线路发生阻塞:" + delayedNames.join("、") + "。</b>";
}
$("#live-delay-info").html(statusText);
})
.fail(function (xhr, textStatus) {
if (xhr.status == 502) {
$("#live-delay-info").html("服务器当前未启动,或处于休眠状态。");
} else {
$("#live-delay-info").html("<b style='color:red'>获取信息失败: " + xhr.status + " " + textStatus + "。</b>");
}
});
}
}());