Spaces:
Running
Running
Add 3 files
Browse files- README.md +7 -5
- index.html +835 -19
- prompts.txt +1 -0
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: instantcoder
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: purple
|
| 5 |
+
colorTo: green
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,835 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Disc Golf League Tracker</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
+
<style>
|
| 10 |
+
.fade-in {
|
| 11 |
+
animation: fadeIn 0.3s ease-in;
|
| 12 |
+
}
|
| 13 |
+
@keyframes fadeIn {
|
| 14 |
+
from { opacity: 0; transform: translateY(10px); }
|
| 15 |
+
to { opacity: 1; transform: translateY(0); }
|
| 16 |
+
}
|
| 17 |
+
.highlight {
|
| 18 |
+
background-color: rgba(255, 255, 0, 0.2);
|
| 19 |
+
transition: background-color 0.3s;
|
| 20 |
+
}
|
| 21 |
+
.money-in { color: #10B981; }
|
| 22 |
+
.money-out { color: #EF4444; }
|
| 23 |
+
input[type="number"]::-webkit-inner-spin-button,
|
| 24 |
+
input[type="number"]::-webkit-outer-spin-button {
|
| 25 |
+
-webkit-appearance: none;
|
| 26 |
+
margin: 0;
|
| 27 |
+
}
|
| 28 |
+
.payment-input {
|
| 29 |
+
width: 60px;
|
| 30 |
+
text-align: center;
|
| 31 |
+
}
|
| 32 |
+
.credits-column {
|
| 33 |
+
background-color: rgba(16, 185, 129, 0.1);
|
| 34 |
+
}
|
| 35 |
+
</style>
|
| 36 |
+
</head>
|
| 37 |
+
<body class="bg-gray-100 min-h-screen">
|
| 38 |
+
<div class="container mx-auto px-4 py-8">
|
| 39 |
+
<header class="mb-8 text-center">
|
| 40 |
+
<h1 class="text-4xl font-bold text-green-800 mb-2">
|
| 41 |
+
<i class="fas fa-golf-ball mr-2"></i> Disc Golf League Tracker
|
| 42 |
+
</h1>
|
| 43 |
+
<p class="text-gray-600">Track weekly scores and finances for your disc golf league</p>
|
| 44 |
+
</header>
|
| 45 |
+
|
| 46 |
+
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
| 47 |
+
<!-- Player Management -->
|
| 48 |
+
<div class="bg-white rounded-lg shadow p-6">
|
| 49 |
+
<h2 class="text-xl font-semibold text-green-700 mb-4 flex items-center">
|
| 50 |
+
<i class="fas fa-users mr-2"></i> Players
|
| 51 |
+
</h2>
|
| 52 |
+
<div class="mb-4 flex">
|
| 53 |
+
<input type="text" id="playerName" placeholder="Player name" class="flex-1 px-3 py-2 border rounded-l focus:outline-none focus:ring-2 focus:ring-green-500">
|
| 54 |
+
<button id="addPlayer" class="bg-green-600 text-white px-4 py-2 rounded-r hover:bg-green-700 transition">
|
| 55 |
+
<i class="fas fa-plus"></i> Add
|
| 56 |
+
</button>
|
| 57 |
+
</div>
|
| 58 |
+
<ul id="playerList" class="divide-y">
|
| 59 |
+
<!-- Players will be added here -->
|
| 60 |
+
</ul>
|
| 61 |
+
</div>
|
| 62 |
+
|
| 63 |
+
<!-- Weekly Event -->
|
| 64 |
+
<div class="bg-white rounded-lg shadow p-6">
|
| 65 |
+
<h2 class="text-xl font-semibold text-green-700 mb-4 flex items-center">
|
| 66 |
+
<i class="fas fa-calendar-week mr-2"></i> Weekly Event
|
| 67 |
+
</h2>
|
| 68 |
+
<div class="mb-4">
|
| 69 |
+
<label class="block text-gray-700 mb-1">Event Date</label>
|
| 70 |
+
<input type="date" id="eventDate" class="w-full px-3 py-2 border rounded focus:outline-none focus:ring-2 focus:ring-green-500">
|
| 71 |
+
</div>
|
| 72 |
+
<div class="mb-4">
|
| 73 |
+
<label class="block text-gray-700 mb-1">Course</label>
|
| 74 |
+
<input type="text" id="courseName" placeholder="Course name" class="w-full px-3 py-2 border rounded focus:outline-none focus:ring-2 focus:ring-green-500">
|
| 75 |
+
</div>
|
| 76 |
+
<div class="mb-4">
|
| 77 |
+
<label class="block text-gray-700 mb-1">Default Entry Fee ($)</label>
|
| 78 |
+
<input type="number" id="entryFee" value="5" min="0" step="0.5" class="w-full px-3 py-2 border rounded focus:outline-none focus:ring-2 focus:ring-green-500">
|
| 79 |
+
</div>
|
| 80 |
+
<button id="startEvent" class="w-full bg-green-600 text-white py-2 rounded hover:bg-green-700 transition">
|
| 81 |
+
<i class="fas fa-play mr-1"></i> Start Event
|
| 82 |
+
</button>
|
| 83 |
+
</div>
|
| 84 |
+
|
| 85 |
+
<!-- Financial Summary -->
|
| 86 |
+
<div class="bg-white rounded-lg shadow p-6">
|
| 87 |
+
<h2 class="text-xl font-semibold text-green-700 mb-4 flex items-center">
|
| 88 |
+
<i class="fas fa-money-bill-wave mr-2"></i> Finances
|
| 89 |
+
</h2>
|
| 90 |
+
<div class="bg-gray-50 p-4 rounded mb-4">
|
| 91 |
+
<div class="flex justify-between mb-2">
|
| 92 |
+
<span class="font-medium">Total Collected:</span>
|
| 93 |
+
<span id="totalCollected" class="font-bold money-in">$0.00</span>
|
| 94 |
+
</div>
|
| 95 |
+
<div class="flex justify-between mb-2">
|
| 96 |
+
<span class="font-medium">Total Paid Out:</span>
|
| 97 |
+
<span id="totalPaidOut" class="font-bold money-out">$0.00</span>
|
| 98 |
+
</div>
|
| 99 |
+
<div class="flex justify-between pt-2 border-t">
|
| 100 |
+
<span class="font-medium">League Balance:</span>
|
| 101 |
+
<span id="leagueBalance" class="font-bold">$0.00</span>
|
| 102 |
+
</div>
|
| 103 |
+
</div>
|
| 104 |
+
<div class="mb-4">
|
| 105 |
+
<label class="block text-gray-700 mb-1">Add Payout</label>
|
| 106 |
+
<div class="flex">
|
| 107 |
+
<select id="payoutPlayer" class="flex-1 px-3 py-2 border rounded-l focus:outline-none focus:ring-2 focus:ring-green-500">
|
| 108 |
+
<option value="">Select player</option>
|
| 109 |
+
</select>
|
| 110 |
+
<input type="number" id="payoutAmount" placeholder="Amount" min="0" step="0.5" class="w-24 px-3 py-2 border-t border-b border-gray-300 focus:outline-none">
|
| 111 |
+
<button id="addPayout" class="bg-green-600 text-white px-4 py-2 rounded-r hover:bg-green-700 transition">
|
| 112 |
+
<i class="fas fa-hand-holding-usd"></i>
|
| 113 |
+
</button>
|
| 114 |
+
</div>
|
| 115 |
+
</div>
|
| 116 |
+
<div class="max-h-40 overflow-y-auto">
|
| 117 |
+
<table class="w-full text-sm">
|
| 118 |
+
<thead>
|
| 119 |
+
<tr class="bg-gray-100">
|
| 120 |
+
<th class="py-2 text-left pl-2">Player</th>
|
| 121 |
+
<th class="py-2 text-right pr-2">Amount</th>
|
| 122 |
+
<th class="py-2 text-right pr-2">Credits</th>
|
| 123 |
+
<th class="py-2 text-right pr-2"></th>
|
| 124 |
+
</tr>
|
| 125 |
+
</thead>
|
| 126 |
+
<tbody id="payoutList">
|
| 127 |
+
<!-- Payouts will be added here -->
|
| 128 |
+
</tbody>
|
| 129 |
+
</table>
|
| 130 |
+
</div>
|
| 131 |
+
</div>
|
| 132 |
+
</div>
|
| 133 |
+
|
| 134 |
+
<!-- Event Scoring Section -->
|
| 135 |
+
<div id="scoringSection" class="bg-white rounded-lg shadow p-6 mt-6 hidden">
|
| 136 |
+
<div class="flex justify-between items-center mb-4">
|
| 137 |
+
<h2 class="text-xl font-semibold text-green-700">
|
| 138 |
+
<i class="fas fa-golf-ball mr-2"></i>
|
| 139 |
+
<span id="currentEventTitle">Event Scoring</span>
|
| 140 |
+
</h2>
|
| 141 |
+
<button id="endEvent" class="bg-red-600 text-white px-4 py-2 rounded hover:bg-red-700 transition">
|
| 142 |
+
<i class="fas fa-stop mr-1"></i> End Event
|
| 143 |
+
</button>
|
| 144 |
+
</div>
|
| 145 |
+
|
| 146 |
+
<div class="overflow-x-auto">
|
| 147 |
+
<table class="w-full text-sm">
|
| 148 |
+
<thead>
|
| 149 |
+
<tr class="bg-gray-100">
|
| 150 |
+
<th class="py-2 text-left pl-2">Player</th>
|
| 151 |
+
<th class="py-2 text-center">Score</th>
|
| 152 |
+
<th class="py-2 text-center">+/-</th>
|
| 153 |
+
<th class="py-2 text-center">Payment</th>
|
| 154 |
+
<th class="py-2 text-center">Paid</th>
|
| 155 |
+
<th class="py-2 text-right pr-2">Actions</th>
|
| 156 |
+
</tr>
|
| 157 |
+
</thead>
|
| 158 |
+
<tbody id="scoreEntryRows">
|
| 159 |
+
<!-- Score rows will be added here -->
|
| 160 |
+
</tbody>
|
| 161 |
+
</table>
|
| 162 |
+
</div>
|
| 163 |
+
</div>
|
| 164 |
+
|
| 165 |
+
<!-- League History -->
|
| 166 |
+
<div class="bg-white rounded-lg shadow p-6 mt-6">
|
| 167 |
+
<h2 class="text-xl font-semibold text-green-700 mb-4 flex items-center">
|
| 168 |
+
<i class="fas fa-history mr-2"></i> League History
|
| 169 |
+
</h2>
|
| 170 |
+
<div class="overflow-x-auto">
|
| 171 |
+
<table class="w-full text-sm">
|
| 172 |
+
<thead>
|
| 173 |
+
<tr class="bg-gray-100">
|
| 174 |
+
<th class="py-2 text-left pl-2">Date</th>
|
| 175 |
+
<th class="py-2 text-left">Course</th>
|
| 176 |
+
<th class="py-2 text-center">Players</th>
|
| 177 |
+
<th class="py-2 text-center">Winner</th>
|
| 178 |
+
<th class="py-2 text-right pr-2">Payout</th>
|
| 179 |
+
<th class="py-2 text-right pr-2">Collected</th>
|
| 180 |
+
</tr>
|
| 181 |
+
</thead>
|
| 182 |
+
<tbody id="eventHistory">
|
| 183 |
+
<!-- Event history will be added here -->
|
| 184 |
+
</tbody>
|
| 185 |
+
</table>
|
| 186 |
+
</div>
|
| 187 |
+
</div>
|
| 188 |
+
|
| 189 |
+
<!-- Player Statistics -->
|
| 190 |
+
<div class="bg-white rounded-lg shadow p-6 mt-6">
|
| 191 |
+
<h2 class="text-xl font-semibold text-green-700 mb-4 flex items-center">
|
| 192 |
+
<i class="fas fa-chart-line mr-2"></i> Player Statistics
|
| 193 |
+
</h2>
|
| 194 |
+
<div class="overflow-x-auto">
|
| 195 |
+
<table class="w-full text-sm">
|
| 196 |
+
<thead>
|
| 197 |
+
<tr class="bg-gray-100">
|
| 198 |
+
<th class="py-2 text-left pl-2">Player</th>
|
| 199 |
+
<th class="py-2 text-center">Events</th>
|
| 200 |
+
<th class="py-2 text-center">Wins</th>
|
| 201 |
+
<th class="py-2 text-center">Avg Score</th>
|
| 202 |
+
<th class="py-2 text-right pr-2">Total Paid</th>
|
| 203 |
+
<th class="py-2 text-right pr-2">Total Payout</th>
|
| 204 |
+
<th class="py-2 text-right pr-2 credits-column">Credits</th>
|
| 205 |
+
</tr>
|
| 206 |
+
</thead>
|
| 207 |
+
<tbody id="playerStats">
|
| 208 |
+
<!-- Player stats will be added here -->
|
| 209 |
+
</tbody>
|
| 210 |
+
</table>
|
| 211 |
+
</div>
|
| 212 |
+
</div>
|
| 213 |
+
|
| 214 |
+
<!-- Player Payment History Modal -->
|
| 215 |
+
<div id="paymentHistoryModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden z-50">
|
| 216 |
+
<div class="bg-white rounded-lg shadow-lg w-full max-w-md max-h-[80vh] overflow-y-auto">
|
| 217 |
+
<div class="p-4 border-b">
|
| 218 |
+
<h3 class="text-lg font-semibold text-green-700" id="paymentHistoryTitle">Payment History</h3>
|
| 219 |
+
<button id="closePaymentHistory" class="absolute top-4 right-4 text-gray-500 hover:text-gray-700">
|
| 220 |
+
<i class="fas fa-times"></i>
|
| 221 |
+
</button>
|
| 222 |
+
</div>
|
| 223 |
+
<div class="p-4">
|
| 224 |
+
<table class="w-full text-sm">
|
| 225 |
+
<thead>
|
| 226 |
+
<tr class="bg-gray-100">
|
| 227 |
+
<th class="py-2 text-left pl-2">Date</th>
|
| 228 |
+
<th class="py-2 text-left">Event</th>
|
| 229 |
+
<th class="py-2 text-right pr-2">Amount</th>
|
| 230 |
+
</tr>
|
| 231 |
+
</thead>
|
| 232 |
+
<tbody id="paymentHistoryContent">
|
| 233 |
+
<!-- Payment history will be added here -->
|
| 234 |
+
</tbody>
|
| 235 |
+
</table>
|
| 236 |
+
</div>
|
| 237 |
+
</div>
|
| 238 |
+
</div>
|
| 239 |
+
</div>
|
| 240 |
+
|
| 241 |
+
<script>
|
| 242 |
+
// Data storage
|
| 243 |
+
let players = [];
|
| 244 |
+
let currentEvent = null;
|
| 245 |
+
let events = [];
|
| 246 |
+
let payouts = [];
|
| 247 |
+
let playerPayments = [];
|
| 248 |
+
|
| 249 |
+
// DOM elements
|
| 250 |
+
const playerNameInput = document.getElementById('playerName');
|
| 251 |
+
const addPlayerBtn = document.getElementById('addPlayer');
|
| 252 |
+
const playerList = document.getElementById('playerList');
|
| 253 |
+
const eventDateInput = document.getElementById('eventDate');
|
| 254 |
+
const courseNameInput = document.getElementById('courseName');
|
| 255 |
+
const entryFeeInput = document.getElementById('entryFee');
|
| 256 |
+
const startEventBtn = document.getElementById('startEvent');
|
| 257 |
+
const scoringSection = document.getElementById('scoringSection');
|
| 258 |
+
const scoreEntryRows = document.getElementById('scoreEntryRows');
|
| 259 |
+
const endEventBtn = document.getElementById('endEvent');
|
| 260 |
+
const payoutPlayerSelect = document.getElementById('payoutPlayer');
|
| 261 |
+
const payoutAmountInput = document.getElementById('payoutAmount');
|
| 262 |
+
const addPayoutBtn = document.getElementById('addPayout');
|
| 263 |
+
const payoutList = document.getElementById('payoutList');
|
| 264 |
+
const totalCollectedSpan = document.getElementById('totalCollected');
|
| 265 |
+
const totalPaidOutSpan = document.getElementById('totalPaidOut');
|
| 266 |
+
const leagueBalanceSpan = document.getElementById('leagueBalance');
|
| 267 |
+
const eventHistory = document.getElementById('eventHistory');
|
| 268 |
+
const playerStats = document.getElementById('playerStats');
|
| 269 |
+
const currentEventTitle = document.getElementById('currentEventTitle');
|
| 270 |
+
const paymentHistoryModal = document.getElementById('paymentHistoryModal');
|
| 271 |
+
const paymentHistoryTitle = document.getElementById('paymentHistoryTitle');
|
| 272 |
+
const paymentHistoryContent = document.getElementById('paymentHistoryContent');
|
| 273 |
+
const closePaymentHistory = document.getElementById('closePaymentHistory');
|
| 274 |
+
|
| 275 |
+
// Set default date to today
|
| 276 |
+
eventDateInput.valueAsDate = new Date();
|
| 277 |
+
|
| 278 |
+
// Initialize from localStorage
|
| 279 |
+
function loadData() {
|
| 280 |
+
const savedPlayers = localStorage.getItem('discGolfPlayers');
|
| 281 |
+
const savedEvents = localStorage.getItem('discGolfEvents');
|
| 282 |
+
const savedPayouts = localStorage.getItem('discGolfPayouts');
|
| 283 |
+
const savedPayments = localStorage.getItem('discGolfPlayerPayments');
|
| 284 |
+
|
| 285 |
+
if (savedPlayers) players = JSON.parse(savedPlayers);
|
| 286 |
+
if (savedEvents) events = JSON.parse(savedEvents);
|
| 287 |
+
if (savedPayouts) payouts = JSON.parse(savedPayouts);
|
| 288 |
+
if (savedPayments) playerPayments = JSON.parse(savedPayments);
|
| 289 |
+
|
| 290 |
+
renderPlayerList();
|
| 291 |
+
updatePayoutPlayerSelect();
|
| 292 |
+
renderEventHistory();
|
| 293 |
+
renderPlayerStats();
|
| 294 |
+
updateFinancialSummary();
|
| 295 |
+
renderPayoutList();
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
// Save data to localStorage
|
| 299 |
+
function saveData() {
|
| 300 |
+
localStorage.setItem('discGolfPlayers', JSON.stringify(players));
|
| 301 |
+
localStorage.setItem('discGolfEvents', JSON.stringify(events));
|
| 302 |
+
localStorage.setItem('discGolfPayouts', JSON.stringify(payouts));
|
| 303 |
+
localStorage.setItem('discGolfPlayerPayments', JSON.stringify(playerPayments));
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
// Add player
|
| 307 |
+
addPlayerBtn.addEventListener('click', () => {
|
| 308 |
+
const name = playerNameInput.value.trim();
|
| 309 |
+
if (name && !players.some(p => p.name.toLowerCase() === name.toLowerCase())) {
|
| 310 |
+
players.push({
|
| 311 |
+
id: Date.now().toString(),
|
| 312 |
+
name: name,
|
| 313 |
+
eventsPlayed: 0,
|
| 314 |
+
wins: 0,
|
| 315 |
+
totalPayout: 0,
|
| 316 |
+
totalPaid: 0,
|
| 317 |
+
totalScore: 0,
|
| 318 |
+
credits: 0
|
| 319 |
+
});
|
| 320 |
+
playerNameInput.value = '';
|
| 321 |
+
renderPlayerList();
|
| 322 |
+
updatePayoutPlayerSelect();
|
| 323 |
+
saveData();
|
| 324 |
+
}
|
| 325 |
+
});
|
| 326 |
+
|
| 327 |
+
// Render player list
|
| 328 |
+
function renderPlayerList() {
|
| 329 |
+
playerList.innerHTML = '';
|
| 330 |
+
players.forEach(player => {
|
| 331 |
+
const li = document.createElement('li');
|
| 332 |
+
li.className = 'py-2 px-1 flex justify-between items-center fade-in';
|
| 333 |
+
li.innerHTML = `
|
| 334 |
+
<span>${player.name}</span>
|
| 335 |
+
<div>
|
| 336 |
+
<button class="text-blue-500 hover:text-blue-700 view-payments mr-3" data-id="${player.id}" title="View payment history">
|
| 337 |
+
<i class="fas fa-money-bill-wave"></i>
|
| 338 |
+
</button>
|
| 339 |
+
<button class="text-red-500 hover:text-red-700 delete-player" data-id="${player.id}">
|
| 340 |
+
<i class="fas fa-trash"></i>
|
| 341 |
+
</button>
|
| 342 |
+
</div>
|
| 343 |
+
`;
|
| 344 |
+
playerList.appendChild(li);
|
| 345 |
+
});
|
| 346 |
+
|
| 347 |
+
// Add delete event listeners
|
| 348 |
+
document.querySelectorAll('.delete-player').forEach(btn => {
|
| 349 |
+
btn.addEventListener('click', (e) => {
|
| 350 |
+
const id = e.currentTarget.getAttribute('data-id');
|
| 351 |
+
players = players.filter(p => p.id !== id);
|
| 352 |
+
renderPlayerList();
|
| 353 |
+
updatePayoutPlayerSelect();
|
| 354 |
+
saveData();
|
| 355 |
+
});
|
| 356 |
+
});
|
| 357 |
+
|
| 358 |
+
// Add payment history event listeners
|
| 359 |
+
document.querySelectorAll('.view-payments').forEach(btn => {
|
| 360 |
+
btn.addEventListener('click', (e) => {
|
| 361 |
+
const playerId = e.currentTarget.getAttribute('data-id');
|
| 362 |
+
showPaymentHistory(playerId);
|
| 363 |
+
});
|
| 364 |
+
});
|
| 365 |
+
}
|
| 366 |
+
|
| 367 |
+
// Show payment history for a player
|
| 368 |
+
function showPaymentHistory(playerId) {
|
| 369 |
+
const player = players.find(p => p.id === playerId);
|
| 370 |
+
if (!player) return;
|
| 371 |
+
|
| 372 |
+
paymentHistoryTitle.textContent = `Payment History - ${player.name}`;
|
| 373 |
+
paymentHistoryContent.innerHTML = '';
|
| 374 |
+
|
| 375 |
+
const playerPayments = getPlayerPayments(playerId);
|
| 376 |
+
if (playerPayments.length === 0) {
|
| 377 |
+
const tr = document.createElement('tr');
|
| 378 |
+
tr.innerHTML = '<td colspan="3" class="py-4 text-center text-gray-500">No payment history found</td>';
|
| 379 |
+
paymentHistoryContent.appendChild(tr);
|
| 380 |
+
} else {
|
| 381 |
+
playerPayments.forEach(payment => {
|
| 382 |
+
const tr = document.createElement('tr');
|
| 383 |
+
tr.className = 'border-b';
|
| 384 |
+
tr.innerHTML = `
|
| 385 |
+
<td class="py-2 pl-2">${formatDate(payment.date)}</td>
|
| 386 |
+
<td class="py-2">${payment.eventName || 'N/A'}</td>
|
| 387 |
+
<td class="py-2 text-right pr-2 money-in">$${payment.amount.toFixed(2)}</td>
|
| 388 |
+
`;
|
| 389 |
+
paymentHistoryContent.appendChild(tr);
|
| 390 |
+
});
|
| 391 |
+
}
|
| 392 |
+
|
| 393 |
+
paymentHistoryModal.classList.remove('hidden');
|
| 394 |
+
}
|
| 395 |
+
|
| 396 |
+
// Close payment history modal
|
| 397 |
+
closePaymentHistory.addEventListener('click', () => {
|
| 398 |
+
paymentHistoryModal.classList.add('hidden');
|
| 399 |
+
});
|
| 400 |
+
|
| 401 |
+
// Get payments for a specific player
|
| 402 |
+
function getPlayerPayments(playerId) {
|
| 403 |
+
return playerPayments.filter(p => p.playerId === playerId);
|
| 404 |
+
}
|
| 405 |
+
|
| 406 |
+
// Update payout player select
|
| 407 |
+
function updatePayoutPlayerSelect() {
|
| 408 |
+
payoutPlayerSelect.innerHTML = '<option value="">Select player</option>';
|
| 409 |
+
players.forEach(player => {
|
| 410 |
+
const option = document.createElement('option');
|
| 411 |
+
option.value = player.id;
|
| 412 |
+
option.textContent = player.name;
|
| 413 |
+
payoutPlayerSelect.appendChild(option);
|
| 414 |
+
});
|
| 415 |
+
}
|
| 416 |
+
|
| 417 |
+
// Start event
|
| 418 |
+
startEventBtn.addEventListener('click', () => {
|
| 419 |
+
const date = eventDateInput.value;
|
| 420 |
+
const course = courseNameInput.value.trim();
|
| 421 |
+
const entryFee = parseFloat(entryFeeInput.value) || 0;
|
| 422 |
+
|
| 423 |
+
if (!date || !course) {
|
| 424 |
+
alert('Please enter a date and course name');
|
| 425 |
+
return;
|
| 426 |
+
}
|
| 427 |
+
|
| 428 |
+
if (players.length === 0) {
|
| 429 |
+
alert('Please add at least one player');
|
| 430 |
+
return;
|
| 431 |
+
}
|
| 432 |
+
|
| 433 |
+
currentEvent = {
|
| 434 |
+
id: Date.now().toString(),
|
| 435 |
+
date: date,
|
| 436 |
+
course: course,
|
| 437 |
+
entryFee: entryFee,
|
| 438 |
+
participants: players.map(player => ({
|
| 439 |
+
playerId: player.id,
|
| 440 |
+
name: player.name,
|
| 441 |
+
score: 0,
|
| 442 |
+
relativeToPar: 0,
|
| 443 |
+
paymentAmount: entryFee,
|
| 444 |
+
paid: false
|
| 445 |
+
}))
|
| 446 |
+
};
|
| 447 |
+
|
| 448 |
+
currentEventTitle.textContent = `${formatDate(date)} @ ${course}`;
|
| 449 |
+
scoringSection.classList.remove('hidden');
|
| 450 |
+
renderScoreEntryRows();
|
| 451 |
+
saveData();
|
| 452 |
+
});
|
| 453 |
+
|
| 454 |
+
// Render score entry rows
|
| 455 |
+
function renderScoreEntryRows() {
|
| 456 |
+
if (!currentEvent) return;
|
| 457 |
+
|
| 458 |
+
scoreEntryRows.innerHTML = '';
|
| 459 |
+
currentEvent.participants.forEach(participant => {
|
| 460 |
+
const player = players.find(p => p.id === participant.playerId);
|
| 461 |
+
const tr = document.createElement('tr');
|
| 462 |
+
tr.className = 'border-b fade-in';
|
| 463 |
+
tr.innerHTML = `
|
| 464 |
+
<td class="py-2 pl-2">${participant.name}</td>
|
| 465 |
+
<td class="py-2 text-center">
|
| 466 |
+
<input type="number" class="w-16 px-2 py-1 border rounded score-input"
|
| 467 |
+
value="${participant.score}" data-player-id="${participant.playerId}">
|
| 468 |
+
</td>
|
| 469 |
+
<td class="py-2 text-center relative-to-par">${formatRelativeToPar(participant.relativeToPar)}</td>
|
| 470 |
+
<td class="py-2 text-center">
|
| 471 |
+
<input type="number" class="payment-input px-2 py-1 border rounded payment-input"
|
| 472 |
+
value="${participant.paymentAmount}" min="0" step="0.5"
|
| 473 |
+
data-player-id="${participant.playerId}">
|
| 474 |
+
</td>
|
| 475 |
+
<td class="py-2 text-center">
|
| 476 |
+
<input type="checkbox" class="h-5 w-5 paid-checkbox"
|
| 477 |
+
${participant.paid ? 'checked' : ''} data-player-id="${participant.playerId}">
|
| 478 |
+
</td>
|
| 479 |
+
<td class="py-2 text-right pr-2">
|
| 480 |
+
<button class="px-2 py-1 bg-gray-200 rounded mr-1 set-par" data-player-id="${participant.playerId}">
|
| 481 |
+
<i class="fas fa-bullseye"></i> Set Par
|
| 482 |
+
</button>
|
| 483 |
+
</td>
|
| 484 |
+
`;
|
| 485 |
+
scoreEntryRows.appendChild(tr);
|
| 486 |
+
});
|
| 487 |
+
|
| 488 |
+
// Add event listeners
|
| 489 |
+
document.querySelectorAll('.score-input').forEach(input => {
|
| 490 |
+
input.addEventListener('change', (e) => {
|
| 491 |
+
const playerId = e.target.getAttribute('data-player-id');
|
| 492 |
+
const score = parseInt(e.target.value) || 0;
|
| 493 |
+
updateParticipantScore(playerId, score);
|
| 494 |
+
});
|
| 495 |
+
});
|
| 496 |
+
|
| 497 |
+
document.querySelectorAll('.payment-input').forEach(input => {
|
| 498 |
+
input.addEventListener('change', (e) => {
|
| 499 |
+
const playerId = e.target.getAttribute('data-player-id');
|
| 500 |
+
const amount = parseFloat(e.target.value) || 0;
|
| 501 |
+
updateParticipantPayment(playerId, amount);
|
| 502 |
+
});
|
| 503 |
+
});
|
| 504 |
+
|
| 505 |
+
document.querySelectorAll('.paid-checkbox').forEach(checkbox => {
|
| 506 |
+
checkbox.addEventListener('change', (e) => {
|
| 507 |
+
const playerId = e.target.getAttribute('data-player-id');
|
| 508 |
+
const paid = e.target.checked;
|
| 509 |
+
updateParticipantPaidStatus(playerId, paid);
|
| 510 |
+
});
|
| 511 |
+
});
|
| 512 |
+
|
| 513 |
+
document.querySelectorAll('.set-par').forEach(btn => {
|
| 514 |
+
btn.addEventListener('click', (e) => {
|
| 515 |
+
const playerId = e.currentTarget.getAttribute('data-player-id');
|
| 516 |
+
const scoreInput = document.querySelector(`.score-input[data-player-id="${playerId}"]`);
|
| 517 |
+
const score = parseInt(scoreInput.value) || 0;
|
| 518 |
+
setAsPar(playerId, score);
|
| 519 |
+
});
|
| 520 |
+
});
|
| 521 |
+
}
|
| 522 |
+
|
| 523 |
+
// Update participant score
|
| 524 |
+
function updateParticipantScore(playerId, score) {
|
| 525 |
+
if (!currentEvent) return;
|
| 526 |
+
|
| 527 |
+
const participant = currentEvent.participants.find(p => p.playerId === playerId);
|
| 528 |
+
if (participant) {
|
| 529 |
+
participant.score = score;
|
| 530 |
+
|
| 531 |
+
// Find the lowest score to calculate relative to par
|
| 532 |
+
const lowestScore = Math.min(...currentEvent.participants.map(p => p.score));
|
| 533 |
+
participant.relativeToPar = participant.score - lowestScore;
|
| 534 |
+
|
| 535 |
+
// Update the display
|
| 536 |
+
const relativeCell = document.querySelector(`.score-input[data-player-id="${playerId}"]`).closest('tr').querySelector('.relative-to-par');
|
| 537 |
+
relativeCell.textContent = formatRelativeToPar(participant.relativeToPar);
|
| 538 |
+
|
| 539 |
+
saveData();
|
| 540 |
+
}
|
| 541 |
+
}
|
| 542 |
+
|
| 543 |
+
// Update participant payment amount
|
| 544 |
+
function updateParticipantPayment(playerId, amount) {
|
| 545 |
+
if (!currentEvent) return;
|
| 546 |
+
|
| 547 |
+
const participant = currentEvent.participants.find(p => p.playerId === playerId);
|
| 548 |
+
if (participant) {
|
| 549 |
+
participant.paymentAmount = amount;
|
| 550 |
+
saveData();
|
| 551 |
+
}
|
| 552 |
+
}
|
| 553 |
+
|
| 554 |
+
// Update participant paid status
|
| 555 |
+
function updateParticipantPaidStatus(playerId, paid) {
|
| 556 |
+
if (!currentEvent) return;
|
| 557 |
+
|
| 558 |
+
const participant = currentEvent.participants.find(p => p.playerId === playerId);
|
| 559 |
+
if (participant) {
|
| 560 |
+
participant.paid = paid;
|
| 561 |
+
saveData();
|
| 562 |
+
updateFinancialSummary();
|
| 563 |
+
}
|
| 564 |
+
}
|
| 565 |
+
|
| 566 |
+
// Set a score as par (0)
|
| 567 |
+
function setAsPar(playerId, parScore) {
|
| 568 |
+
if (!currentEvent) return;
|
| 569 |
+
|
| 570 |
+
currentEvent.participants.forEach(participant => {
|
| 571 |
+
const scoreInput = document.querySelector(`.score-input[data-player-id="${participant.playerId}"]`);
|
| 572 |
+
const currentScore = parseInt(scoreInput.value) || 0;
|
| 573 |
+
const newScore = currentScore - parScore;
|
| 574 |
+
scoreInput.value = newScore;
|
| 575 |
+
updateParticipantScore(participant.playerId, newScore);
|
| 576 |
+
});
|
| 577 |
+
}
|
| 578 |
+
|
| 579 |
+
// Format relative to par
|
| 580 |
+
function formatRelativeToPar(value) {
|
| 581 |
+
if (value === 0) return 'E';
|
| 582 |
+
return value > 0 ? `+${value}` : value;
|
| 583 |
+
}
|
| 584 |
+
|
| 585 |
+
// End event
|
| 586 |
+
endEventBtn.addEventListener('click', () => {
|
| 587 |
+
if (!currentEvent) return;
|
| 588 |
+
|
| 589 |
+
// Determine winner(s)
|
| 590 |
+
const minScore = Math.min(...currentEvent.participants.map(p => p.score));
|
| 591 |
+
const winners = currentEvent.participants.filter(p => p.score === minScore);
|
| 592 |
+
|
| 593 |
+
// Calculate total collected for this event
|
| 594 |
+
const eventCollected = currentEvent.participants
|
| 595 |
+
.filter(p => p.paid)
|
| 596 |
+
.reduce((sum, p) => sum + p.paymentAmount, 0);
|
| 597 |
+
|
| 598 |
+
// Record player payments
|
| 599 |
+
currentEvent.participants.forEach(participant => {
|
| 600 |
+
if (participant.paid) {
|
| 601 |
+
playerPayments.push({
|
| 602 |
+
id: Date.now().toString(),
|
| 603 |
+
playerId: participant.playerId,
|
| 604 |
+
eventId: currentEvent.id,
|
| 605 |
+
eventName: `${formatDate(currentEvent.date)} @ ${currentEvent.course}`,
|
| 606 |
+
date: currentEvent.date,
|
| 607 |
+
amount: participant.paymentAmount
|
| 608 |
+
});
|
| 609 |
+
|
| 610 |
+
// Update player's total paid
|
| 611 |
+
const player = players.find(p => p.id === participant.playerId);
|
| 612 |
+
if (player) {
|
| 613 |
+
player.totalPaid += participant.paymentAmount;
|
| 614 |
+
|
| 615 |
+
// Add to player's credits if not paid out yet
|
| 616 |
+
const playerPayouts = payouts.filter(p => p.playerId === participant.playerId);
|
| 617 |
+
const totalPayout = playerPayouts.reduce((sum, p) => sum + p.amount, 0);
|
| 618 |
+
|
| 619 |
+
if (player.totalPayout < player.totalPaid) {
|
| 620 |
+
player.credits = player.totalPaid - player.totalPayout;
|
| 621 |
+
} else {
|
| 622 |
+
player.credits = 0;
|
| 623 |
+
}
|
| 624 |
+
}
|
| 625 |
+
}
|
| 626 |
+
});
|
| 627 |
+
|
| 628 |
+
// Update player stats
|
| 629 |
+
currentEvent.participants.forEach(participant => {
|
| 630 |
+
const player = players.find(p => p.id === participant.playerId);
|
| 631 |
+
if (player) {
|
| 632 |
+
player.eventsPlayed++;
|
| 633 |
+
player.totalScore += participant.score;
|
| 634 |
+
|
| 635 |
+
if (winners.some(w => w.playerId === participant.playerId)) {
|
| 636 |
+
player.wins++;
|
| 637 |
+
}
|
| 638 |
+
}
|
| 639 |
+
});
|
| 640 |
+
|
| 641 |
+
// Add to event history
|
| 642 |
+
events.push({
|
| 643 |
+
id: currentEvent.id,
|
| 644 |
+
date: currentEvent.date,
|
| 645 |
+
course: currentEvent.course,
|
| 646 |
+
winner: winners.map(w => w.name).join(', '),
|
| 647 |
+
payout: winners.length > 0 ? calculatePayout(currentEvent) : 0,
|
| 648 |
+
collected: eventCollected,
|
| 649 |
+
participantCount: currentEvent.participants.length
|
| 650 |
+
});
|
| 651 |
+
|
| 652 |
+
// Reset current event
|
| 653 |
+
currentEvent = null;
|
| 654 |
+
scoringSection.classList.add('hidden');
|
| 655 |
+
|
| 656 |
+
// Update displays
|
| 657 |
+
renderEventHistory();
|
| 658 |
+
renderPlayerStats();
|
| 659 |
+
updateFinancialSummary();
|
| 660 |
+
renderPayoutList();
|
| 661 |
+
saveData();
|
| 662 |
+
});
|
| 663 |
+
|
| 664 |
+
// Calculate potential payout for an event
|
| 665 |
+
function calculatePayout(event) {
|
| 666 |
+
const paidParticipants = event.participants.filter(p => p.paid);
|
| 667 |
+
const totalCollected = paidParticipants.reduce((sum, p) => sum + p.paymentAmount, 0);
|
| 668 |
+
return totalCollected;
|
| 669 |
+
}
|
| 670 |
+
|
| 671 |
+
// Add payout
|
| 672 |
+
addPayoutBtn.addEventListener('click', () => {
|
| 673 |
+
const playerId = payoutPlayerSelect.value;
|
| 674 |
+
const amount = parseFloat(payoutAmountInput.value) || 0;
|
| 675 |
+
|
| 676 |
+
if (!playerId || amount <= 0) {
|
| 677 |
+
alert('Please select a player and enter a valid amount');
|
| 678 |
+
return;
|
| 679 |
+
}
|
| 680 |
+
|
| 681 |
+
const player = players.find(p => p.id === playerId);
|
| 682 |
+
if (!player) return;
|
| 683 |
+
|
| 684 |
+
payouts.push({
|
| 685 |
+
id: Date.now().toString(),
|
| 686 |
+
playerId: playerId,
|
| 687 |
+
playerName: player.name,
|
| 688 |
+
amount: amount,
|
| 689 |
+
date: new Date().toISOString().split('T')[0]
|
| 690 |
+
});
|
| 691 |
+
|
| 692 |
+
// Update player's total payout
|
| 693 |
+
player.totalPayout += amount;
|
| 694 |
+
|
| 695 |
+
// Update player's credits
|
| 696 |
+
if (player.totalPayout < player.totalPaid) {
|
| 697 |
+
player.credits = player.totalPaid - player.totalPayout;
|
| 698 |
+
} else {
|
| 699 |
+
player.credits = 0;
|
| 700 |
+
}
|
| 701 |
+
|
| 702 |
+
payoutAmountInput.value = '';
|
| 703 |
+
renderPayoutList();
|
| 704 |
+
renderPlayerStats();
|
| 705 |
+
updateFinancialSummary();
|
| 706 |
+
saveData();
|
| 707 |
+
});
|
| 708 |
+
|
| 709 |
+
// Render payout list
|
| 710 |
+
function renderPayoutList() {
|
| 711 |
+
payoutList.innerHTML = '';
|
| 712 |
+
players.forEach(player => {
|
| 713 |
+
const playerPayouts = payouts.filter(p => p.playerId === player.id);
|
| 714 |
+
const totalPayout = playerPayouts.reduce((sum, p) => sum + p.amount, 0);
|
| 715 |
+
|
| 716 |
+
// Calculate credits (total paid - total payout)
|
| 717 |
+
const credits = player.totalPaid - totalPayout;
|
| 718 |
+
|
| 719 |
+
const tr = document.createElement('tr');
|
| 720 |
+
tr.className = 'fade-in';
|
| 721 |
+
tr.innerHTML = `
|
| 722 |
+
<td class="py-1 pl-2">${player.name}</td>
|
| 723 |
+
<td class="py-1 text-right pr-2 money-out">$${totalPayout.toFixed(2)}</td>
|
| 724 |
+
<td class="py-1 text-right pr-2 money-in">$${Math.max(0, credits).toFixed(2)}</td>
|
| 725 |
+
<td class="py-1 text-right pr-2">
|
| 726 |
+
<button class="text-green-600 hover:text-green-800 add-payout" data-id="${player.id}" title="Add payout">
|
| 727 |
+
<i class="fas fa-plus"></i>
|
| 728 |
+
</button>
|
| 729 |
+
</td>
|
| 730 |
+
`;
|
| 731 |
+
payoutList.appendChild(tr);
|
| 732 |
+
});
|
| 733 |
+
|
| 734 |
+
// Add payout event listeners
|
| 735 |
+
document.querySelectorAll('.add-payout').forEach(btn => {
|
| 736 |
+
btn.addEventListener('click', (e) => {
|
| 737 |
+
const playerId = e.currentTarget.getAttribute('data-id');
|
| 738 |
+
const player = players.find(p => p.id === playerId);
|
| 739 |
+
if (player) {
|
| 740 |
+
payoutPlayerSelect.value = playerId;
|
| 741 |
+
payoutAmountInput.focus();
|
| 742 |
+
}
|
| 743 |
+
});
|
| 744 |
+
});
|
| 745 |
+
}
|
| 746 |
+
|
| 747 |
+
// Update financial summary
|
| 748 |
+
function updateFinancialSummary() {
|
| 749 |
+
// Total collected from all events
|
| 750 |
+
const totalCollected = events.reduce((sum, event) => {
|
| 751 |
+
return sum + event.collected;
|
| 752 |
+
}, 0);
|
| 753 |
+
|
| 754 |
+
// Total paid out
|
| 755 |
+
const totalPaidOut = payouts.reduce((sum, payout) => sum + payout.amount, 0);
|
| 756 |
+
|
| 757 |
+
// League balance
|
| 758 |
+
const balance = totalCollected - totalPaidOut;
|
| 759 |
+
|
| 760 |
+
// Update in real-time from current event if it exists
|
| 761 |
+
if (currentEvent) {
|
| 762 |
+
const currentCollected = currentEvent.participants
|
| 763 |
+
.filter(p => p.paid)
|
| 764 |
+
.reduce((sum, p) => sum + p.paymentAmount, 0);
|
| 765 |
+
|
| 766 |
+
totalCollectedSpan.textContent = `$${(totalCollected + currentCollected).toFixed(2)}`;
|
| 767 |
+
} else {
|
| 768 |
+
totalCollectedSpan.textContent = `$${totalCollected.toFixed(2)}`;
|
| 769 |
+
}
|
| 770 |
+
|
| 771 |
+
totalPaidOutSpan.textContent = `$${totalPaidOut.toFixed(2)}`;
|
| 772 |
+
leagueBalanceSpan.textContent = `$${balance.toFixed(2)}`;
|
| 773 |
+
|
| 774 |
+
// Color balance based on value
|
| 775 |
+
if (balance < 0) {
|
| 776 |
+
leagueBalanceSpan.classList.remove('money-in');
|
| 777 |
+
leagueBalanceSpan.classList.add('money-out');
|
| 778 |
+
} else {
|
| 779 |
+
leagueBalanceSpan.classList.remove('money-out');
|
| 780 |
+
leagueBalanceSpan.classList.add('money-in');
|
| 781 |
+
}
|
| 782 |
+
}
|
| 783 |
+
|
| 784 |
+
// Render event history
|
| 785 |
+
function renderEventHistory() {
|
| 786 |
+
eventHistory.innerHTML = '';
|
| 787 |
+
events.slice().reverse().forEach(event => {
|
| 788 |
+
const tr = document.createElement('tr');
|
| 789 |
+
tr.className = 'border-b fade-in hover:bg-gray-50';
|
| 790 |
+
tr.innerHTML = `
|
| 791 |
+
<td class="py-2 pl-2">${formatDate(event.date)}</td>
|
| 792 |
+
<td class="py-2">${event.course}</td>
|
| 793 |
+
<td class="py-2 text-center">${event.participantCount}</td>
|
| 794 |
+
<td class="py-2 text-center">${event.winner}</td>
|
| 795 |
+
<td class="py-2 text-right pr-2 money-out">$${event.payout.toFixed(2)}</td>
|
| 796 |
+
<td class="py-2 text-right pr-2 money-in">$${event.collected.toFixed(2)}</td>
|
| 797 |
+
`;
|
| 798 |
+
eventHistory.appendChild(tr);
|
| 799 |
+
});
|
| 800 |
+
}
|
| 801 |
+
|
| 802 |
+
// Render player stats
|
| 803 |
+
function renderPlayerStats() {
|
| 804 |
+
playerStats.innerHTML = '';
|
| 805 |
+
players.forEach(player => {
|
| 806 |
+
const avgScore = player.eventsPlayed > 0
|
| 807 |
+
? (player.totalScore / player.eventsPlayed).toFixed(1)
|
| 808 |
+
: '-';
|
| 809 |
+
|
| 810 |
+
const tr = document.createElement('tr');
|
| 811 |
+
tr.className = 'border-b fade-in hover:bg-gray-50';
|
| 812 |
+
tr.innerHTML = `
|
| 813 |
+
<td class="py-2 pl-2">${player.name}</td>
|
| 814 |
+
<td class="py-2 text-center">${player.eventsPlayed}</td>
|
| 815 |
+
<td class="py-2 text-center">${player.wins}</td>
|
| 816 |
+
<td class="py-2 text-center">${avgScore}</td>
|
| 817 |
+
<td class="py-2 text-right pr-2 money-in">$${player.totalPaid.toFixed(2)}</td>
|
| 818 |
+
<td class="py-2 text-right pr-2 money-in">$${player.totalPayout.toFixed(2)}</td>
|
| 819 |
+
<td class="py-2 text-right pr-2 money-in credits-column">$${Math.max(0, player.credits).toFixed(2)}</td>
|
| 820 |
+
`;
|
| 821 |
+
playerStats.appendChild(tr);
|
| 822 |
+
});
|
| 823 |
+
}
|
| 824 |
+
|
| 825 |
+
// Format date as MM/DD/YYYY
|
| 826 |
+
function formatDate(dateString) {
|
| 827 |
+
const date = new Date(dateString);
|
| 828 |
+
return date.toLocaleDateString('en-US');
|
| 829 |
+
}
|
| 830 |
+
|
| 831 |
+
// Initialize
|
| 832 |
+
loadData();
|
| 833 |
+
</script>
|
| 834 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Chainrattler/instantcoder" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 835 |
+
</html>
|
prompts.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
update finances tab total collected, total paid out and league balance in real time as money comes in or goes out. Add a running credits column for each player if no money has been paid out to each player
|