{"id":407,"date":"2026-04-17T04:54:19","date_gmt":"2026-04-17T04:54:19","guid":{"rendered":"https:\/\/mtnstep.com\/New\/?page_id=407"},"modified":"2026-06-12T23:57:49","modified_gmt":"2026-06-12T23:57:49","slug":"live-scorecard","status":"publish","type":"page","link":"https:\/\/mtnstep.com\/New\/live-scorecard\/","title":{"rendered":"Live Scorecard"},"content":{"rendered":"\r\n    <style>\r\n    \/* Hides the giant featured image and page titles, BUT LEAVES THE MAIN SITE MENU ALONE *\/\r\n    .post-thumbnail, .entry-thumbnail, .featured-media, \r\n    .featured-image, header.entry-header, .page-title-bar, \r\n    .page-header-bg, .entry-title, img.wp-post-image { \r\n        display: none !important; background-image: none !important;\r\n    }\r\n\r\n    \/* The Universal Menu Styles *\/\r\n    .golf-app-nav-container {\r\n        display: flex !important; flex-direction: row !important; flex-wrap: wrap !important;\r\n        justify-content: center !important; align-items: center !important; gap: 15px !important;\r\n        background: #111 !important; padding: 15px !important; border-radius: 8px !important;\r\n        border: 1px solid #333 !important; margin: 20px auto 40px auto !important; max-width: 1000px;\r\n    }\r\n    .golf-app-nav-container a.golf-nav-btn {\r\n        display: inline-flex !important; align-items: center !important; justify-content: center !important;\r\n        background: #222 !important; color: #4db8ff !important; text-decoration: none !important;\r\n        padding: 12px 20px !important; border-radius: 6px !important; font-weight: bold !important;\r\n        font-size: 16px !important; border: 1px solid #444 !important; white-space: nowrap !important;\r\n        margin: 0 !important; transition: 0.2s ease !important; line-height: 1 !important;\r\n    }\r\n    .golf-app-nav-container a.golf-nav-btn:hover { background: #4db8ff !important; color: #000 !important; }\r\n    <\/style>\r\n    \r\n    <div class=\"golf-app-nav-container\">\r\n        <a href=\"https:\/\/mtnstep.com\/New\/live-scorecard\/\" class=\"golf-nav-btn\">Live Scorecard<\/a>\r\n        <a href=\"https:\/\/mtnstep.com\/New\/leaders-and-course-records\/\" class=\"golf-nav-btn\">Course Records<\/a>\r\n        <a href=\"https:\/\/mtnstep.com\/New\/tour-leaders\/\" class=\"golf-nav-btn\">Tour Leaders<\/a>\r\n        <a href=\"https:\/\/mtnstep.com\/New\/mountain-step-national-golf-course\/\" class=\"golf-nav-btn\">MtnStep Ranch GC<\/a>\r\n    <\/div>\r\n    \n\n\n    <style>\r\n      .golf-app-container { font-family: sans-serif; max-width: 1000px; margin: 0 auto; padding: 10px; }\r\n      .course-link-container { text-align: center; margin-top: -10px; margin-bottom: 20px; }\r\n      .course-link { color: #4db8ff; font-size: 16px; font-weight: bold; text-decoration: none; transition: color 0.2s; }\r\n      .course-link:hover { color: #fff; text-decoration: underline; }\r\n      .event-setup-box { display: flex; gap: 15px; background: #1a1a1a; padding: 15px; border-radius: 8px; margin-bottom: 20px; border: 1px solid #444; }\r\n      .event-name-input { flex: 2; padding: 12px; font-size: 18px; font-weight: bold; background: #000; color: #fff; border: 1px solid #555; border-radius: 6px; text-align: center; }\r\n      .event-name-input::placeholder { color: #888; font-weight: normal; }\r\n      .event-mode-select { flex: 1; padding: 12px; font-weight: bold; background: #000; color: #4db8ff; border: 1px solid #555; border-radius: 6px; text-align: center; cursor: pointer; }\r\n      @media (max-width: 600px) { .event-setup-box { flex-direction: column; } }\r\n      .table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 20px; }\r\n      \r\n      .scorecard-table { width: 100%; border-collapse: collapse; text-align: center; background: #111; color: #fff; white-space: nowrap; }\r\n      .scorecard-table th, .scorecard-table td { border: 1px solid #444; padding: 10px 8px; }\r\n      \r\n      #main-table thead tr th { color: #4CAF50 !important; font-size: 18px !important; font-weight: bold !important; opacity: 1 !important; visibility: visible !important; display: table-cell !important; background: #000 !important; text-transform: none !important; }\r\n      #main-table thead tr th:first-child, #main-table thead tr th:last-child { color: #ffffff !important; }\r\n      \r\n      .hole-input { width: 45px; height: 35px; padding: 5px; text-align: center; font-size: 16px; font-weight: bold; background:#222; color:#fff; border: 1px solid #777; border-radius: 4px; }\r\n      .ai-score { font-size: 18px; font-weight: bold; color: #ccc; }\r\n      .score-red { color: #ff5252; font-weight: bold; } \r\n      .score-black { color: #ffb74d; font-weight: bold; } \r\n      .score-even { color: #64b5f6; font-weight: bold;} \r\n      .scorecard-table tr:not(.player-name-row) th:first-child, \r\n      .scorecard-table tr:not(.player-name-row) td:first-child { position: sticky; left: 0; background: #111; z-index: 2; border-right: 2px solid #777; font-weight: bold; width: 60px; color: #fff; }\r\n      .scorecard-table tr:not(.player-name-row) th:first-child { background: #000; z-index: 3; color: #fff !important;}\r\n      .player-name-row td { background: #2a2a2a !important; border-right: none !important; padding: 0 !important; }\r\n      .sticky-banner-content { position: sticky; left: 0; display: flex; align-items: center; width: max-content; padding: 8px 10px; z-index: 4; }\r\n      .pos-badge { background: #000; color: #fff; font-size: 14px; font-weight: bold; padding: 4px 8px; border-radius: 4px; border: 1px solid #555; margin-right: 12px; min-width: 32px; text-align: center; display: inline-block;}\r\n      .profile-photo { width: 32px; height: 32px; border-radius: 50%; border: 2px solid #555; margin-right: 10px; }\r\n      .profile-link { color: #4db8ff; font-size: 16px; font-weight: bold; text-decoration: none; transition: color 0.2s; }\r\n      .profile-link:hover { color: #fff; text-decoration: underline; }\r\n      .banner-live-score { font-size: 16px; font-weight: bold; margin-left: 10px; }\r\n      tbody tr { transition: transform 0.3s ease; }\r\n      .playing-toggle-container { margin-left: 15px; display: flex; align-items: center; background: #111; padding: 2px 8px; border-radius: 4px; border: 1px solid #444;}\r\n      .playing-toggle-container label { font-size: 12px; color: #aaa; margin-left: 5px; cursor: pointer; font-weight: normal;}\r\n      .playing-toggle-container input { cursor: pointer; }\r\n      #submit-round-btn { display: none; width: 100%; background: #4CAF50; color: white; font-size: 20px; font-weight: bold; padding: 15px; border: none; border-radius: 8px; cursor: pointer; box-shadow: 0 4px 6px rgba(0,0,0,0.3); transition: background 0.3s; }\r\n      #submit-round-btn:active { background: #388E3C; }\r\n      #submit-round-btn:disabled { background: #555; color: #888; cursor: not-allowed; }\r\n      \r\n      \/* NEW BADGE STYLES *\/\r\n      .am-badge-sm { background: #ffb74d; color: #000; font-size: 10px; font-weight: bold; padding: 2px 5px; border-radius: 4px; margin-left: 8px; text-transform: uppercase; letter-spacing: 0.5px; vertical-align: middle;}\r\n      .sr-badge-sm { background: #81c784; color: #000; font-size: 10px; font-weight: bold; padding: 2px 5px; border-radius: 4px; margin-left: 8px; text-transform: uppercase; letter-spacing: 0.5px; vertical-align: middle;}\r\n      .pro-badge-sm { background: #1e88e5; color: #fff; font-size: 10px; font-weight: bold; padding: 2px 5px; border-radius: 4px; margin-left: 8px; text-transform: uppercase; letter-spacing: 0.5px; vertical-align: middle;}\r\n    <\/style>\r\n\r\n    <div class=\"golf-app-container\">\r\n      <h2 style=\"text-align: center; margin-bottom: 10px;\">\u26f3 Live Tournament Scorecard<\/h2>\r\n      <div class=\"course-link-container\"><a href=\"https:\/\/mtnstep.com\/New\/mountain-step-national-golf-course\/\" class=\"course-link\">\ud83d\udccd Mountain Step Ranch Golf Course<\/a><\/div>\r\n      <div class=\"event-setup-box\">\r\n          <input type=\"text\" id=\"event-name\" class=\"event-name-input\" placeholder=\"\ud83c\udfc6 Enter Event Name (e.g., The Masters)\">\r\n          <select id=\"course-mode-select\" class=\"event-mode-select\">\r\n              <option value=\"back4\">Back 4 (4 Holes)<\/option>\r\n              <option value=\"front5\" selected>Front 5 (5 Holes)<\/option>\r\n              <option value=\"back8\">Back 8 (8 Holes)<\/option>\r\n              <option value=\"full\">Full Course (9 Holes)<\/option>\r\n              <option value=\"big10\">The Big 10 (10 Holes)<\/option>\r\n              <option value=\"cherokee\">Cherokee River Loop (14 Holes)<\/option>\r\n              <option value=\"full18\">Full 18 (18 Holes)<\/option>\r\n          <\/select>\r\n      <\/div>\r\n      <div class=\"table-responsive\">\r\n        <table class=\"scorecard-table\" id=\"main-table\">\r\n          <thead>\r\n            <tr>\r\n              <th style=\"color:#fff !important;\">Hole<\/th>\r\n              <th style=\"color:#4CAF50 !important; font-size:18px !important;\">1<\/th><th style=\"color:#4CAF50 !important; font-size:18px !important;\">2<\/th><th style=\"color:#4CAF50 !important; font-size:18px !important;\">3<\/th><th style=\"color:#4CAF50 !important; font-size:18px !important;\">4<\/th><th style=\"color:#4CAF50 !important; font-size:18px !important;\">5<\/th>\r\n              <th style=\"color:#fff !important;\">Total<\/th>\r\n            <\/tr>\r\n            <tr>\r\n              <td>Par<\/td>\r\n              <td>3<\/td><td>3<\/td><td>3<\/td><td>3<\/td><td>3<\/td>\r\n              <td id=\"td-par-total\" style=\"font-weight:bold;\">15<\/td>\r\n            <\/tr>\r\n            <tr>\r\n              <td>Yards<\/td>\r\n              <td>78<\/td><td>36<\/td><td>53<\/td><td>45<\/td><td>65<\/td>\r\n              <td id=\"td-yard-total\">277<\/td>\r\n            <\/tr>\r\n          <\/thead>\r\n          <tbody id=\"players-body\"><tr><td colspan=\"20\">Loading Tournament Field...<\/td><\/tr><\/tbody>\r\n        <\/table>\r\n      <\/div>\r\n      <button id=\"submit-round-btn\">\u2705 Finish & Submit Tournament<\/button>\r\n    <\/div>\r\n\r\n    <script>\r\n      (function() {\r\n        const dbPlayerStatuses = {\"Jake Boggs\":\"Amateur\",\"Bridger Alpsteg\":\"Amateur\",\"Becca Bryan\":\"Pro\",\"Team Pro Pirates\":\"Pro\",\"Toby Ginseng\":\"Pro\",\"Rickey Dobbs\":\"Pro\",\"Ace Merrimack\":\"Pro\",\"Lyle Fowler\":\"Senior\",\"Ralph Hawkins III\":\"Pro\",\"Bryce Wooden\":\"Pro\",\"Carlton Shlob\":\"Senior\",\"Chuck Fank\":\"Pro\",\"Vince Evelyn\":\"Pro\",\"Will Alpsteg\":\"Pro\",\"Mister Ginseng\":\"Pro\",\"Richard Thibideaux\":\"Pro\"};\r\n        \r\n        const PHYSICAL_HOLES = [\r\n            { par: 3, yards: 78 }, { par: 3, yards: 36 }, { par: 3, yards: 53 },\r\n            { par: 3, yards: 45 }, { par: 3, yards: 65 }, { par: 4, yards: 160 },\r\n            { par: 3, yards: 90 }, { par: 3, yards: 106 }, { par: 3, yards: 28 }\r\n        ];\r\n        \r\n        const COURSE_LAYOUTS = {\r\n            'full': { cols: [0,1,2,3,4,5,6,7,8] },\r\n            'front5': { cols: [0,1,2,3,4] },\r\n            'back4': { cols: [5,6,7,8] },\r\n            'full18': { cols: [0,1,2,3,4,5,6,7,8, 0,1,2,3,4,5,6,7,8] },\r\n            'cherokee': { cols: [0,1,2,3,4,5,6,7,8, 0,1,2,3,4] },\r\n            'big10': { cols: [0,1,2,3,4, 0,1,2,3,4] },\r\n            'back8': { cols: [5,6,7,8, 5,6,7,8] }\r\n        };\r\n\r\n        let tournamentData = []; \r\n        let currentLayout = COURSE_LAYOUTS['front5']; \r\n\r\n        function generateFakeScores(layout) {\r\n            let fakeHoles = [];\r\n            let totalPar = 0;\r\n            layout.cols.forEach(col => totalPar += PHYSICAL_HOLES[col].par);\r\n            let totalToDistribute = totalPar + (Math.floor(Math.random() * 8) + 2); \r\n            let strokesLeft = totalToDistribute - totalPar; \r\n            \r\n            layout.cols.forEach(col => fakeHoles.push(PHYSICAL_HOLES[col].par));\r\n            while(strokesLeft > 0) { let r = Math.floor(Math.random() * layout.cols.length); fakeHoles[r] += 1; strokesLeft--; }\r\n            return fakeHoles;\r\n        }\r\n\r\n        function buildDynamicTable() {\r\n            const modeKey = document.getElementById('course-mode-select').value;\r\n            currentLayout = COURSE_LAYOUTS[modeKey];\r\n            \r\n            let h1 = '<tr><th style=\"color:#fff !important;\">Hole<\/th>';\r\n            let h2 = '<tr><td>Par<\/td>';\r\n            let h3 = '<tr><td>Yards<\/td>';\r\n            let tPar = 0, tYard = 0;\r\n            \r\n            currentLayout.cols.forEach((col, i) => {\r\n                h1 += `<th style=\"color:#4CAF50 !important; font-size:18px !important;\">${col + 1}<\/th>`; \r\n                let parColor = (PHYSICAL_HOLES[col].par === 4) ? 'style=\"color:#ffb74d;\"' : '';\r\n                h2 += `<td ${parColor}>${PHYSICAL_HOLES[col].par}<\/td>`;\r\n                h3 += `<td>${PHYSICAL_HOLES[col].yards}<\/td>`;\r\n                tPar += PHYSICAL_HOLES[col].par; tYard += PHYSICAL_HOLES[col].yards;\r\n            });\r\n            h1 += '<th style=\"color:#fff !important;\">Total<\/th><\/tr>'; \r\n            h2 += `<td id=\"td-par-total\" style=\"font-weight:bold;\">${tPar}<\/td><\/tr>`; \r\n            h3 += `<td id=\"td-yard-total\">${tYard}<\/td><\/tr>`;\r\n            document.querySelector('#main-table thead').innerHTML = h1 + h2 + h3;\r\n\r\n            const tbody = document.getElementById('players-body');\r\n            tbody.innerHTML = ''; \r\n            \r\n            tournamentData.forEach((player, index) => {\r\n                const currentStatus = dbPlayerStatuses[player.name] || 'Pro';\r\n                let statusBadgeHtml = '';\r\n                \r\n                \/\/ ADDING THE PRO BADGE\r\n                if(currentStatus.toLowerCase() === 'amateur') { statusBadgeHtml = '<span class=\"am-badge-sm\">AM<\/span>'; } \r\n                else if(currentStatus.toLowerCase() === 'senior') { statusBadgeHtml = '<span class=\"sr-badge-sm\">SR<\/span>'; }\r\n                else { statusBadgeHtml = '<span class=\"pro-badge-sm\">PRO<\/span>'; } \/\/ Default to Pro\r\n\r\n                if(player.type === 'Simulated') {\r\n                    player.scores = generateFakeScores(currentLayout);\r\n                    for (let k = 0; k < player.scores.length; k++) {\r\n                        let physicalHole = currentLayout.cols[k];\r\n                        let aiMax = (currentStatus.toLowerCase() === 'amateur') ? (PHYSICAL_HOLES[physicalHole].par * 2) : 10;\r\n                        if (player.scores[k] > aiMax) player.scores[k] = aiMax;\r\n                    }\r\n                } else {\r\n                    player.simulatedScoresIfAbsent = generateFakeScores(currentLayout);\r\n                }\r\n\r\n                const nameTr = document.createElement('tr');\r\n                nameTr.className = 'player-name-row'; nameTr.id = `banner-row-${index}`;\r\n                let toggleHTML = (player.type === 'Human') ? `<div class=\"playing-toggle-container\"><input type=\"checkbox\" id=\"toggle-${index}\" class=\"human-playing-toggle\" data-row=\"${index}\"><label for=\"toggle-${index}\">Playing<\/label><\/div>` : '';\r\n\r\n                nameTr.innerHTML = `<td colspan=\"${currentLayout.cols.length + 2}\" id=\"banner-cell-${index}\"><div class=\"sticky-banner-content\"><span class=\"pos-badge\" id=\"pos-badge-${index}\">-<\/span><img decoding=\"async\" src=\"${player.photo}\" class=\"profile-photo\"><a href=\"${player.link}\" class=\"profile-link\" target=\"_blank\">${player.name}<\/a> ${statusBadgeHtml}${toggleHTML}<span class=\"banner-live-score score-even\" id=\"banner-score-${index}\">(E) Thru 0<\/span><\/div><\/td>`;\r\n                tbody.appendChild(nameTr);\r\n\r\n                const scoreTr = document.createElement('tr');\r\n                scoreTr.id = `score-row-${index}`;\r\n                let rowHTML = `<td>Score<\/td>`;\r\n                \r\n                currentLayout.cols.forEach((col, i) => {\r\n                    let currentHoleMax = (currentStatus.toLowerCase() === 'amateur') ? (PHYSICAL_HOLES[col].par * 2) : 10;\r\n                    rowHTML += `<td id=\"cell-${index}-col-${i}\"><input type=\"number\" class=\"hole-input human-score\" id=\"input-${index}-col-${i}\" data-row=\"${index}\" data-max=\"${currentHoleMax}\" min=\"1\" max=\"${currentHoleMax}\" style=\"display:none;\"><span class=\"ai-score\" id=\"ai-${index}-col-${i}\"><\/span><\/td>`;\r\n                });\r\n                rowHTML += `<td id=\"total-${index}\">0 <br><span class=\"score-even\">(E)<\/span><\/td>`;\r\n                scoreTr.innerHTML = rowHTML;\r\n                tbody.appendChild(scoreTr);\r\n            });\r\n\r\n            document.querySelectorAll('.human-score').forEach(input => { \r\n                input.addEventListener('input', function() {\r\n                    const maxAllowed = parseInt(this.getAttribute('data-max'));\r\n                    if (parseInt(this.value) > maxAllowed) this.value = maxAllowed; \r\n                    updateLiveBoard();\r\n                }); \r\n            });\r\n            document.querySelectorAll('.human-playing-toggle').forEach(checkbox => {\r\n                checkbox.addEventListener('change', function() {\r\n                    const rIdx = this.getAttribute('data-row');\r\n                    tournamentData[rIdx].isActuallyPlayingHuman = this.checked;\r\n                    for(let i=0; i < currentLayout.cols.length; i++) {\r\n                        const inputEl = document.getElementById(`input-${rIdx}-col-${i}`);\r\n                        const spanEl = document.getElementById(`ai-${rIdx}-col-${i}`);\r\n                        if (this.checked) { inputEl.style.display = 'inline-block'; spanEl.style.display = 'none'; } \r\n                        else { inputEl.style.display = 'none'; spanEl.style.display = 'inline-block'; }\r\n                    }\r\n                    updateLiveBoard();\r\n                });\r\n            });\r\n            updateLiveBoard();\r\n        }\r\n\r\n        function startGolfAppEngine() {\r\n            fetch('\/New\/wp-json\/golf\/v1\/start-round')\r\n            .then(res => res.json())\r\n            .then(players => {\r\n                tournamentData = players;\r\n                tournamentData.forEach(p => { p.pacingOffset = Math.floor(Math.random() * 5) - 2; p.isActuallyPlayingHuman = false; });\r\n                document.getElementById('course-mode-select').addEventListener('change', buildDynamicTable);\r\n                buildDynamicTable();\r\n            }).catch(e => console.log(e));\r\n        }\r\n\r\n        function updateLiveBoard() {\r\n          let humanHolesFinished = 0; let activeHumanFound = false;\r\n          const firstActiveHumanIndex = tournamentData.findIndex(p => p.type === 'Human' && p.isActuallyPlayingHuman);\r\n          if(firstActiveHumanIndex !== -1) {\r\n            activeHumanFound = true;\r\n            for(let i=0; i<currentLayout.cols.length; i++) {\r\n                const s = parseInt(document.getElementById(`input-${firstActiveHumanIndex}-col-${i}`).value);\r\n                if(!isNaN(s) && s > 0) humanHolesFinished++;\r\n            }\r\n          }\r\n\r\n          tournamentData.forEach((player, rowIndex) => {\r\n            let totalStrokes = 0; let holesPlayed = 0; let currentParTotal = 0;\r\n            let isParticipating = player.type === 'Simulated' || player.isActuallyPlayingHuman;\r\n\r\n            if (!isParticipating) {\r\n                for(let i=0; i<currentLayout.cols.length; i++) { document.getElementById(`ai-${rowIndex}-col-${i}`).innerText = '-'; }\r\n                player.currentToPar = 999; player.currentHolesPlayed = 0;\r\n                document.getElementById(`total-${rowIndex}`).innerHTML = '<span style=\"color:#888; font-weight:bold;\">DNP<\/span>';\r\n                const dbn = document.getElementById('banner-score-' + rowIndex);\r\n                if(dbn) { dbn.innerHTML = 'Not Playing'; dbn.className = 'banner-live-score'; }\r\n                document.getElementById(`pos-badge-${rowIndex}`).innerText = '-';\r\n                return; \r\n            }\r\n\r\n            if(player.type === 'Human' && player.isActuallyPlayingHuman) {\r\n              for(let i=0; i<currentLayout.cols.length; i++) {\r\n                 const s = parseInt(document.getElementById(`input-${rowIndex}-col-${i}`).value);\r\n                 if(!isNaN(s) && s > 0) { totalStrokes += s; holesPlayed++; currentParTotal += PHYSICAL_HOLES[currentLayout.cols[i]].par; }\r\n              }\r\n            } else if (player.type === 'Simulated') {\r\n              let aiTargetHolesPlayed = currentLayout.cols.length; \r\n              if (activeHumanFound) {\r\n                 if (humanHolesFinished === currentLayout.cols.length) { aiTargetHolesPlayed = currentLayout.cols.length; } \r\n                 else { aiTargetHolesPlayed = Math.min(Math.max(humanHolesFinished + player.pacingOffset, 0), currentLayout.cols.length); }\r\n              }\r\n              let holesPlayedThisMode = 0;\r\n              for(let i=0; i<currentLayout.cols.length; i++) {\r\n                let cell = document.getElementById(`ai-${rowIndex}-col-${i}`);\r\n                if (holesPlayedThisMode < aiTargetHolesPlayed) {\r\n                   cell.innerText = player.scores[i]; totalStrokes += parseInt(player.scores[i]);\r\n                   holesPlayed++; holesPlayedThisMode++; currentParTotal += PHYSICAL_HOLES[currentLayout.cols[i]].par;\r\n                } else { cell.innerText = ''; }\r\n              }\r\n            }\r\n            \r\n            let color = \"score-even\", text = \"E\"; let toPar = 0; \r\n            if(holesPlayed > 0) {\r\n                toPar = totalStrokes - currentParTotal; \r\n                if(toPar > 0) { color = \"score-black\"; text = \"+\" + toPar; } \r\n                else if(toPar < 0) { color = \"score-red\"; text = toPar; }\r\n            }\r\n            player.currentToPar = toPar; player.currentHolesPlayed = holesPlayed;\r\n            player.finalTotalStrokes = totalStrokes; player.finalToParString = text;\r\n\r\n            const displayColumn = document.getElementById(`total-${rowIndex}`);\r\n            if(displayColumn) displayColumn.innerHTML = (holesPlayed === 0) ? '0 <br><span class=\"score-even\">(E)<\/span>' : `${totalStrokes} <br><span class=\"${color}\">(${text})<\/span>`;\r\n            \r\n            const displayBanner = document.getElementById(`banner-score-${rowIndex}`);\r\n            if(displayBanner) { displayBanner.innerHTML = `(${text}) Thru ${holesPlayed}`; displayBanner.className = `banner-live-score ${color}`; }\r\n          });\r\n          \r\n          const tbody = document.getElementById('players-body');\r\n          if(!tbody) return;\r\n          let indices = tournamentData.map((_, i) => i);\r\n          indices.sort((a, b) => {\r\n              let pA = tournamentData[a], pB = tournamentData[b];\r\n              let aAct = pA.type === 'Simulated' || pA.isActuallyPlayingHuman, bAct = pB.type === 'Simulated' || pB.isActuallyPlayingHuman;\r\n              if (aAct && !bAct) return -1; if (!aAct && bAct) return 1;\r\n              if (pA.currentToPar !== pB.currentToPar) return pA.currentToPar - pB.currentToPar;\r\n              if (pB.currentHolesPlayed !== pA.currentHolesPlayed) return pB.currentHolesPlayed - pA.currentHolesPlayed;\r\n              return 0;\r\n          });\r\n          \r\n          indices.forEach(i => { tbody.appendChild(document.getElementById(`banner-row-${i}`)); tbody.appendChild(document.getElementById(`score-row-${i}`)); });\r\n\r\n          let activeIndices = indices.filter(idx => tournamentData[idx].type === 'Simulated' || tournamentData[idx].isActuallyPlayingHuman);\r\n          let rankArr = activeIndices.map(idx => ({ idx: idx, toPar: tournamentData[idx].currentToPar }));\r\n          for(let i = 0; i < rankArr.length; i++) { rankArr[i].actualRank = (i > 0 && rankArr[i].toPar === rankArr[i-1].toPar) ? rankArr[i-1].actualRank : (i + 1); }\r\n          let rankCounts = {}; rankArr.forEach(r => { rankCounts[r.actualRank] = (rankCounts[r.actualRank] || 0) + 1; });\r\n          rankArr.forEach(r => {\r\n              const badge = document.getElementById(`pos-badge-${r.idx}`);\r\n              if(badge) badge.innerText = (rankCounts[r.actualRank] > 1 ? 'T' : '') + r.actualRank;\r\n          });\r\n\r\n          const submitBtn = document.getElementById('submit-round-btn');\r\n          if(submitBtn) {\r\n              if ((activeHumanFound && humanHolesFinished === currentLayout.cols.length) || !activeHumanFound) {\r\n                  submitBtn.style.display = 'block';\r\n                  submitBtn.onclick = function() {\r\n                      const customEventName = document.getElementById('event-name').value;\r\n                      submitBtn.innerText = '\u23f3 Saving Tournament...'; submitBtn.disabled = true;\r\n                      const allPlayerResults = [];\r\n                      tournamentData.forEach((p, rowIndex) => {\r\n                          if (p.type === 'Simulated' || (p.type === 'Human' && p.isActuallyPlayingHuman)) {\r\n                              let finalHoles = [];\r\n                              for(let i=0; i<currentLayout.cols.length; i++) {\r\n                                  if(p.type === 'Human') {\r\n                                      const val = document.getElementById(`input-${rowIndex}-col-${i}`).value;\r\n                                      finalHoles.push(val ? parseInt(val) : 0);\r\n                                  } else { finalHoles.push(p.scores[i]); }\r\n                              }\r\n                              allPlayerResults.push({ id: p.id, total: p.finalTotalStrokes, to_par: p.finalToParString, holes: finalHoles });\r\n                          }\r\n                      });\r\n\r\n                      fetch('\/New\/wp-json\/golf\/v1\/submit-score', { method: 'POST', headers: { 'Content-Type': 'application\/json' }, body: JSON.stringify({ event_name: customEventName, results: allPlayerResults }) })\r\n                      .then(res => res.json())\r\n                      .then(data => { if(data.success) { submitBtn.innerText = '\u2705 Saved Successfully!'; submitBtn.style.background = '#1976d2'; } });\r\n                  };\r\n              } else { submitBtn.style.display = 'none'; }\r\n          }\r\n        }\r\n        if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', startGolfAppEngine); } else { startGolfAppEngine(); }\r\n      })();\r\n    <\/script>\r\n    \n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"footnotes":""},"class_list":["post-407","page","type-page","status-publish","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/mtnstep.com\/New\/wp-json\/wp\/v2\/pages\/407","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mtnstep.com\/New\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/mtnstep.com\/New\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/mtnstep.com\/New\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mtnstep.com\/New\/wp-json\/wp\/v2\/comments?post=407"}],"version-history":[{"count":30,"href":"https:\/\/mtnstep.com\/New\/wp-json\/wp\/v2\/pages\/407\/revisions"}],"predecessor-version":[{"id":576,"href":"https:\/\/mtnstep.com\/New\/wp-json\/wp\/v2\/pages\/407\/revisions\/576"}],"wp:attachment":[{"href":"https:\/\/mtnstep.com\/New\/wp-json\/wp\/v2\/media?parent=407"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}