// programmer/static/programmer/js/profile.js
function openModalContent(el) {
    const url = el.dataset.url;
    const title = el.querySelector('h4').innerText;
    const modal = document.getElementById('contentModal');
    const body = document.getElementById('contentModalBody');
    const titleEl = document.getElementById('contentModalTitle');
    titleEl.textContent = title;
    body.innerHTML = '<p>Загрузка...</p>';
    modal.style.display = 'block';
    fetch(url)
        .then(response => response.text())
        .then(html => {
            body.innerHTML = html;
        })
        .catch(() => {
            body.innerHTML = '<p style="color:red;">Ошибка загрузки. Попробуйте позже.</p>';
        });
}

function closeContentModal() {
    document.getElementById('contentModal').style.display = 'none';
}
// Закрытие по клику на фон и ESC
document.addEventListener('click', function(e) {
    if (e.target === document.getElementById('contentModal')) closeContentModal();
});
document.addEventListener('keydown', function(e) {
    if (e.key === 'Escape') closeContentModal();
});