{"id":343,"date":"2026-08-26T14:07:05","date_gmt":"2026-08-26T13:07:05","guid":{"rendered":"https:\/\/dev.folkale.co.uk\/?page_id=343"},"modified":"2026-08-26T15:12:32","modified_gmt":"2026-08-26T14:12:32","slug":"live-information","status":"publish","type":"page","link":"https:\/\/dev.folkale.co.uk\/?page_id=343","title":{"rendered":"Live information"},"content":{"rendered":"\n<div id=\"folkale-live\">\n    <div class=\"folkale-live-box\">\n        <h2>\ud83d\udccd Live Information<\/h2>\n        <p id=\"folkale-live-status\">Checking your location\u2026<\/p>\n    <\/div>\n<\/div>\n\n<style>\n.folkale-live-item {\n    background: #fff;\n    color: #333;\n    padding: 25px 30px;\n    margin-bottom: 25px;\n    border-radius: 8px;\n    box-shadow: 0 2px 8px rgba(0,0,0,0.08);\n}\n\n.folkale-live-item h3 {\n    color: #222;\n    margin-top: 0;\n    margin-bottom: 12px;\n}\n\n.folkale-live-item p {\n    color: #333;\n    margin-bottom: 0;\n}\n\n.folkale-live-status-box {\n    text-align: center;\n    color: #333;\n}\n\n.folkale-live-updated {\n    color: #555;\n    text-align: center;\n    font-size: 0.85em;\n    opacity: 0.65;\n    margin-top: 30px;\n}\n\n.folkale-live-icon {\n    font-size: 2em;\n    line-height: 1;\n    margin-bottom: 12px;\n}\n\n.folkale-live-item {\n    background: #fff;\n    color: #333;\n    padding: 25px 30px;\n    margin-bottom: 25px;\n    border-radius: 8px;\n    box-shadow: 0 2px 8px rgba(0,0,0,0.08);\n}\n\n.folkale-live-item h3 {\n    color: #222;\n    margin-top: 0;\n    margin-bottom: 12px;\n}\n\n.folkale-live-item p {\n    color: #333;\n    margin-bottom: 0;\n}\n\n.folkale-live-status-box {\n    text-align: center;\n    color: #333;\n}\n\n.folkale-live-updated {\n    color: #555;\n    text-align: center;\n    font-size: 0.85em;\n    opacity: 0.65;\n    margin-top: 30px;\n}\n<\/style>\n\n<script>\n(function () {\n\n    \/*\n     * LOCATION SETTINGS\n     *\n     * testing = true  -> temporary home location\n     * testing = false -> real Folk Ale location\n     *\/\n\n    const testing = false;\n\n    \/\/ REAL FOLK ALE LOCATION\n    const festivalLat = 51.226103;\n    const festivalLon = 0.202922;\n    const festivalRadius = 500;\n\n    \/\/ TEMPORARY TEST LOCATION\n    const testLat = 51.335892;\n    const testLon = 1.426473;\n    const testRadius = 100;\n\n    const checkLat = testing ? testLat : festivalLat;\n    const checkLon = testing ? testLon : festivalLon;\n    const allowedDistance = testing ? testRadius : festivalRadius;\n\n    const apiUrl = 'https:\/\/photos.folkale.co.uk\/api\/live.php';\n\n    const status = document.getElementById('folkale-live-status');\n\n    \/*\n     * Icons for announcement types\n     *\/\n    const icons = {\n        info: '\u2139\ufe0f',\n        important: '\u26a0\ufe0f',\n        music: '\ud83c\udfb5',\n        food: '\ud83c\udf54',\n        campsite: '\ud83c\udfd5\ufe0f',\n        urgent: '\ud83d\udea8'\n    };\n\n    function showStatus(message) {\n\n        status.innerHTML =\n            '<div class=\"folkale-live-item folkale-live-status-box\">' +\n            '<p>' + message + '<\/p>' +\n            '<\/div>';\n\n    }\n\n    function escapeHtml(text) {\n\n        const div = document.createElement('div');\n\n        div.textContent = text;\n\n        return div.innerHTML;\n\n    }\n\n    function distanceInMetres(lat1, lon1, lat2, lon2) {\n\n        const R = 6371000;\n\n        const lat1Rad = lat1 * Math.PI \/ 180;\n        const lat2Rad = lat2 * Math.PI \/ 180;\n\n        const dLat = (lat2 - lat1) * Math.PI \/ 180;\n        const dLon = (lon2 - lon1) * Math.PI \/ 180;\n\n        const a =\n            Math.sin(dLat \/ 2) * Math.sin(dLat \/ 2) +\n            Math.cos(lat1Rad) *\n            Math.cos(lat2Rad) *\n            Math.sin(dLon \/ 2) *\n            Math.sin(dLon \/ 2);\n\n        const c =\n            2 * Math.atan2(\n                Math.sqrt(a),\n                Math.sqrt(1 - a)\n            );\n\n        return R * c;\n\n    }\n\n    function displayInformation(data) {\n\n        if (\n            !data.information ||\n            !Array.isArray(data.information) ||\n            data.information.length === 0\n        ) {\n\n            showStatus('No live information at the moment.');\n\n            return;\n\n        }\n\n        let html = '';\n\n        data.information.forEach(function (item) {\n\n            const icon = icons[item.type] || icons.info;\n\n            html +=\n                '<div class=\"folkale-live-item\">';\n\n            html +=\n                '<div class=\"folkale-live-icon\">' +\n                icon +\n                '<\/div>';\n\n            if (item.title) {\n\n                html +=\n                    '<h3>' +\n                    escapeHtml(item.title) +\n                    '<\/h3>';\n\n            }\n\n            if (item.message) {\n\n                html +=\n                    '<p>' +\n                    escapeHtml(item.message) +\n                    '<\/p>';\n\n            }\n\n            html += '<\/div>';\n\n        });\n\n        html +=\n            '<p class=\"folkale-live-updated\">' +\n            'Updated ' +\n            new Date(data.updated).toLocaleTimeString() +\n            '<\/p>';\n\n        status.innerHTML = html;\n\n    }\n\n    \/*\n     * Start\n     *\/\n\n    showStatus('Checking your location\u2026');\n\n    if (!navigator.geolocation) {\n\n        showStatus(\n            'Your browser does not support location services.'\n        );\n\n        return;\n\n    }\n\n    navigator.geolocation.getCurrentPosition(\n\n        function (position) {\n\n            const userLat = position.coords.latitude;\n            const userLon = position.coords.longitude;\n\n            const distance = distanceInMetres(\n                userLat,\n                userLon,\n                checkLat,\n                checkLon\n            );\n\n            if (distance > allowedDistance) {\n\n                showStatus(\n                    'Live information is available to visitors at the festival.'\n                );\n\n                return;\n\n            }\n\n            showStatus('Loading live information\u2026');\n\n            fetch(apiUrl)\n\n                .then(function (response) {\n\n                    if (!response.ok) {\n                        throw new Error(\n                            'API returned HTTP ' + response.status\n                        );\n                    }\n\n                    return response.json();\n\n                })\n\n                .then(function (data) {\n\n                    if (data.status !== 'ok') {\n                        throw new Error(\n                            'API returned an error'\n                        );\n                    }\n\n                    displayInformation(data);\n\n                })\n\n                .catch(function (error) {\n\n                    console.error(\n                        'Folk Ale live information error:',\n                        error\n                    );\n\n                    showStatus(\n                        'Live information is temporarily unavailable.'\n                    );\n\n                });\n\n        },\n\n        function (error) {\n\n            if (error.code === 1) {\n\n                showStatus(\n                    'Please allow location access to view live information.'\n                );\n\n            } else {\n\n                showStatus(\n                    'We could not determine your location.'\n                );\n\n            }\n\n        },\n\n        {\n            enableHighAccuracy: true,\n            timeout: 30000,\n            maximumAge: 60000\n        }\n\n    );\n\n})();\n<\/script>\n","protected":false},"excerpt":{"rendered":"<p>\ud83d\udccd Live Information Checking your location\u2026<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-343","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/dev.folkale.co.uk\/index.php?rest_route=\/wp\/v2\/pages\/343","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.folkale.co.uk\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/dev.folkale.co.uk\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/dev.folkale.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.folkale.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=343"}],"version-history":[{"count":19,"href":"https:\/\/dev.folkale.co.uk\/index.php?rest_route=\/wp\/v2\/pages\/343\/revisions"}],"predecessor-version":[{"id":363,"href":"https:\/\/dev.folkale.co.uk\/index.php?rest_route=\/wp\/v2\/pages\/343\/revisions\/363"}],"wp:attachment":[{"href":"https:\/\/dev.folkale.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}