“Widget:BMMOLatestUpdate”的版本间的差异
BallanceBug(讨论 | 贡献) |
BallanceBug(讨论 | 贡献) |
||
(未显示同一用户的2个中间版本) | |||
第1行: | 第1行: | ||
<span class="bmmo-latest-update"></span> | <span class="bmmo-latest-update"></span> | ||
<script> | <script> | ||
− | fetch("https://dl.bmmo. | + | fetch("https://dl.bmmo.win/download/latest?version-only=true") |
.then(res => res.json()) | .then(res => res.json()) | ||
.then(data => { | .then(data => { | ||
− | const lang = "<!--{$ | + | const lang = "<!--{$lang|default:'en'|escape:'html'}-->"; |
const dateLatest = new Date(data["time"] * 1e3); | const dateLatest = new Date(data["time"] * 1e3); | ||
let text = data["version"]; | let text = data["version"]; |
2024年9月27日 (五) 09:43的最新版本
<script> fetch("https://dl.bmmo.win/download/latest?version-only=true")
.then(res => res.json())
.then(data => {
const lang = "";
const dateLatest = new Date(data["time"] * 1e3);
let text = data["version"];
text += '';
if (lang == "zh") {
text += (`(${dateLatest.toLocaleDateString("zh-SG")},`
+ `${((new Date() - dateLatest) / 1e3 / 86400).toFixed(0)}日前)`);
} else {
text += (` (${dateLatest.toLocaleDateString("en-UK", {year: "numeric", month: "long", day: "numeric"})}, `
+ `${((new Date() - dateLatest) / 1e3 / 86400).toFixed(0)} day(s) ago)`);
}
text += '';
document.querySelectorAll(".bmmo-latest-update").forEach(el => {
el.innerHTML = text;
});
});
</script>