/** * Lakics Admin Panel - Frontend Integration * * This file provides JavaScript functions to integrate the Referencia API * with your existing Lakics2025 HTML frontend. * * Usage: * 1. Include this file in your referenciak.html * 2. Call loadReferencias() to fetch and display data * 3. Customize the displayReferencias() function to match your HTML structure */ // Configuration - Now that Laravel serves the frontend, we can use relative URLs const API_BASE_URL = ''; // Empty string for relative URLs since everything is served through Laravel /** * Fetch all referencias from the API */ async function loadReferencias() { try { showLoading(); const response = await fetch(`${API_BASE_URL}/api/referenciak`); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); if (data.success) { displayReferencias(data.data); } else { showError('Failed to load referencias'); } } catch (error) { console.error('Error loading referencias:', error); showError('Error loading referencias: ' + error.message); } finally { hideLoading(); } } /** * Display referencias in the HTML * Uses the existing card-columns Bootstrap layout */ function displayReferencias(referencias) { const container = document.getElementById('referencias-container'); if (!container) { console.error('Container element with ID "referencias-container" not found'); return; } // Clear existing content container.innerHTML = ''; if (referencias.length === 0) { container.innerHTML = '
Nincsenek referenciák.
Kattintson bárhova a bezáráshoz
`; modal.appendChild(modalContent); document.body.appendChild(modal); // Close modal on click modal.addEventListener('click', function() { document.body.removeChild(modal); }); // Prevent closing when clicking on the content modalContent.addEventListener('click', function(e) { e.stopPropagation(); }); } /** * Fetch a single referencia by ID */ async function loadReferencia(id) { try { const response = await fetch(`${API_BASE_URL}/api/referenciak/${id}`); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); if (data.success) { return data.data; } else { throw new Error('Referencia not found'); } } catch (error) { console.error('Error loading referencia:', error); throw error; } } /** * Show loading indicator */ function showLoading() { const container = document.getElementById('referencias-container'); if (container) { container.innerHTML = 'Referenciák betöltése...
Hiba: ${escapeHtml(message)}