feat: refine scoring with hole info, putts, penalties, bunkers

Co-authored-by: aider (openrouter/thinkingmachines/inkling-small:free) <aider@aider.chat>
This commit is contained in:
Jiří Stachandaider committed 2026-10-09 22:52:46 +02:00
1 parent 9f72bf3a6a
commit d7c491ec22
3 files changed
+123 -76

No files matched your search

+34 -20
View File
@@ -52,20 +52,27 @@ async function loadRound() {
function renderHole(hole) {
document.getElementById('hole-score-id').value = hole.hole_score_id;
document.getElementById('hole-label').textContent = `Hole ${hole.hole_number}`;
document.getElementById('strokes').value = hole.strokes || 0;
document.getElementById('fairway').checked = hole.fairway_hit;
document.getElementById('skipped').checked = hole.skipped;
document.getElementById('completed').checked = hole.completed;
document.getElementById('strokes').value = hole.strokes || 1;
document.getElementById('unfinished').checked = hole.unfinished || false;
document.getElementById('skipped').checked = hole.skipped || false;
document.getElementById('completed').checked = hole.completed || false;
document.getElementById('fairway').checked = hole.fairway_hit || false;
document.getElementById('gir-display').textContent = hole.gir ? 'Yes' : 'No';
const putts = hole.putts || [];
document.getElementById('putts-input').value = putts.map(p => p.location).join(',');
document.getElementById('putts-green').value = hole.putts_green || 0;
document.getElementById('putts-off-green').value = hole.putts_off_green || 0;
const pens = (hole.penalties || []).map(p => p.type).join(',');
document.getElementById('penalties-input').value = pens;
document.getElementById('pen-water').checked = hole.penalty_water || false;
document.getElementById('pen-ob').checked = hole.penalty_ob || false;
document.getElementById('pen-lost').checked = hole.penalty_lost || false;
const buns = (hole.bunkers || []).map(b => b.location).join(',');
document.getElementById('bunkers-input').value = buns;
document.getElementById('bunker-greenside').checked = hole.bunker_greenside || false;
document.getElementById('bunker-fairway').checked = hole.bunker_fairway || false;
const info = hole.hole_info || {};
document.getElementById('hole-info').innerHTML = `
<strong>Par ${info.par}</strong> | Tee: ${info.tee} | ${info.yardage_meters}m
`;
}
function renderNav(holes) {
@@ -93,26 +100,30 @@ function nextHole() {
async function saveHole() {
const id = document.getElementById('hole-score-id').value;
const strokes = parseInt(document.getElementById('strokes').value) || 0;
const fairway = document.getElementById('fairway').checked;
const strokes = parseInt(document.getElementById('strokes').value) || 1;
const unfinished = document.getElementById('unfinished').checked;
const skipped = document.getElementById('skipped').checked;
const completed = document.getElementById('completed').checked;
const fairway = document.getElementById('fairway').checked;
const puttsStr = document.getElementById('putts-input').value;
const putts = puttsStr.split(',').filter(s => s.trim()).map(s => ({location: s.trim()}));
const puttsGreen = parseInt(document.getElementById('putts-green').value) || 0;
const puttsOffGreen = parseInt(document.getElementById('putts-off-green').value) || 0;
const pensStr = document.getElementById('penalties-input').value;
const penalties = pensStr.split(',').filter(s => s.trim()).map(s => ({type: s.trim()}));
const penWater = document.getElementById('pen-water').checked;
const penOb = document.getElementById('pen-ob').checked;
const penLost = document.getElementById('pen-lost').checked;
const bunsStr = document.getElementById('bunkers-input').value;
const bunkers = bunsStr.split(',').filter(s => s.trim()).map(s => ({location: s.trim()}));
const bunkerGreenside = document.getElementById('bunker-greenside').checked;
const bunkerFairway = document.getElementById('bunker-fairway').checked;
const res = await fetch(`/hole/${id}`, {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
strokes, skipped, completed, fairway_hit: fairway,
putts, penalties, bunkers
strokes, skipped, completed, fairway_hit: fairway, unfinished,
putts_green: puttsGreen, putts_off_green: puttsOffGreen,
penalty_water: penWater, penalty_ob: penOb, penalty_lost: penLost,
bunker_greenside: bunkerGreenside, bunker_fairway: bunkerFairway
})
});
const result = await res.json();
@@ -128,6 +139,9 @@ async function loadStats() {
<p><strong>Total Putts:</strong> ${stats.total_putts}</p>
<p><strong>Fairways Hit:</strong> ${stats.fairways_hit}</p>
<p><strong>GIR:</strong> ${stats.gir}</p>
<p><strong>Penalty Strokes:</strong> ${stats.penalty_strokes}</p>
<p><strong>Bunker Greenside:</strong> ${stats.bunker_greenside}</p>
<p><strong>Bunker Fairway:</strong> ${stats.bunker_fairway}</p>
<p><strong>Holes Played:</strong> ${stats.holes_played}</p>
`;
}