7e5fa6cbf1
- Add HTMX CDN to layout - Replace client-side table rendering (displayRatings, displayCourses) with server-rendered EJS partials via hx-get - Add server-side course search with debounced hx-trigger - Lazy-load player history and course layouts via htmx.ajax() - Render rating chart via htmx:afterSwap with data attributes - Add partial routes: ratings-table, course-table, player-history, course-layouts
72 lines
3.4 KiB
Plaintext
72 lines
3.4 KiB
Plaintext
<% if (layouts.length === 0) { %>
|
|
<div class="no-layouts">No layouts found. Click the refresh icon to scrape layouts.</div>
|
|
<% } else {
|
|
var oneYearAgo = new Date();
|
|
oneYearAgo.setDate(oneYearAgo.getDate() - 365);
|
|
|
|
var activeLayouts = [];
|
|
var inactiveLayouts = [];
|
|
|
|
layouts.forEach(function(layout) {
|
|
if (layout.last_played) {
|
|
var lastPlayedDate = new Date(layout.last_played);
|
|
if (lastPlayedDate >= oneYearAgo) {
|
|
activeLayouts.push(layout);
|
|
} else {
|
|
inactiveLayouts.push(layout);
|
|
}
|
|
} else {
|
|
inactiveLayouts.push(layout);
|
|
}
|
|
});
|
|
%>
|
|
<h4 style="margin-top: 0;">Layouts:</h4>
|
|
|
|
<% if (activeLayouts.length > 0) { %>
|
|
<% activeLayouts.forEach(function(layout) {
|
|
var ratingDisplay = layout.mean_rating ?
|
|
'<span style="color: #28a745; font-weight: bold; margin-left: 10px;">Rating: ' + layout.mean_rating + '</span>' : '';
|
|
var dateDisplay = layout.last_played ?
|
|
'<span style="color: #6c757d; font-size: 12px; margin-left: 10px;">Last played: ' + new Date(layout.last_played).toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' }) + '</span>' : '';
|
|
%>
|
|
<div class="layout-item">
|
|
<div>
|
|
<span class="layout-name"><%= layout.name %></span>
|
|
<%- dateDisplay %>
|
|
</div>
|
|
<span class="layout-par">Par <%= layout.par %><%- ratingDisplay %></span>
|
|
</div>
|
|
<% }); %>
|
|
<% } %>
|
|
|
|
<% if (inactiveLayouts.length > 0) { %>
|
|
<div class="inactive-layouts-accordion">
|
|
<div class="accordion-header" onclick="toggleAccordion('accordion-<%= courseId %>')">
|
|
<span class="accordion-header-text">Inactive Layouts (<%= inactiveLayouts.length %>) - Not played in last year</span>
|
|
<span class="accordion-icon" id="accordion-<%= courseId %>-icon">▼</span>
|
|
</div>
|
|
<div class="accordion-content" id="accordion-<%= courseId %>">
|
|
<% inactiveLayouts.forEach(function(layout) {
|
|
var ratingDisplay = layout.mean_rating ?
|
|
'<span style="color: #28a745; font-weight: bold; margin-left: 10px;">Rating: ' + layout.mean_rating + '</span>' : '';
|
|
var dateDisplay = layout.last_played ?
|
|
'<span style="color: #6c757d; font-size: 12px; margin-left: 10px;">Last played: ' + new Date(layout.last_played).toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' }) + '</span>' :
|
|
'<span style="color: #dc3545; font-size: 12px; margin-left: 10px;">Never played</span>';
|
|
%>
|
|
<div class="layout-item inactive">
|
|
<div>
|
|
<span class="layout-name"><%= layout.name %></span>
|
|
<%- dateDisplay %>
|
|
</div>
|
|
<span class="layout-par">Par <%= layout.par %><%- ratingDisplay %></span>
|
|
</div>
|
|
<% }); %>
|
|
</div>
|
|
</div>
|
|
<% } %>
|
|
|
|
<% if (activeLayouts.length === 0 && inactiveLayouts.length === 0) { %>
|
|
<div class="no-layouts">No layouts found. Click the refresh icon to scrape layouts.</div>
|
|
<% } %>
|
|
<% } %>
|