up
This commit is contained in:
+13
-7
@@ -9,8 +9,8 @@ function parseLatestBuild(readme) {
|
||||
}
|
||||
|
||||
async function loadLatestBuild() {
|
||||
const status = document.getElementById('build-status');
|
||||
const download = document.getElementById('build-download');
|
||||
const statuses = document.querySelectorAll('.build-status');
|
||||
const downloads = document.querySelectorAll('.build-download');
|
||||
try {
|
||||
const response = await fetch('/minecraft/api/readme', {
|
||||
cache: 'no-store',
|
||||
@@ -23,12 +23,18 @@ async function loadLatestBuild() {
|
||||
}
|
||||
const readme = new TextDecoder().decode(Uint8Array.from(atob(data.content), char => char.charCodeAt(0)));
|
||||
const build = parseLatestBuild(readme);
|
||||
status.textContent = `Актуальная версия — ${build.version}`;
|
||||
download.href = build.url;
|
||||
download.textContent = `Скачать сборку ${build.version}`;
|
||||
download.hidden = false;
|
||||
for (const status of statuses) {
|
||||
status.textContent = `Актуальная версия — ${build.version}`;
|
||||
}
|
||||
for (const download of downloads) {
|
||||
download.href = build.url;
|
||||
download.textContent = `Скачать сборку ${build.version}`;
|
||||
download.hidden = false;
|
||||
}
|
||||
} catch {
|
||||
status.textContent = 'Не удалось определить актуальную версию. Открой репозиторий по ссылке внизу страницы.';
|
||||
for (const status of statuses) {
|
||||
status.textContent = 'Не удалось определить актуальную версию. Кнопка откроет репозиторий — выбери актуальную сборку в README.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user