Add Android BLE mesh client and project website
This commit is contained in:
50
website/assets/js/app.js
Normal file
50
website/assets/js/app.js
Normal file
@@ -0,0 +1,50 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const btn = document.getElementById('downloadBtn');
|
||||
const versionBadge = document.getElementById('versionBadge');
|
||||
const versionSummary = document.getElementById('versionSummary');
|
||||
const downloadMeta = document.getElementById('downloadMeta');
|
||||
if (!btn) return;
|
||||
|
||||
btn.addEventListener('click', (event) => {
|
||||
if (!btn.getAttribute('href') || btn.getAttribute('href') === '#') {
|
||||
event.preventDefault();
|
||||
alert('APK пока не опубликован. Следите за обновлениями проекта.');
|
||||
}
|
||||
});
|
||||
|
||||
fetch('assets/meta/version.json', { cache: 'no-store' })
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}`);
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then((meta) => {
|
||||
const sizeMb = (meta.apkSizeBytes / (1024 * 1024)).toFixed(1);
|
||||
const builtAt = new Date(meta.buildDateUtc).toLocaleString('ru-RU', {
|
||||
dateStyle: 'medium',
|
||||
timeStyle: 'short'
|
||||
});
|
||||
|
||||
if (versionBadge) {
|
||||
versionBadge.textContent = `v${meta.versionName} (${meta.versionCode})`;
|
||||
}
|
||||
if (versionSummary) {
|
||||
versionSummary.textContent = `Последняя сборка опубликована ${builtAt} UTC.`;
|
||||
}
|
||||
if (downloadMeta) {
|
||||
downloadMeta.textContent = `Доступна debug-сборка v${meta.versionName}. Размер APK: ${sizeMb} MB.`;
|
||||
}
|
||||
if (meta.apkPath) {
|
||||
btn.setAttribute('href', meta.apkPath);
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
if (versionBadge) {
|
||||
versionBadge.textContent = 'Версия недоступна';
|
||||
}
|
||||
if (versionSummary) {
|
||||
versionSummary.textContent = 'Не удалось загрузить метаданные сборки.';
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user