Files
Phoenix/www/ui/changelog.js
T

31 lines
905 B
JavaScript

let loadPromise = null;
export function setupLazyChangelog(details, content) {
if (!details || !content || details.dataset.bound === '1') return;
details.dataset.bound = '1';
const load = async () => {
if (content.dataset.loaded === '1') return;
if (!loadPromise) {
loadPromise = fetch('./changelog.html', { cache: 'no-cache' })
.then((response) => {
if (!response.ok) throw new Error(`HTTP ${response.status}`);
return response.text();
});
}
try {
content.innerHTML = await loadPromise;
content.dataset.loaded = '1';
} catch (error) {
loadPromise = null;
content.textContent = 'Versionsverlauf konnte nicht geladen werden.';
console.warn('Changelog load error:', error);
}
};
details.addEventListener('toggle', () => {
if (details.open) void load();
});
if (details.open) void load();
}