2025-05-22 16:13:58 +02:00

64 lines
2.0 KiB
JavaScript

document.querySelectorAll('nav ul li a').forEach(link => {
link.addEventListener('click', e => {
e.preventDefault();
const target = e.target.id.replace('nav-', '') + '-section';
document.querySelectorAll('main section').forEach(sec => sec.classList.add('hidden'));
const section = document.getElementById(target);
if (section) section.classList.remove('hidden');
});
});
document.getElementById('login-form')?.addEventListener('submit', function(e) {
e.preventDefault();
const username = document.getElementById('username').value;
alert(`Logging in as ${username}...`);
// TODO: call backend API for authentication
});
fetch("/gitea-repos/")
.then(res => res.json())
.then(repos => {
const list = document.getElementById("repo-list");
list.innerHTML = ""; // Clear "Loading..."
repos.forEach(function(repo) {
const item = document.createElement("li");
item.innerHTML = `
<strong><a href="${repo.html_url}" target="_blank">${repo.name}</a></strong>
<p>${repo.description || "No description"}</p>`;
list.appendChild(item);
});
})
.catch(err => console.error("Error fetching repos: ", err));
/*
onload
*/
window.addEventListener('DOMContentLoaded', function() {
const loadingScreen = document.getElementById('loading-screen');
if (loadingScreen) {
loadingScreen.addEventListener('click', function() {
loadingScreen.style.display = 'none'; // hides the full screen
});
}
});
document.addEventListener("DOMContentLoaded", function() {
const loadingScreen = document.getElementById('loading-screen');
const loadingText = document.querySelector('.loading-text');
loadingScreen.addEventListener('click', function() {
loadingScreen.style.display = 'none';
document.querySelector('.foreground-container').style.display = 'block';
});
});
document.getElementById("loading-screen").addEventListener("click", function() {
document.getElementById("loading-screen").style.display = "none";
const container = document.querySelector(".foreground-container");
container.classList.remove("hidden");
container.classList.add("fade-in");
});