{"id":182,"date":"2026-04-24T08:46:08","date_gmt":"2026-04-24T08:46:08","guid":{"rendered":"https:\/\/louthlgfa.ie\/?page_id=182"},"modified":"2026-05-07T20:42:52","modified_gmt":"2026-05-07T20:42:52","slug":"front-page-v4","status":"publish","type":"page","link":"https:\/\/www.louthlgfa.ie\/","title":{"rendered":"Front Page V4"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\"><strong>Fixtures, Results &amp; Standings<\/strong><\/h3>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<button id=\"btnTodayFixtures\" \r\n    style=\"padding:10px 16px; font-size:16px; margin-bottom:15px;\">\r\n    Show Today&#8217;s Fixtures\r\n<\/button>\r\n\r\n<div id=\"todayFixturesOutput\"><\/div>\r\n\r\n<script>\r\ndocument.getElementById(\"btnTodayFixtures\").addEventListener(\"click\", async () => {\r\n\r\n    const out = document.getElementById(\"todayFixturesOutput\");\r\n    out.innerHTML = \"Loading today's fixtures\u2026\";\r\n\r\n    const apiKey = \"foir_prod_NDtiJNVWyQpxRRujIXMrCOZntNaqZfflFjihYbiLtqilV\";\r\n    const ownerId = \"0e2e84a8-2d94-dc94-d574-9d44d4c15395\";\r\n\r\n    \/\/ Today's date boundaries\r\n    const now = new Date();\r\n    const yyyy = now.getFullYear();\r\n    const mm = now.getMonth();\r\n    const dd = now.getDate();\r\n\r\n    const startOfDay = new Date(yyyy, mm, dd, 0, 0, 0);\r\n    const endOfDay   = new Date(yyyy, mm, dd, 23, 59, 59);\r\n\r\n    \/\/ Format date dd\/mm\/yyyy\r\n    const formattedDate = dd.toString().padStart(2, \"0\") + \"\/\" +\r\n                          (mm + 1).toString().padStart(2, \"0\") + \"\/\" +\r\n                          yyyy;\r\n\r\n    \/\/ Fetch fixtures\r\n    const res = await fetch(\r\n        \"https:\/\/api.foireann.ie\/open-data\/v1\/fixtures?size=500\",\r\n        { headers: { \"Authorization\": \"Bearer \" + apiKey } }\r\n    );\r\n\r\n    let fixtures = (await res.json()).data || [];\r\n\r\n    \/\/ Filter: owner, not archived, and today only\r\n    fixtures = fixtures.filter(f =>\r\n        !f.archived &&\r\n        f.owner?.id === ownerId &&\r\n        f.startDate &&\r\n        new Date(f.startDate) >= startOfDay &&\r\n        new Date(f.startDate) <= endOfDay\r\n    );\r\n\r\n    if (!fixtures.length) {\r\n        out.innerHTML = `<h3>Today's Fixtures (${formattedDate})<\/h3>\r\n                         <p>No fixtures scheduled for today.<\/p>`;\r\n        return;\r\n    }\r\n\r\n    \/\/ Group by competition\r\n    const comps = {};\r\n    fixtures.forEach(f => {\r\n        const id = f.competition?.id || \"unknown\";\r\n        if (!comps[id]) {\r\n            comps[id] = {\r\n                name: f.competition?.name || \"Unknown Competition\",\r\n                fixtures: []\r\n            };\r\n        }\r\n        comps[id].fixtures.push(f);\r\n    });\r\n\r\n    \/\/ Sort competitions alphabetically\r\n    const sortedCompIds = Object.keys(comps).sort((a, b) =>\r\n        comps[a].name.localeCompare(comps[b].name)\r\n    );\r\n\r\n    \/\/ Build HTML\r\n    let html = `<h3>Today's Fixtures (${formattedDate})<\/h3>`;\r\n\r\n    for (const compId of sortedCompIds) {\r\n        const comp = comps[compId];\r\n\r\n        html += `\r\n            <h4>${comp.name}<\/h4>\r\n            <table style=\"width:100%; border-collapse:collapse; margin-bottom:20px;\">\r\n                <thead>\r\n                    <tr>\r\n                        <th>Time<\/th>\r\n                        <th>Home<\/th>\r\n                        <th>Away<\/th>\r\n                        <th>Venue<\/th>\r\n                    <\/tr>\r\n                <\/thead>\r\n                <tbody>\r\n                    ${comp.fixtures.map(f => `\r\n                        <tr>\r\n                            <td>${new Date(f.startDate).toLocaleTimeString(\"en-GB\", { hour: \"2-digit\", minute: \"2-digit\" })}<\/td>\r\n                            <td>${f.homeTeam?.name || \"\"}<\/td>\r\n                            <td>${f.awayTeam?.name || \"\"}<\/td>\r\n                            <td>${f.place?.name || \"\"}<\/td>\r\n                        <\/tr>\r\n                    `).join(\"\")}\r\n                <\/tbody>\r\n            <\/table>\r\n        `;\r\n    }\r\n\r\n    out.innerHTML = html;\r\n});\r\n<\/script>\n\n\n\n<button id=\"btnClubFixtures\" \r\n    style=\"padding:10px 16px; font-size:16px; margin-bottom:15px;\">\r\n    Show Fixtures For My Club\r\n<\/button>\r\n\r\n<div id=\"clubFixturesContainer\"><\/div>\r\n\r\n<script>\r\ndocument.getElementById(\"btnClubFixtures\").addEventListener(\"click\", async () => {\r\n\r\n    const container = document.getElementById(\"clubFixturesContainer\");\r\n    container.innerHTML = \"Loading club list\u2026\";\r\n\r\n    const apiKey = \"foir_prod_NDtiJNVWyQpxRRujIXMrCOZntNaqZfflFjihYbiLtqilV\";\r\n    const ownerId = \"0e2e84a8-2d94-dc94-d574-9d44d4c15395\";\r\n\r\n    const res = await fetch(\r\n        \"https:\/\/api.foireann.ie\/open-data\/v1\/fixtures?size=500\",\r\n        { headers: { \"Authorization\": \"Bearer \" + apiKey } }\r\n    );\r\n\r\n    let fixtures = (await res.json()).data || [];\r\n\r\n    \/\/ Same logic as main dashboard\r\n    fixtures = fixtures.filter(f =>\r\n        !f.archived &&\r\n        f.owner?.id === ownerId &&\r\n        f.startDate &&\r\n        new Date(f.startDate).getFullYear() === 2026\r\n    );\r\n\r\n    \/\/ Build unique club list\r\n    const clubSet = new Set();\r\n    fixtures.forEach(f => {\r\n        if (f.homeTeam?.name) clubSet.add(f.homeTeam.name);\r\n        if (f.awayTeam?.name) clubSet.add(f.awayTeam.name);\r\n    });\r\n    const clubs = Array.from(clubSet).sort();\r\n\r\n    container.innerHTML = `\r\n        <input id=\"clubSearch\" type=\"text\" placeholder=\"Start typing a club name\u2026\"\r\n            style=\"width:100%; padding:10px; font-size:16px; border:1px solid #ccc; border-radius:4px; margin-bottom:10px;\">\r\n        <div id=\"clubSuggestions\" \r\n            style=\"border:1px solid #ccc; border-radius:4px; max-height:200px; overflow-y:auto; display:none;\"><\/div>\r\n        <div id=\"clubFixturesOutput\" style=\"margin-top:20px;\"><\/div>\r\n    `;\r\n\r\n    const searchInput = document.getElementById(\"clubSearch\");\r\n    const suggestions = document.getElementById(\"clubSuggestions\");\r\n    const output = document.getElementById(\"clubFixturesOutput\");\r\n\r\n    \/\/ Autocomplete\r\n    searchInput.addEventListener(\"input\", () => {\r\n        const term = searchInput.value.toLowerCase().trim();\r\n        suggestions.innerHTML = \"\";\r\n        if (!term) {\r\n            suggestions.style.display = \"none\";\r\n            return;\r\n        }\r\n\r\n        const matches = clubs.filter(c => c.toLowerCase().includes(term));\r\n\r\n        if (!matches.length) {\r\n            suggestions.style.display = \"none\";\r\n            return;\r\n        }\r\n\r\n        suggestions.style.display = \"block\";\r\n        suggestions.innerHTML = matches.map(c =>\r\n            `<div class=\"clubOption\" \r\n                style=\"padding:8px; cursor:pointer; border-bottom:1px solid #eee;\">\r\n                ${c}\r\n            <\/div>`\r\n        ).join(\"\");\r\n\r\n        document.querySelectorAll(\".clubOption\").forEach(opt => {\r\n            opt.onclick = () => {\r\n                const selected = opt.innerText.trim();\r\n                searchInput.value = selected;\r\n                suggestions.style.display = \"none\";\r\n                showClubFixtures(selected);\r\n            };\r\n        });\r\n    });\r\n\r\n    function showClubFixtures(clubName) {\r\n        output.innerHTML = \"Loading fixtures\u2026\";\r\n\r\n        const nameTerm = clubName.toLowerCase().trim();\r\n\r\n        \/\/ From today's date (00:00)\r\n        const today = new Date();\r\n        today.setHours(0, 0, 0, 0);\r\n\r\n        \/\/ Same matching logic as main dashboard (substring match)\r\n        const clubFixtures = fixtures.filter(f => {\r\n            const d = new Date(f.startDate);\r\n            if (d < today) return false;\r\n\r\n            const home = (f.homeTeam?.name || \"\").toLowerCase();\r\n            const away = (f.awayTeam?.name || \"\").toLowerCase();\r\n\r\n            return home.includes(nameTerm) || away.includes(nameTerm);\r\n        });\r\n\r\n        if (!clubFixtures.length) {\r\n            output.innerHTML = `<p>No upcoming fixtures for <strong>${clubName}<\/strong>.<\/p>`;\r\n            return;\r\n        }\r\n\r\n        \/\/ Group by competition\r\n        const comps = {};\r\n        clubFixtures.forEach(f => {\r\n            const id = f.competition?.id || \"unknown\";\r\n            if (!comps[id]) {\r\n                comps[id] = {\r\n                    name: f.competition?.name || \"Unknown Competition\",\r\n                    fixtures: []\r\n                };\r\n            }\r\n            comps[id].fixtures.push(f);\r\n        });\r\n\r\n        const sortedCompIds = Object.keys(comps).sort((a, b) =>\r\n            comps[a].name.localeCompare(comps[b].name)\r\n        );\r\n\r\n        let html = `<h3>Upcoming Fixtures for ${clubName}<\/h3>`;\r\n\r\n        for (const compId of sortedCompIds) {\r\n            const comp = comps[compId];\r\n\r\n            \/\/ \u2705 Sort fixtures by date ASC (nearest first)\r\n            comp.fixtures.sort((a, b) =>\r\n                new Date(a.startDate) - new Date(b.startDate)\r\n            );\r\n\r\n            html += `\r\n                <h4>${comp.name}<\/h4>\r\n                <table style=\"width:100%; border-collapse:collapse; margin-bottom:20px;\">\r\n                    <thead>\r\n                        <tr>\r\n                            <th>Date\/Time<\/th>\r\n                            <th>Home<\/th>\r\n                            <th>Away<\/th>\r\n                            <th>Venue<\/th>\r\n                        <\/tr>\r\n                    <\/thead>\r\n                    <tbody>\r\n                        ${comp.fixtures.map(f => {\r\n                            const home = f.homeTeam?.name || \"\";\r\n                            const away = f.awayTeam?.name || \"\";\r\n\r\n                            \/\/ \ud83d\udd25 Bold the selected club\r\n                            const homeHtml = home.toLowerCase().includes(nameTerm)\r\n                                ? `<strong>${home}<\/strong>`\r\n                                : home;\r\n\r\n                            const awayHtml = away.toLowerCase().includes(nameTerm)\r\n                                ? `<strong>${away}<\/strong>`\r\n                                : away;\r\n\r\n                            return `\r\n                                <tr>\r\n                                    <td>${new Date(f.startDate).toLocaleString(\"en-GB\", { \r\n                                        day: \"2-digit\", month: \"2-digit\", year: \"numeric\",\r\n                                        hour: \"2-digit\", minute: \"2-digit\"\r\n                                    })}<\/td>\r\n                                    <td>${homeHtml}<\/td>\r\n                                    <td>${awayHtml}<\/td>\r\n                                    <td>${f.place?.name || \"\"}<\/td>\r\n                                <\/tr>\r\n                            `;\r\n                        }).join(\"\")}\r\n                    <\/tbody>\r\n                <\/table>\r\n            `;\r\n        }\r\n\r\n        output.innerHTML = html;\r\n    }\r\n});\r\n<\/script>\n\n\n\n<button id=\"btnClubResults\" \r\n    style=\"padding:10px 16px; font-size:16px; margin-bottom:15px;\">\r\n    Show Results For My Club\r\n<\/button>\r\n\r\n<div id=\"clubResultsContainer\"><\/div>\r\n\r\n<script>\r\ndocument.getElementById(\"btnClubResults\").addEventListener(\"click\", async () => {\r\n\r\n    const container = document.getElementById(\"clubResultsContainer\");\r\n    container.innerHTML = \"Loading club list\u2026\";\r\n\r\n    const apiKey = \"foir_prod_NDtiJNVWyQpxRRujIXMrCOZntNaqZfflFjihYbiLtqilV\";\r\n    const ownerId = \"0e2e84a8-2d94-dc94-d574-9d44d4c15395\";\r\n\r\n    const res = await fetch(\r\n        \"https:\/\/api.foireann.ie\/open-data\/v1\/fixtures?size=500\",\r\n        { headers: { \"Authorization\": \"Bearer \" + apiKey } }\r\n    );\r\n\r\n    let fixtures = (await res.json()).data || [];\r\n\r\n    \/\/ Same logic as main dashboard\r\n    fixtures = fixtures.filter(f =>\r\n        !f.archived &&\r\n        f.owner?.id === ownerId &&\r\n        f.startDate &&\r\n        new Date(f.startDate).getFullYear() === 2026\r\n    );\r\n\r\n    \/\/ Extract club names\r\n    const clubSet = new Set();\r\n    fixtures.forEach(f => {\r\n        if (f.homeTeam?.name) clubSet.add(f.homeTeam.name);\r\n        if (f.awayTeam?.name) clubSet.add(f.awayTeam.name);\r\n    });\r\n    const clubs = Array.from(clubSet).sort();\r\n\r\n    container.innerHTML = `\r\n        <input id=\"clubSearchResults\" type=\"text\" placeholder=\"Start typing a club name\u2026\"\r\n            style=\"width:100%; padding:10px; font-size:16px; border:1px solid #ccc; border-radius:4px; margin-bottom:10px;\">\r\n        <div id=\"clubResultsSuggestions\" \r\n            style=\"border:1px solid #ccc; border-radius:4px; max-height:200px; overflow-y:auto; display:none;\"><\/div>\r\n        <div id=\"clubResultsOutput\" style=\"margin-top:20px;\"><\/div>\r\n    `;\r\n\r\n    const searchInput = document.getElementById(\"clubSearchResults\");\r\n    const suggestions = document.getElementById(\"clubResultsSuggestions\");\r\n    const output = document.getElementById(\"clubResultsOutput\");\r\n\r\n    \/\/ Autocomplete\r\n    searchInput.addEventListener(\"input\", () => {\r\n        const term = searchInput.value.toLowerCase().trim();\r\n        suggestions.innerHTML = \"\";\r\n        if (!term) {\r\n            suggestions.style.display = \"none\";\r\n            return;\r\n        }\r\n\r\n        const matches = clubs.filter(c => c.toLowerCase().includes(term));\r\n\r\n        if (!matches.length) {\r\n            suggestions.style.display = \"none\";\r\n            return;\r\n        }\r\n\r\n        suggestions.style.display = \"block\";\r\n        suggestions.innerHTML = matches.map(c =>\r\n            `<div class=\"clubOptionRes\" \r\n                style=\"padding:8px; cursor:pointer; border-bottom:1px solid #eee;\">\r\n                ${c}\r\n            <\/div>`\r\n        ).join(\"\");\r\n\r\n        document.querySelectorAll(\".clubOptionRes\").forEach(opt => {\r\n            opt.onclick = () => {\r\n                const selected = opt.innerText.trim();\r\n                searchInput.value = selected;\r\n                suggestions.style.display = \"none\";\r\n                showClubResults(selected);\r\n            };\r\n        });\r\n    });\r\n\r\n    function showClubResults(clubName) {\r\n        output.innerHTML = \"Loading results\u2026\";\r\n\r\n        const nameTerm = clubName.toLowerCase().trim();\r\n\r\n        \/\/ Identify results (same logic as main dashboard)\r\n        const results = fixtures.filter(f => {\r\n            const home = (f.homeTeam?.name || \"\").toLowerCase();\r\n            const away = (f.awayTeam?.name || \"\").toLowerCase();\r\n\r\n            const isResult =\r\n                f.isResult ||\r\n                f.homeTeam?.goals !== undefined ||\r\n                f.awayTeam?.goals !== undefined;\r\n\r\n            return isResult && (home.includes(nameTerm) || away.includes(nameTerm));\r\n        });\r\n\r\n        if (!results.length) {\r\n            output.innerHTML = `<p>No results found for <strong>${clubName}<\/strong>.<\/p>`;\r\n            return;\r\n        }\r\n\r\n        \/\/ Group by competition\r\n        const comps = {};\r\n        results.forEach(f => {\r\n            const id = f.competition?.id || \"unknown\";\r\n            if (!comps[id]) {\r\n                comps[id] = {\r\n                    name: f.competition?.name || \"Unknown Competition\",\r\n                    results: []\r\n                };\r\n            }\r\n            comps[id].results.push(f);\r\n        });\r\n\r\n        const sortedCompIds = Object.keys(comps).sort((a, b) =>\r\n            comps[a].name.localeCompare(comps[b].name)\r\n        );\r\n\r\n        let html = `<h3>Results for ${clubName}<\/h3>`;\r\n\r\n        for (const compId of sortedCompIds) {\r\n            const comp = comps[compId];\r\n\r\n            \/\/ Sort newest \u2192 oldest (same as main dashboard)\r\n            comp.results.sort((a, b) =>\r\n                new Date(b.startDate) - new Date(a.startDate)\r\n            );\r\n\r\n            html += `\r\n                <h4>${comp.name}<\/h4>\r\n                <table style=\"width:100%; border-collapse:collapse; margin-bottom:20px;\">\r\n                    <thead>\r\n                        <tr>\r\n                            <th>Date<\/th>\r\n                            <th>Home<\/th>\r\n                            <th>H<\/th>\r\n                            <th>Away<\/th>\r\n                            <th>A<\/th>\r\n                        <\/tr>\r\n                    <\/thead>\r\n                    <tbody>\r\n                        ${comp.results.map(f => {\r\n                            const home = f.homeTeam?.name || \"\";\r\n                            const away = f.awayTeam?.name || \"\";\r\n\r\n                            const homeHtml = home.toLowerCase().includes(nameTerm)\r\n                                ? `<strong>${home}<\/strong>`\r\n                                : home;\r\n\r\n                            const awayHtml = away.toLowerCase().includes(nameTerm)\r\n                                ? `<strong>${away}<\/strong>`\r\n                                : away;\r\n\r\n                            return `\r\n                                <tr>\r\n                                    <td>${new Date(f.startDate).toLocaleString(\"en-GB\")}<\/td>\r\n                                    <td>${homeHtml}<\/td>\r\n                                    <td>${(f.homeTeam?.goals ?? 0) + \"-\" + (f.homeTeam?.points ?? 0)}<\/td>\r\n                                    <td>${awayHtml}<\/td>\r\n                                    <td>${(f.awayTeam?.goals ?? 0) + \"-\" + (f.awayTeam?.points ?? 0)}<\/td>\r\n                                <\/tr>\r\n                            `;\r\n                        }).join(\"\")}\r\n                    <\/tbody>\r\n                <\/table>\r\n            `;\r\n        }\r\n\r\n        output.innerHTML = html;\r\n    }\r\n});\r\n<\/script>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<div id=\"multiCompDashboard\">Loading competitions\u2026<\/div>\n\n<style>\n.spinner {\n    display: inline-block;\n    width: 22px;\n    height: 22px;\n    border: 3px solid #ccc;\n    border-top-color: #333;\n    border-radius: 50%;\n    animation: spin 0.7s linear infinite;\n    margin-right: 8px;\n}\n@keyframes spin { to { transform: rotate(360deg); } }\n\n.compSection {\n    margin-top: 20px;\n}\n\n.toggleHint {\n    margin: 10px 0;\n    font-size: 0.9em;\n    color: #555;\n}\n\n.btnToggle {\n    margin-right: 10px;\n    margin-bottom: 10px;\n}\n<\/style>\n\n<script>\nfunction waitForElement(id, callback) {\n    const el = document.getElementById(id);\n    if (el) callback(el);\n    else setTimeout(() => waitForElement(id, callback), 50);\n}\n\nwaitForElement(\"multiCompDashboard\", function (dashboardEl) {\n\n(async () => {\n\n    const apiKey = \"foir_prod_NDtiJNVWyQpxRRujIXMrCOZntNaqZfflFjihYbiLtqilV\";\n    const ownerId = \"0e2e84a8-2d94-dc94-d574-9d44d4c15395\";\n\n    \/\/ -------------------------------------------------------\n    \/\/ 1\ufe0f\u20e3 FETCH FIXTURES ONCE TO BUILD COMPETITION LIST\n    \/\/ -------------------------------------------------------\n    const res = await fetch(\n        \"https:\/\/api.foireann.ie\/open-data\/v1\/fixtures?size=500\",\n        { headers: { \"Authorization\": \"Bearer \" + apiKey } }\n    );\n\n    let fixtures = (await res.json()).data || [];\n\n    fixtures = fixtures.filter(f =>\n        f.owner?.id === ownerId &&\n        f.startDate &&\n        new Date(f.startDate).getFullYear() === 2026\n    );\n\n    if (!fixtures.length) {\n        dashboardEl.innerHTML = \"<p>No competitions found for 2026.<\/p>\";\n        return;\n    }\n\n    \/\/ Build comp list\n    const comps = {};\n    fixtures.forEach(f => {\n        const id = f.competition?.id;\n        if (!id) return;\n        if (!comps[id]) {\n            comps[id] = f.competition?.name || \"Unknown Competition\";\n        }\n    });\n\n    const sortedIds = Object.keys(comps).sort((a, b) =>\n        comps[a].localeCompare(comps[b])\n    );\n\n    \/\/ -------------------------------------------------------\n    \/\/ 2\ufe0f\u20e3 RENDER DROPDOWN\n    \/\/ -------------------------------------------------------\n    let html = `\n        <h2>All Competitions (2026)<\/h2>\n        <label><strong>Select a competition:<\/strong><\/label><br>\n        <select id=\"compSelect\">\n            <option value=\"\">-- Choose Competition --<\/option>\n            ${sortedIds.map(id => `\n                <option value=\"${id}\">${comps[id]}<\/option>\n            `).join(\"\")}\n        <\/select>\n\n        <div id=\"compOutput\" class=\"compSection\"><\/div>\n    `;\n\n    dashboardEl.innerHTML = html;\n\n    const compSelect = document.getElementById(\"compSelect\");\n    const compOutput = document.getElementById(\"compOutput\");\n\n    \/\/ -------------------------------------------------------\n    \/\/ 3\ufe0f\u20e3 WHEN A COMP IS SELECTED \u2192 FETCH ALL DATA FOR THAT COMP\n    \/\/ -------------------------------------------------------\n    compSelect.addEventListener(\"change\", async () => {\n\n        const compId = compSelect.value;\n        if (!compId) {\n            compOutput.innerHTML = \"\";\n            return;\n        }\n\n        const compName = comps[compId];\n\n        \/\/ Show spinner + message for at least 1 second\n        compOutput.innerHTML = `\n            <div style=\"display:flex; align-items:center;\">\n                <div class=\"spinner\"><\/div>\n                <span>Gathering data for <strong>${compName}<\/strong> from Foireann\u2026<\/span>\n            <\/div>\n        `;\n\n        const startTime = Date.now();\n\n        \/\/ Fetch fixtures for this comp\n        const fixRes = await fetch(\n            \"https:\/\/api.foireann.ie\/open-data\/v1\/fixtures?size=500\",\n            { headers: { \"Authorization\": \"Bearer \" + apiKey } }\n        );\n        let allFix = (await fixRes.json()).data || [];\n\n        const compFixtures = allFix.filter(f =>\n            f.competition?.id === compId &&\n            f.startDate &&\n            new Date(f.startDate).getFullYear() === 2026\n        );\n\n        \/\/ Fetch standings\n        const tableRes = await fetch(\n            `https:\/\/api.foireann.ie\/open-data\/v1\/competitions?id=${compId}`,\n            { headers: { \"Authorization\": \"Bearer \" + apiKey } }\n        );\n        const compObj = (await tableRes.json()).data?.[0];\n\n        const tables = [];\n        if (compObj?.divisions) {\n            compObj.divisions.forEach(div => {\n                div.leagues?.forEach(lg => {\n                    if (lg.teams?.length) {\n                        tables.push({\n                            divisionName: div.name,\n                            leagueName: lg.name,\n                            teams: lg.teams\n                        });\n                    }\n                });\n            });\n        }\n\n        \/\/ Ensure spinner stays for at least 1 second\n        const elapsed = Date.now() - startTime;\n        if (elapsed < 1000) {\n            await new Promise(r => setTimeout(r, 1000 - elapsed));\n        }\n\n        \/\/ -------------------------------------------------------\n        \/\/ 4\ufe0f\u20e3 BUILD FIXTURES \/ RESULTS \/ STANDINGS HTML\n        \/\/ -------------------------------------------------------\n        const results = compFixtures.filter(f =>\n            f.isResult ||\n            f.homeTeam?.goals !== undefined ||\n            f.awayTeam?.goals !== undefined\n        );\n\n        const upcoming = compFixtures.filter(f => !results.includes(f));\n\n        results.sort((a, b) => new Date(b.startDate) - new Date(a.startDate));\n        upcoming.sort((a, b) => new Date(a.startDate) - new Date(b.startDate));\n\n        const resultsHtml = results.length ? `\n            <table class=\"resultsTable\" style=\"width:100%; border-collapse:collapse;\">\n                <thead>\n                    <tr><th>Date<\/th><th>Home<\/th><th>H<\/th><th>Away<\/th><th>A<\/th><\/tr>\n                <\/thead>\n                <tbody>\n                    ${results.map(f => `\n                        <tr>\n                            <td>${new Date(f.startDate).toLocaleString(\"en-GB\")}<\/td>\n                            <td>${f.homeTeam?.name}<\/td>\n                            <td>${f.homeTeam?.goals ?? 0}-${f.homeTeam?.points ?? 0}<\/td>\n                            <td>${f.awayTeam?.name}<\/td>\n                            <td>${f.awayTeam?.goals ?? 0}-${f.awayTeam?.points ?? 0}<\/td>\n                        <\/tr>\n                    `).join(\"\")}\n                <\/tbody>\n            <\/table>\n        ` : \"<p>No results available.<\/p>\";\n\n        const fixturesHtml = upcoming.length ? `\n            <table style=\"width:100%; border-collapse:collapse;\">\n                <thead>\n                    <tr><th>Date<\/th><th>Home<\/th><th>Away<\/th><th>Venue<\/th><th>Referee<\/th><th>Round<\/th><\/tr>\n                <\/thead>\n                <tbody>\n                    ${upcoming.map(f => `\n                        <tr>\n                            <td>${new Date(f.startDate).toLocaleString(\"en-GB\")}<\/td>\n                            <td>${f.homeTeam?.name}<\/td>\n                            <td>${f.awayTeam?.name}<\/td>\n                            <td>${f.place?.name || \"\"}<\/td>\n                            <td>${f.refereeName || f.referee?.name || \"\"}<\/td>\n                            <td>${f.round || \"\"}<\/td>\n                        <\/tr>\n                    `).join(\"\")}\n                <\/tbody>\n            <\/table>\n        ` : \"<p>No upcoming fixtures.<\/p>\";\n\n        const standingsHtml = tables.length ? `\n            ${tables.map(tbl => `\n                <h4>${tbl.divisionName} \u2013 ${tbl.leagueName}<\/h4>\n                <table style=\"width:100%; border-collapse:collapse;\">\n                    <thead>\n                        <tr>\n                            <th>R<\/th><th>Team<\/th><th>P<\/th><th>W<\/th><th>D<\/th><th>L<\/th>\n                            <th>PF<\/th><th>PA<\/th><th>PD<\/th><th>Pts<\/th>\n                        <\/tr>\n                    <\/thead>\n                    <tbody>\n                        ${tbl.teams.map(t => `\n                            <tr>\n                                <td>${t.rank}<\/td>\n                                <td>${t.name}<\/td>\n                                <td>${t.played}<\/td>\n                                <td>${t.won}<\/td>\n                                <td>${t.drawn}<\/td>\n                                <td>${t.lost}<\/td>\n                                <td>${t.pointsFor}<\/td>\n                                <td>${t.pointsAgainst}<\/td>\n                                <td>${t.pointsDifference}<\/td>\n                                <td>${t.totalPoints}<\/td>\n                            <\/tr>\n                        `).join(\"\")}\n                    <\/tbody>\n                <\/table>\n            `).join(\"\")}\n        ` : \"<p>No standings available.<\/p>\";\n\n        \/\/ -------------------------------------------------------\n        \/\/ 5\ufe0f\u20e3 RENDER UI WITH TOGGLE BUTTONS\n        \/\/ -------------------------------------------------------\n        compOutput.innerHTML = `\n            <h3>${compName}<\/h3>\n            <p class=\"toggleHint\">Click to show\/hide:<\/p>\n\n            <button class=\"btnToggle\" data-target=\"res\">Results<\/button>\n            <button class=\"btnToggle\" data-target=\"fix\">Fixtures<\/button>\n            <button class=\"btnToggle\" data-target=\"std\">Standings<\/button>\n\n            <div id=\"res\" style=\"display:none; margin-top:10px;\">${resultsHtml}<\/div>\n            <div id=\"fix\" style=\"display:none; margin-top:10px;\">${fixturesHtml}<\/div>\n            <div id=\"std\" style=\"display:none; margin-top:10px;\">${standingsHtml}<\/div>\n        `;\n\n        document.querySelectorAll(\".btnToggle\").forEach(btn => {\n            btn.onclick = () => {\n                const el = document.getElementById(btn.dataset.target);\n                el.style.display = el.style.display === \"none\" ? \"block\" : \"none\";\n            };\n        });\n\n    });\n\n})();\n});\n<\/script>\n","protected":false},"excerpt":{"rendered":"<p>Fixtures, Results &amp; Standings Show Today&#8217;s Fixtures Show Fixtures For My Club Show Results For My Club Loading competitions\u2026<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-182","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.louthlgfa.ie\/index.php?rest_route=\/wp\/v2\/pages\/182","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.louthlgfa.ie\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.louthlgfa.ie\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.louthlgfa.ie\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.louthlgfa.ie\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=182"}],"version-history":[{"count":8,"href":"https:\/\/www.louthlgfa.ie\/index.php?rest_route=\/wp\/v2\/pages\/182\/revisions"}],"predecessor-version":[{"id":230,"href":"https:\/\/www.louthlgfa.ie\/index.php?rest_route=\/wp\/v2\/pages\/182\/revisions\/230"}],"wp:attachment":[{"href":"https:\/\/www.louthlgfa.ie\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=182"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}