33 lines
1.1 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', 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(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));