@extends('layout') @section('content') {{--

Trick & Trip

@foreach ($trickTripItems as $item) @endforeach

--}} {{--

Trick & Trip


document.addEventListener("DOMContentLoaded", function () { const contentContainer = document.getElementById("trickTripContent"); const loadMoreButton = document.getElementById("loadMoreButton"); const titleContainer = document.getElementById("trick-trip-title"); const urlParams = new URLSearchParams(window.location.search); const typeParam = urlParams.get("type"); const apiUrl = "{{ env('APP_URL') }}/api/contents?type=" + typeParam; const itemsPerLoad = 9; // Number of items to show per load let allItems = []; // Store all fetched items let displayedItems = 0; // Counter for displayed items // Format date utility function function formatDate(dateString) { const options = { year: "numeric", month: "long", day: "numeric" }; return new Date(dateString).toLocaleDateString(undefined, options); } // Fetch data from API function fetchData() { fetch(apiUrl) .then(response => response.json()) .then(data => { if (data.status.statusType === "S") { allItems = data.data.filter(item => item.approved === "Y"); console.log(allItems); if (allItems.length > 0) { titleContainer.innerText = allItems[0].type_name; renderItems(); } else { titleContainer.innerText = "No Items Found"; loadMoreButton.style.display = "none"; } } else { console.error("Error:", data.status.errorMessage); } }) .catch(error => { console.error("Fetch error:", error); }); } // Render items incrementally function renderItems() { const nextItems = allItems.slice(displayedItems, displayedItems + itemsPerLoad); nextItems.forEach(item => { contentContainer.innerHTML += `
trick-trip

${item.title}

${item.description}

${formatDate(item.update_time)}

`; }); displayedItems += nextItems.length; // Hide Load More button if all items are displayed if (displayedItems >= allItems.length) { loadMoreButton.style.display = "none"; } } // Event listener for Load More button loadMoreButton.addEventListener("click", renderItems); // Initial fetch fetchData(); }); --}}

Trick & Trip


@endsection