- Create templates/modern.html as unified base for brutalism, glassmorphism, neumorphism - Add styles.py with CSS and chart config for each style - Add --style argument to generate_report.py (overrides --template) - Remove individual brutalism.html, glassmorphism.html, neumorphism.html - Keep platinum.html separate due to unique Mac OS 9 structure Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
727 lines
32 KiB
HTML
727 lines
32 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Lutris Playtime Report</title>
|
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
<style>
|
|
/* Theme-specific CSS injected here */
|
|
__THEME_CSS__
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<!-- Scroll to Top Button -->
|
|
<button class="scroll-top" id="scroll-top" title="Scroll to top">
|
|
<div class="scroll-top-arrow"></div>
|
|
</button>
|
|
|
|
<!-- Theme Toggle Button -->
|
|
<button class="theme-toggle" id="theme-toggle" title="Toggle theme">
|
|
<span class="icon" id="theme-icon"></span>
|
|
</button>
|
|
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h1 class="card-title">Lutris Playtime Report</h1>
|
|
</div>
|
|
<div class="card-content">
|
|
<div class="filters" id="filters"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h2 class="card-title">Statistics</h2>
|
|
</div>
|
|
<div class="card-content">
|
|
<div class="stats">
|
|
<div class="stat">
|
|
<div class="stat-value" id="total-library">__TOTAL_LIBRARY__</div>
|
|
<div class="stat-label">Games in Library</div>
|
|
</div>
|
|
<div class="stat">
|
|
<div class="stat-value" id="total-games">0</div>
|
|
<div class="stat-label">Games Played</div>
|
|
</div>
|
|
<div class="stat">
|
|
<div class="stat-value" id="total-time">0h</div>
|
|
<div class="stat-label">Total Playtime</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h2 class="card-title">Playtime Distribution</h2>
|
|
</div>
|
|
<div class="card-content">
|
|
<div class="charts-wrapper">
|
|
<div class="chart-container">
|
|
<div class="chart-title">Top Games</div>
|
|
<canvas id="playtime-chart"></canvas>
|
|
</div>
|
|
<div class="chart-container">
|
|
<div class="chart-title">By Category</div>
|
|
<canvas id="categories-chart"></canvas>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h2 class="card-title">Summaries</h2>
|
|
</div>
|
|
<div class="card-content summaries-content">
|
|
<div class="tabs">
|
|
<div class="tab active" data-tab="games">Top Games</div>
|
|
<div class="tab" data-tab="categories">By Category</div>
|
|
<div class="tab" data-tab="runners">By Runner</div>
|
|
</div>
|
|
<div class="tab-content">
|
|
<div class="tab-panel active" id="tab-games">
|
|
<div class="table-wrapper">
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>#</th>
|
|
<th>Game</th>
|
|
<th>Playtime</th>
|
|
<th style="text-align: right">%</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="games-table"></tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="tab-panel" id="tab-categories">
|
|
<div class="table-wrapper">
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>#</th>
|
|
<th>Category</th>
|
|
<th>Playtime</th>
|
|
<th style="text-align: right">%</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="categories-table"></tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="tab-panel" id="tab-runners">
|
|
<div class="table-wrapper">
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>#</th>
|
|
<th>Runner</th>
|
|
<th>Playtime</th>
|
|
<th style="text-align: right">%</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="runners-table"></tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// Theme management
|
|
const themeToggle = document.getElementById('theme-toggle');
|
|
const themeIcon = document.getElementById('theme-icon');
|
|
const themes = ['auto', 'light', 'dark'];
|
|
let currentThemeIndex = 0;
|
|
|
|
function getSystemTheme() {
|
|
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
}
|
|
|
|
function updateThemeIcon() {
|
|
const theme = themes[currentThemeIndex];
|
|
if (theme === 'auto') {
|
|
themeIcon.textContent = '';
|
|
themeIcon.className = 'icon icon-auto';
|
|
themeToggle.title = 'Theme: Auto (click to change)';
|
|
} else if (theme === 'light') {
|
|
themeIcon.textContent = '\u2600\uFE0F';
|
|
themeIcon.className = 'icon';
|
|
themeToggle.title = 'Theme: Light (click to change)';
|
|
} else {
|
|
themeIcon.textContent = '\uD83C\uDF19';
|
|
themeIcon.className = 'icon';
|
|
themeToggle.title = 'Theme: Dark (click to change)';
|
|
}
|
|
}
|
|
|
|
function applyTheme() {
|
|
const theme = themes[currentThemeIndex];
|
|
if (theme === 'auto') {
|
|
document.documentElement.removeAttribute('data-theme');
|
|
} else {
|
|
document.documentElement.setAttribute('data-theme', theme);
|
|
}
|
|
updateThemeIcon();
|
|
localStorage.setItem('theme', theme);
|
|
updateChartColors();
|
|
}
|
|
|
|
function loadSavedTheme() {
|
|
const saved = localStorage.getItem('theme');
|
|
if (saved) {
|
|
currentThemeIndex = themes.indexOf(saved);
|
|
if (currentThemeIndex === -1) currentThemeIndex = 0;
|
|
}
|
|
applyTheme();
|
|
}
|
|
|
|
themeToggle.addEventListener('click', () => {
|
|
currentThemeIndex = (currentThemeIndex + 1) % themes.length;
|
|
applyTheme();
|
|
});
|
|
|
|
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
|
|
if (themes[currentThemeIndex] === 'auto') {
|
|
updateThemeIcon();
|
|
updateChartColors();
|
|
}
|
|
});
|
|
|
|
// Data and chart logic
|
|
const allGames = __ALL_GAMES__;
|
|
const topN = __TOP_N__;
|
|
|
|
// Theme-specific configuration
|
|
const themeConfig = __THEME_CONFIG__;
|
|
|
|
function formatTime(hours) {
|
|
const h = Math.floor(hours);
|
|
const m = Math.round((hours - h) * 60);
|
|
if (h === 0) return m + 'm';
|
|
if (m === 0) return h + 'h';
|
|
return h + 'h ' + m + 'm';
|
|
}
|
|
|
|
function getServices() {
|
|
const services = {};
|
|
allGames.forEach(g => {
|
|
const s = g.service;
|
|
if (!services[s]) services[s] = { count: 0, playtime: 0 };
|
|
services[s].count++;
|
|
services[s].playtime += g.playtime;
|
|
});
|
|
return Object.entries(services)
|
|
.sort((a, b) => b[1].playtime - a[1].playtime)
|
|
.map(([name, data]) => ({ name, ...data }));
|
|
}
|
|
|
|
const services = getServices();
|
|
const filtersDiv = document.getElementById('filters');
|
|
services.forEach(service => {
|
|
const label = document.createElement('label');
|
|
label.className = 'filter-label';
|
|
label.innerHTML = `
|
|
<input type="checkbox" value="${service.name}" checked>
|
|
<span class="service-name">${service.name}</span>
|
|
<span class="service-count">(${service.count})</span>
|
|
`;
|
|
filtersDiv.appendChild(label);
|
|
});
|
|
|
|
let chart = null;
|
|
let categoriesChart = null;
|
|
const ctx = document.getElementById('playtime-chart').getContext('2d');
|
|
const ctxCategories = document.getElementById('categories-chart').getContext('2d');
|
|
|
|
// Initialize theme after chart variables are declared
|
|
loadSavedTheme();
|
|
|
|
function getSelectedServices() {
|
|
const checkboxes = filtersDiv.querySelectorAll('input[type="checkbox"]');
|
|
return Array.from(checkboxes)
|
|
.filter(cb => cb.checked)
|
|
.map(cb => cb.value);
|
|
}
|
|
|
|
function getFilteredData(selectedServices) {
|
|
const filtered = allGames
|
|
.filter(g => selectedServices.includes(g.service))
|
|
.sort((a, b) => b.playtime - a.playtime);
|
|
|
|
if (filtered.length === 0) {
|
|
return { chartData: [], othersGames: [], categoriesData: [], totalPlaytime: 0, totalGames: 0 };
|
|
}
|
|
|
|
const totalPlaytime = filtered.reduce((sum, g) => sum + g.playtime, 0);
|
|
const totalGames = filtered.length;
|
|
|
|
const topGames = filtered.slice(0, topN).map(g => ({
|
|
name: g.name,
|
|
playtime: g.playtime,
|
|
service: g.service,
|
|
categories: g.categories || []
|
|
}));
|
|
|
|
let othersGames = [];
|
|
|
|
if (filtered.length > topN) {
|
|
othersGames = filtered.slice(topN).map(g => ({
|
|
name: g.name,
|
|
playtime: g.playtime,
|
|
service: g.service,
|
|
categories: g.categories || []
|
|
}));
|
|
const othersPlaytime = othersGames.reduce((sum, g) => sum + g.playtime, 0);
|
|
const othersCount = othersGames.length;
|
|
topGames.push({
|
|
name: `Others (${othersCount} games)`,
|
|
playtime: othersPlaytime,
|
|
service: 'others'
|
|
});
|
|
}
|
|
|
|
const categoryMap = {};
|
|
filtered.forEach(g => {
|
|
if (g.categories && g.categories.length > 0) {
|
|
g.categories.forEach(cat => {
|
|
if (cat === '.hidden' || cat === 'favorite') return;
|
|
if (!categoryMap[cat]) {
|
|
categoryMap[cat] = { name: cat, playtime: 0, gameCount: 0 };
|
|
}
|
|
categoryMap[cat].playtime += g.playtime;
|
|
categoryMap[cat].gameCount++;
|
|
});
|
|
}
|
|
});
|
|
const categoriesData = Object.values(categoryMap)
|
|
.sort((a, b) => b.playtime - a.playtime);
|
|
|
|
const runnerMap = {};
|
|
filtered.forEach(g => {
|
|
const runner = g.runner || 'unknown';
|
|
if (!runnerMap[runner]) {
|
|
runnerMap[runner] = { name: runner, playtime: 0, gameCount: 0 };
|
|
}
|
|
runnerMap[runner].playtime += g.playtime;
|
|
runnerMap[runner].gameCount++;
|
|
});
|
|
const runnersData = Object.values(runnerMap)
|
|
.sort((a, b) => b.playtime - a.playtime);
|
|
|
|
return { chartData: topGames, othersGames, categoriesData, runnersData, totalPlaytime, totalGames };
|
|
}
|
|
|
|
function getChartTextColor() {
|
|
const theme = themes[currentThemeIndex];
|
|
if (theme === 'dark') return themeConfig.textColorDark;
|
|
if (theme === 'light') return themeConfig.textColorLight;
|
|
return getSystemTheme() === 'dark' ? themeConfig.textColorDark : themeConfig.textColorLight;
|
|
}
|
|
|
|
function getChartBorderColor() {
|
|
const theme = themes[currentThemeIndex];
|
|
if (theme === 'dark') return themeConfig.borderColorDark;
|
|
if (theme === 'light') return themeConfig.borderColorLight;
|
|
return getSystemTheme() === 'dark' ? themeConfig.borderColorDark : themeConfig.borderColorLight;
|
|
}
|
|
|
|
function updateChartColors() {
|
|
const textColor = getChartTextColor();
|
|
if (typeof chart !== 'undefined' && chart) {
|
|
chart.options.plugins.legend.labels.color = textColor;
|
|
chart.update();
|
|
}
|
|
if (typeof categoriesChart !== 'undefined' && categoriesChart) {
|
|
categoriesChart.options.plugins.legend.labels.color = textColor;
|
|
categoriesChart.update();
|
|
}
|
|
}
|
|
|
|
function updateDisplay() {
|
|
const selectedServices = getSelectedServices();
|
|
const { chartData, othersGames, categoriesData, runnersData, totalPlaytime, totalGames } = getFilteredData(selectedServices);
|
|
|
|
document.getElementById('total-games').textContent = totalGames;
|
|
document.getElementById('total-time').textContent = formatTime(totalPlaytime);
|
|
|
|
if (chart) {
|
|
chart.destroy();
|
|
}
|
|
if (categoriesChart) {
|
|
categoriesChart.destroy();
|
|
}
|
|
|
|
if (chartData.length === 0) {
|
|
document.getElementById('games-table').innerHTML =
|
|
'<tr><td colspan="4" class="no-data">No games match the selected filters</td></tr>';
|
|
document.getElementById('categories-table').innerHTML =
|
|
'<tr><td colspan="4" class="no-data">No categories found</td></tr>';
|
|
document.getElementById('runners-table').innerHTML =
|
|
'<tr><td colspan="4" class="no-data">No runners found</td></tr>';
|
|
return;
|
|
}
|
|
|
|
const textColor = getChartTextColor();
|
|
const borderColor = getChartBorderColor();
|
|
|
|
chart = new Chart(ctx, {
|
|
type: 'doughnut',
|
|
data: {
|
|
labels: chartData.map(g => g.name),
|
|
datasets: [{
|
|
data: chartData.map(g => g.playtime),
|
|
backgroundColor: themeConfig.colors.slice(0, chartData.length),
|
|
borderColor: borderColor,
|
|
borderWidth: themeConfig.borderWidth
|
|
}]
|
|
},
|
|
options: {
|
|
responsive: true,
|
|
plugins: {
|
|
legend: {
|
|
position: 'bottom',
|
|
labels: {
|
|
color: textColor,
|
|
font: {
|
|
family: themeConfig.fontFamily,
|
|
size: 11,
|
|
weight: themeConfig.fontWeight
|
|
},
|
|
padding: 12,
|
|
usePointStyle: true,
|
|
pointStyle: themeConfig.pointStyle
|
|
}
|
|
},
|
|
tooltip: {
|
|
backgroundColor: themeConfig.tooltipBg,
|
|
titleColor: themeConfig.tooltipTitleColor,
|
|
bodyColor: themeConfig.tooltipBodyColor,
|
|
borderColor: themeConfig.tooltipBorderColor,
|
|
borderWidth: themeConfig.tooltipBorderWidth,
|
|
titleFont: { weight: 'bold', family: themeConfig.fontFamily },
|
|
bodyFont: { weight: 'normal', family: themeConfig.fontFamily },
|
|
cornerRadius: themeConfig.tooltipCornerRadius,
|
|
padding: 12,
|
|
callbacks: {
|
|
title: function(context) {
|
|
return themeConfig.uppercaseTooltip ? context[0].label.toUpperCase() : context[0].label;
|
|
},
|
|
beforeBody: function(context) {
|
|
const index = context[0].dataIndex;
|
|
const service = chartData[index].service;
|
|
if (service && service !== 'others') {
|
|
return themeConfig.uppercaseTooltip ? service.toUpperCase() : service.charAt(0).toUpperCase() + service.slice(1);
|
|
}
|
|
return '';
|
|
},
|
|
label: function(context) {
|
|
const value = context.raw;
|
|
const percent = ((value / totalPlaytime) * 100).toFixed(1);
|
|
return formatTime(value) + ' (' + percent + '%)';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
const topCategoriesChart = categoriesData.slice(0, topN);
|
|
const otherCategoriesChart = categoriesData.slice(topN);
|
|
const categoriesChartData = topCategoriesChart.map(c => ({
|
|
name: c.name,
|
|
playtime: c.playtime
|
|
}));
|
|
if (otherCategoriesChart.length > 0) {
|
|
const othersPlaytime = otherCategoriesChart.reduce((sum, c) => sum + c.playtime, 0);
|
|
categoriesChartData.push({
|
|
name: `Others (${otherCategoriesChart.length} categories)`,
|
|
playtime: othersPlaytime
|
|
});
|
|
}
|
|
|
|
if (categoriesChartData.length > 0) {
|
|
categoriesChart = new Chart(ctxCategories, {
|
|
type: 'doughnut',
|
|
data: {
|
|
labels: categoriesChartData.map(c => c.name),
|
|
datasets: [{
|
|
data: categoriesChartData.map(c => c.playtime),
|
|
backgroundColor: themeConfig.colors.slice(0, categoriesChartData.length),
|
|
borderColor: borderColor,
|
|
borderWidth: themeConfig.borderWidth
|
|
}]
|
|
},
|
|
options: {
|
|
responsive: true,
|
|
plugins: {
|
|
legend: {
|
|
position: 'bottom',
|
|
labels: {
|
|
color: textColor,
|
|
font: {
|
|
family: themeConfig.fontFamily,
|
|
size: 11,
|
|
weight: themeConfig.fontWeight
|
|
},
|
|
padding: 12,
|
|
usePointStyle: true,
|
|
pointStyle: themeConfig.pointStyle
|
|
}
|
|
},
|
|
tooltip: {
|
|
backgroundColor: themeConfig.tooltipBg,
|
|
titleColor: themeConfig.tooltipTitleColor,
|
|
bodyColor: themeConfig.tooltipBodyColor,
|
|
borderColor: themeConfig.tooltipBorderColor,
|
|
borderWidth: themeConfig.tooltipBorderWidth,
|
|
cornerRadius: themeConfig.tooltipCornerRadius,
|
|
padding: 12,
|
|
titleFont: { family: themeConfig.fontFamily },
|
|
bodyFont: { family: themeConfig.fontFamily },
|
|
callbacks: {
|
|
label: function(context) {
|
|
const value = context.raw;
|
|
const percent = ((value / totalPlaytime) * 100).toFixed(1);
|
|
return ' ' + formatTime(value) + ' (' + percent + '%)';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
const tbody = document.getElementById('games-table');
|
|
tbody.innerHTML = '';
|
|
chartData.forEach((game, index) => {
|
|
const percent = ((game.playtime / totalPlaytime) * 100).toFixed(1);
|
|
const isOthers = game.service === 'others';
|
|
const serviceBadge = !isOthers
|
|
? `<span class="service-badge">${game.service}</span>`
|
|
: '';
|
|
const categoriesBadges = !isOthers && game.categories && game.categories.length > 0
|
|
? game.categories
|
|
.filter(cat => cat !== '.hidden' && cat !== 'favorite')
|
|
.map(cat => `<span class="category-badge">${cat}</span>`)
|
|
.join('')
|
|
: '';
|
|
const row = document.createElement('tr');
|
|
if (isOthers) {
|
|
row.className = 'others-row';
|
|
}
|
|
row.innerHTML = `
|
|
<td>${index + 1}</td>
|
|
<td>
|
|
<span class="color-box" style="background: ${themeConfig.colors[index]}"></span>
|
|
${game.name}${serviceBadge}${categoriesBadges}
|
|
</td>
|
|
<td class="time">${formatTime(game.playtime)}</td>
|
|
<td class="percent">${percent}%</td>
|
|
`;
|
|
tbody.appendChild(row);
|
|
|
|
if (isOthers && othersGames.length > 0) {
|
|
const detailRows = [];
|
|
othersGames.forEach((otherGame, otherIndex) => {
|
|
const otherPercent = ((otherGame.playtime / totalPlaytime) * 100).toFixed(1);
|
|
const otherCategoriesBadges = otherGame.categories && otherGame.categories.length > 0
|
|
? otherGame.categories
|
|
.filter(cat => cat !== '.hidden' && cat !== 'favorite')
|
|
.map(cat => `<span class="category-badge">${cat}</span>`)
|
|
.join('')
|
|
: '';
|
|
const detailRow = document.createElement('tr');
|
|
detailRow.className = 'others-detail';
|
|
detailRow.innerHTML = `
|
|
<td>${index + 1}.${otherIndex + 1}</td>
|
|
<td>
|
|
${otherGame.name}
|
|
<span class="service-badge">${otherGame.service}</span>${otherCategoriesBadges}
|
|
</td>
|
|
<td class="time">${formatTime(otherGame.playtime)}</td>
|
|
<td class="percent">${otherPercent}%</td>
|
|
`;
|
|
tbody.appendChild(detailRow);
|
|
detailRows.push(detailRow);
|
|
});
|
|
|
|
row.addEventListener('click', () => {
|
|
row.classList.toggle('expanded');
|
|
detailRows.forEach(dr => dr.classList.toggle('visible'));
|
|
});
|
|
}
|
|
});
|
|
|
|
const catTbody = document.getElementById('categories-table');
|
|
catTbody.innerHTML = '';
|
|
if (categoriesData.length === 0) {
|
|
catTbody.innerHTML = '<tr><td colspan="4" class="no-data">No categories found</td></tr>';
|
|
} else {
|
|
const topCategories = categoriesData.slice(0, topN);
|
|
const otherCategories = categoriesData.slice(topN);
|
|
|
|
topCategories.forEach((cat, index) => {
|
|
const percent = ((cat.playtime / totalPlaytime) * 100).toFixed(1);
|
|
const row = document.createElement('tr');
|
|
row.innerHTML = `
|
|
<td>${index + 1}</td>
|
|
<td>
|
|
<span class="color-box" style="background: ${themeConfig.colors[index]}"></span>
|
|
${cat.name} <span class="service-badge">${cat.gameCount} games</span>
|
|
</td>
|
|
<td class="time">${formatTime(cat.playtime)}</td>
|
|
<td class="percent">${percent}%</td>
|
|
`;
|
|
catTbody.appendChild(row);
|
|
});
|
|
|
|
if (otherCategories.length > 0) {
|
|
const othersPlaytime = otherCategories.reduce((sum, c) => sum + c.playtime, 0);
|
|
const othersPercent = ((othersPlaytime / totalPlaytime) * 100).toFixed(1);
|
|
const othersIndex = topCategories.length;
|
|
|
|
const othersRow = document.createElement('tr');
|
|
othersRow.className = 'others-row';
|
|
othersRow.innerHTML = `
|
|
<td>${othersIndex + 1}</td>
|
|
<td>
|
|
<span class="color-box" style="background: ${themeConfig.colors[othersIndex]}"></span>
|
|
Others (${otherCategories.length} categories)
|
|
</td>
|
|
<td class="time">${formatTime(othersPlaytime)}</td>
|
|
<td class="percent">${othersPercent}%</td>
|
|
`;
|
|
catTbody.appendChild(othersRow);
|
|
|
|
const detailRows = [];
|
|
otherCategories.forEach((otherCat, otherIndex) => {
|
|
const otherPercent = ((otherCat.playtime / totalPlaytime) * 100).toFixed(1);
|
|
const detailRow = document.createElement('tr');
|
|
detailRow.className = 'others-detail';
|
|
detailRow.innerHTML = `
|
|
<td>${othersIndex + 1}.${otherIndex + 1}</td>
|
|
<td>
|
|
${otherCat.name} <span class="service-badge">${otherCat.gameCount} games</span>
|
|
</td>
|
|
<td class="time">${formatTime(otherCat.playtime)}</td>
|
|
<td class="percent">${otherPercent}%</td>
|
|
`;
|
|
catTbody.appendChild(detailRow);
|
|
detailRows.push(detailRow);
|
|
});
|
|
|
|
othersRow.addEventListener('click', () => {
|
|
othersRow.classList.toggle('expanded');
|
|
detailRows.forEach(dr => dr.classList.toggle('visible'));
|
|
});
|
|
}
|
|
}
|
|
|
|
const runnersTbody = document.getElementById('runners-table');
|
|
runnersTbody.innerHTML = '';
|
|
if (runnersData.length === 0) {
|
|
runnersTbody.innerHTML = '<tr><td colspan="4" class="no-data">No runners found</td></tr>';
|
|
} else {
|
|
const topRunners = runnersData.slice(0, topN);
|
|
const otherRunners = runnersData.slice(topN);
|
|
|
|
topRunners.forEach((runner, index) => {
|
|
const percent = ((runner.playtime / totalPlaytime) * 100).toFixed(1);
|
|
const row = document.createElement('tr');
|
|
row.innerHTML = `
|
|
<td>${index + 1}</td>
|
|
<td>
|
|
<span class="color-box" style="background: ${themeConfig.colors[index]}"></span>
|
|
${runner.name} <span class="service-badge">${runner.gameCount} games</span>
|
|
</td>
|
|
<td class="time">${formatTime(runner.playtime)}</td>
|
|
<td class="percent">${percent}%</td>
|
|
`;
|
|
runnersTbody.appendChild(row);
|
|
});
|
|
|
|
if (otherRunners.length > 0) {
|
|
const othersPlaytime = otherRunners.reduce((sum, r) => sum + r.playtime, 0);
|
|
const othersPercent = ((othersPlaytime / totalPlaytime) * 100).toFixed(1);
|
|
const othersIndex = topRunners.length;
|
|
|
|
const othersRow = document.createElement('tr');
|
|
othersRow.className = 'others-row';
|
|
othersRow.innerHTML = `
|
|
<td>${othersIndex + 1}</td>
|
|
<td>
|
|
<span class="color-box" style="background: ${themeConfig.colors[othersIndex]}"></span>
|
|
Others (${otherRunners.length} runners)
|
|
</td>
|
|
<td class="time">${formatTime(othersPlaytime)}</td>
|
|
<td class="percent">${othersPercent}%</td>
|
|
`;
|
|
runnersTbody.appendChild(othersRow);
|
|
|
|
const detailRows = [];
|
|
otherRunners.forEach((otherRunner, otherIndex) => {
|
|
const otherPercent = ((otherRunner.playtime / totalPlaytime) * 100).toFixed(1);
|
|
const detailRow = document.createElement('tr');
|
|
detailRow.className = 'others-detail';
|
|
detailRow.innerHTML = `
|
|
<td>${othersIndex + 1}.${otherIndex + 1}</td>
|
|
<td>
|
|
${otherRunner.name} <span class="service-badge">${otherRunner.gameCount} games</span>
|
|
</td>
|
|
<td class="time">${formatTime(otherRunner.playtime)}</td>
|
|
<td class="percent">${otherPercent}%</td>
|
|
`;
|
|
runnersTbody.appendChild(detailRow);
|
|
detailRows.push(detailRow);
|
|
});
|
|
|
|
othersRow.addEventListener('click', () => {
|
|
othersRow.classList.toggle('expanded');
|
|
detailRows.forEach(dr => dr.classList.toggle('visible'));
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
filtersDiv.addEventListener('change', updateDisplay);
|
|
updateDisplay();
|
|
|
|
// Tab switching
|
|
document.querySelectorAll('.tab').forEach(tab => {
|
|
tab.addEventListener('click', () => {
|
|
const tabId = tab.dataset.tab;
|
|
document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
|
|
tab.classList.add('active');
|
|
document.querySelectorAll('.tab-panel').forEach(p => p.classList.remove('active'));
|
|
document.getElementById('tab-' + tabId).classList.add('active');
|
|
});
|
|
});
|
|
|
|
// Scroll to top button
|
|
const scrollTopBtn = document.getElementById('scroll-top');
|
|
|
|
function updateScrollTopVisibility() {
|
|
if (window.scrollY > 100) {
|
|
scrollTopBtn.classList.add('visible');
|
|
} else {
|
|
scrollTopBtn.classList.remove('visible');
|
|
}
|
|
}
|
|
|
|
window.addEventListener('scroll', updateScrollTopVisibility);
|
|
updateScrollTopVisibility();
|
|
|
|
scrollTopBtn.addEventListener('click', () => {
|
|
window.scrollTo({
|
|
top: 0,
|
|
behavior: 'smooth'
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|