diff --git a/assets/js/main.js b/assets/js/main.js index 7a0bc05..a2afbad 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -1,9 +1,33 @@ +async function loadProfile(userId) { + console.log("loadProfile called for user:", userId); + const modal = document.getElementById('profileModal'); + const content = document.getElementById('profileModalContent'); + if (!modal || !content) { + console.error("Profile modal elements not found"); + return; + } + + try { + const response = await fetch('api/get_profile.php?user_id=' + userId); + const data = await response.json(); + if (data.html) { + content.innerHTML = data.html; + modal.style.display = 'flex'; + } else { + console.error("No HTML returned from profile API"); + } + } catch (error) { + console.error('Error loading profile:', error); + } +} + document.addEventListener('DOMContentLoaded', () => { const chatForm = document.getElementById('chat-form'); const chatInput = document.getElementById('chat-input'); const chatMessages = document.getElementById('chat-messages'); const appendMessage = (text, sender) => { + if (!chatMessages) return; const msgDiv = document.createElement('div'); msgDiv.classList.add('message', sender); msgDiv.textContent = text; @@ -39,20 +63,3 @@ document.addEventListener('DOMContentLoaded', () => { }); } }); - -async function loadProfile(userId) { - const modal = document.getElementById('profileModal'); - const content = document.getElementById('profileModalContent'); - if (!modal || !content) return; - - try { - const response = await fetch('api/get_profile.php?user_id=' + userId); - const data = await response.json(); - if (data.html) { - content.innerHTML = data.html; - modal.style.display = 'flex'; - } - } catch (error) { - console.error('Error loading profile:', error); - } -} \ No newline at end of file diff --git a/index.php b/index.php index 932947f..d21ff5d 100644 --- a/index.php +++ b/index.php @@ -4,9 +4,6 @@ require_once 'includes/status_helper.php'; session_start(); $db = db(); -// HEADER IS NOW IN includes/header.php -// But we still need some data for the map and modals in index.php - $user_role = $_SESSION['user_role'] ?? 'user'; $view = isset($_GET['view']) ? $_GET['view'] : 'sector'; @@ -176,6 +173,7 @@ function getStatusColor($status, $statuses_map) { Nexus - <?php echo $page_title; ?> +