- Move all HTML templates to templates/ - Move Platinum assets to templates/Platinum/ - Update default paths in generate_report.py Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1216 lines
41 KiB
HTML
1216 lines
41 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>
|
|
:root {
|
|
--bg-base: #ffffff;
|
|
--bg-primary: #ffffff;
|
|
--bg-secondary: #f0f0f0;
|
|
--bg-tertiary: #e0e0e0;
|
|
--text-primary: #000000;
|
|
--text-secondary: #333333;
|
|
--text-muted: #666666;
|
|
--border-color: #000000;
|
|
--border-width: 3px;
|
|
--accent-color: #ff0000;
|
|
--accent-secondary: #0000ff;
|
|
--accent-tertiary: #ffff00;
|
|
--selection-bg: #ffff00;
|
|
--selection-text: #000000;
|
|
--shadow-offset: 6px;
|
|
}
|
|
|
|
[data-theme="dark"] {
|
|
--bg-base: #000000;
|
|
--bg-primary: #000000;
|
|
--bg-secondary: #111111;
|
|
--bg-tertiary: #222222;
|
|
--text-primary: #ffffff;
|
|
--text-secondary: #cccccc;
|
|
--text-muted: #888888;
|
|
--border-color: #ffffff;
|
|
--accent-color: #ff3333;
|
|
--accent-secondary: #3333ff;
|
|
--accent-tertiary: #ffff33;
|
|
--selection-bg: #ff3333;
|
|
--selection-text: #000000;
|
|
}
|
|
|
|
@media (prefers-color-scheme: dark) {
|
|
:root:not([data-theme="light"]) {
|
|
--bg-base: #000000;
|
|
--bg-primary: #000000;
|
|
--bg-secondary: #111111;
|
|
--bg-tertiary: #222222;
|
|
--text-primary: #ffffff;
|
|
--text-secondary: #cccccc;
|
|
--text-muted: #888888;
|
|
--border-color: #ffffff;
|
|
--accent-color: #ff3333;
|
|
--accent-secondary: #3333ff;
|
|
--accent-tertiary: #ffff33;
|
|
--selection-bg: #ff3333;
|
|
--selection-text: #000000;
|
|
}
|
|
}
|
|
|
|
* {
|
|
box-sizing: border-box;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
|
|
body {
|
|
font-family: 'Courier New', Courier, monospace;
|
|
font-size: 14px;
|
|
max-width: 1200px;
|
|
margin: 0 auto;
|
|
padding: 20px;
|
|
background-color: var(--bg-base);
|
|
background-image: __BACKGROUND_IMAGE_CUSTOM__;
|
|
background-size: cover;
|
|
background-position: center;
|
|
background-attachment: fixed;
|
|
min-height: 100vh;
|
|
color: var(--text-primary);
|
|
line-height: 1.4;
|
|
}
|
|
|
|
/* Theme Toggle Button */
|
|
.theme-toggle {
|
|
position: fixed;
|
|
top: 20px;
|
|
right: 20px;
|
|
z-index: 1000;
|
|
width: 50px;
|
|
height: 50px;
|
|
border: var(--border-width) solid var(--border-color);
|
|
background: var(--bg-primary);
|
|
cursor: pointer;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-size: 20px;
|
|
box-shadow: var(--shadow-offset) var(--shadow-offset) 0 var(--border-color);
|
|
transition: transform 0.1s, box-shadow 0.1s;
|
|
}
|
|
|
|
.theme-toggle:hover {
|
|
transform: translate(-2px, -2px);
|
|
box-shadow: calc(var(--shadow-offset) + 2px) calc(var(--shadow-offset) + 2px) 0 var(--border-color);
|
|
}
|
|
|
|
.theme-toggle:active {
|
|
transform: translate(2px, 2px);
|
|
box-shadow: calc(var(--shadow-offset) - 2px) calc(var(--shadow-offset) - 2px) 0 var(--border-color);
|
|
}
|
|
|
|
.theme-toggle .icon {
|
|
line-height: 1;
|
|
}
|
|
|
|
.theme-toggle .icon-auto {
|
|
position: relative;
|
|
width: 24px;
|
|
height: 24px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.theme-toggle .icon-auto::before,
|
|
.theme-toggle .icon-auto::after {
|
|
position: absolute;
|
|
font-size: 20px;
|
|
line-height: 1;
|
|
}
|
|
|
|
.theme-toggle .icon-auto::before {
|
|
content: '☀️';
|
|
clip-path: inset(0 50% 0 0);
|
|
}
|
|
|
|
.theme-toggle .icon-auto::after {
|
|
content: '🌙';
|
|
clip-path: inset(0 0 0 50%);
|
|
}
|
|
|
|
/* Brutal Card Style */
|
|
.brutal-card {
|
|
background: var(--bg-primary);
|
|
border: var(--border-width) solid var(--border-color);
|
|
box-shadow: var(--shadow-offset) var(--shadow-offset) 0 var(--border-color);
|
|
margin-bottom: 24px;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.card-header {
|
|
padding: 12px 16px;
|
|
border-bottom: var(--border-width) solid var(--border-color);
|
|
background: var(--accent-tertiary);
|
|
}
|
|
|
|
[data-theme="dark"] .card-header,
|
|
.dark-theme .card-header {
|
|
background: var(--bg-tertiary);
|
|
}
|
|
|
|
@media (prefers-color-scheme: dark) {
|
|
:root:not([data-theme="light"]) .card-header {
|
|
background: var(--bg-tertiary);
|
|
}
|
|
}
|
|
|
|
.card-title {
|
|
font-size: 18px;
|
|
font-weight: 900;
|
|
text-transform: uppercase;
|
|
letter-spacing: 2px;
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.card-content {
|
|
padding: 20px;
|
|
}
|
|
|
|
/* Filters */
|
|
.filters {
|
|
display: flex;
|
|
justify-content: center;
|
|
gap: 12px;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.filter-label {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
cursor: pointer;
|
|
user-select: none;
|
|
padding: 8px 12px;
|
|
background: var(--bg-secondary);
|
|
border: 2px solid var(--border-color);
|
|
font-weight: 700;
|
|
text-transform: uppercase;
|
|
font-size: 12px;
|
|
transition: transform 0.1s, box-shadow 0.1s;
|
|
}
|
|
|
|
.filter-label:hover {
|
|
transform: translate(-2px, -2px);
|
|
box-shadow: 4px 4px 0 var(--border-color);
|
|
}
|
|
|
|
.filter-label input[type="checkbox"] {
|
|
appearance: none;
|
|
-webkit-appearance: none;
|
|
width: 20px;
|
|
height: 20px;
|
|
border: 2px solid var(--border-color);
|
|
background: var(--bg-primary);
|
|
cursor: pointer;
|
|
position: relative;
|
|
}
|
|
|
|
.filter-label input[type="checkbox"]:checked {
|
|
background: var(--accent-color);
|
|
}
|
|
|
|
.filter-label input[type="checkbox"]:checked::after {
|
|
content: '✕';
|
|
position: absolute;
|
|
left: 50%;
|
|
top: 50%;
|
|
transform: translate(-50%, -50%);
|
|
font-size: 14px;
|
|
font-weight: 900;
|
|
color: var(--bg-primary);
|
|
}
|
|
|
|
.filter-label .service-name {
|
|
text-transform: uppercase;
|
|
font-weight: 700;
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.filter-label .service-count {
|
|
color: var(--text-muted);
|
|
font-size: 11px;
|
|
}
|
|
|
|
/* Stats */
|
|
.stats {
|
|
display: flex;
|
|
justify-content: center;
|
|
gap: 20px;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.stat {
|
|
text-align: center;
|
|
padding: 20px 30px;
|
|
background: var(--bg-secondary);
|
|
border: var(--border-width) solid var(--border-color);
|
|
min-width: 150px;
|
|
}
|
|
|
|
.stat-value {
|
|
font-size: 36px;
|
|
font-weight: 900;
|
|
color: var(--accent-color);
|
|
font-variant-numeric: tabular-nums;
|
|
}
|
|
|
|
.stat-label {
|
|
font-size: 11px;
|
|
color: var(--text-muted);
|
|
margin-top: 4px;
|
|
text-transform: uppercase;
|
|
letter-spacing: 1px;
|
|
font-weight: 700;
|
|
}
|
|
|
|
/* Charts */
|
|
.charts-wrapper {
|
|
display: flex;
|
|
gap: 20px;
|
|
justify-content: center;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.chart-container {
|
|
flex: 1;
|
|
min-width: 280px;
|
|
max-width: 450px;
|
|
padding: 16px;
|
|
background: var(--bg-secondary);
|
|
border: var(--border-width) solid var(--border-color);
|
|
}
|
|
|
|
.chart-title {
|
|
font-size: 14px;
|
|
font-weight: 900;
|
|
text-align: center;
|
|
margin-bottom: 12px;
|
|
color: var(--text-primary);
|
|
text-transform: uppercase;
|
|
letter-spacing: 1px;
|
|
}
|
|
|
|
@media (max-width: 700px) {
|
|
.charts-wrapper {
|
|
flex-direction: column;
|
|
align-items: center;
|
|
}
|
|
.chart-container {
|
|
max-width: 100%;
|
|
width: 100%;
|
|
}
|
|
}
|
|
|
|
/* Tabs */
|
|
.tabs {
|
|
display: flex;
|
|
gap: 0;
|
|
padding: 0 16px;
|
|
margin-bottom: -3px;
|
|
position: relative;
|
|
z-index: 1;
|
|
}
|
|
|
|
.tab {
|
|
padding: 12px 24px;
|
|
cursor: pointer;
|
|
color: var(--text-secondary);
|
|
font-weight: 900;
|
|
text-transform: uppercase;
|
|
font-size: 12px;
|
|
letter-spacing: 1px;
|
|
background: var(--bg-tertiary);
|
|
border: var(--border-width) solid var(--border-color);
|
|
border-bottom: none;
|
|
margin-right: -3px;
|
|
transition: none;
|
|
}
|
|
|
|
.tab:hover {
|
|
color: var(--text-primary);
|
|
background: var(--bg-secondary);
|
|
}
|
|
|
|
.tab.active {
|
|
color: var(--accent-color);
|
|
background: var(--bg-secondary);
|
|
position: relative;
|
|
}
|
|
|
|
.tab.active::after {
|
|
content: '';
|
|
position: absolute;
|
|
bottom: -3px;
|
|
left: 0;
|
|
right: 0;
|
|
height: 3px;
|
|
background: var(--bg-secondary);
|
|
}
|
|
|
|
.tab-content {
|
|
background: var(--bg-secondary);
|
|
border: var(--border-width) solid var(--border-color);
|
|
padding: 16px;
|
|
}
|
|
|
|
.tab-panel {
|
|
display: none;
|
|
}
|
|
|
|
.tab-panel.active {
|
|
display: block;
|
|
}
|
|
|
|
/* Tables */
|
|
.table-wrapper {
|
|
overflow-x: auto;
|
|
}
|
|
|
|
table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
font-size: 13px;
|
|
}
|
|
|
|
th {
|
|
padding: 12px 16px;
|
|
text-align: left;
|
|
font-weight: 900;
|
|
color: var(--text-primary);
|
|
border-bottom: var(--border-width) solid var(--border-color);
|
|
text-transform: uppercase;
|
|
font-size: 11px;
|
|
letter-spacing: 1px;
|
|
background: var(--bg-tertiary);
|
|
}
|
|
|
|
td {
|
|
padding: 12px 16px;
|
|
border-bottom: 1px solid var(--border-color);
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
tr:hover td {
|
|
background: var(--selection-bg);
|
|
color: var(--selection-text);
|
|
}
|
|
|
|
tr:hover .service-badge {
|
|
background: var(--border-color);
|
|
color: var(--bg-primary);
|
|
}
|
|
|
|
tr:last-child td {
|
|
border-bottom: none;
|
|
}
|
|
|
|
.time {
|
|
font-variant-numeric: tabular-nums;
|
|
font-weight: 700;
|
|
}
|
|
|
|
.percent {
|
|
font-variant-numeric: tabular-nums;
|
|
text-align: right;
|
|
color: var(--text-muted);
|
|
font-weight: 700;
|
|
}
|
|
|
|
.color-box {
|
|
display: inline-block;
|
|
width: 14px;
|
|
height: 14px;
|
|
margin-right: 8px;
|
|
vertical-align: middle;
|
|
border: 2px solid var(--border-color);
|
|
}
|
|
|
|
.service-badge {
|
|
display: inline-block;
|
|
font-size: 10px;
|
|
padding: 2px 6px;
|
|
background: var(--bg-tertiary);
|
|
border: 1px solid var(--border-color);
|
|
color: var(--text-muted);
|
|
margin-left: 8px;
|
|
text-transform: uppercase;
|
|
font-weight: 700;
|
|
letter-spacing: 0.5px;
|
|
}
|
|
|
|
.no-data {
|
|
text-align: center;
|
|
padding: 40px;
|
|
color: var(--text-muted);
|
|
font-weight: 700;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
/* Others row expansion */
|
|
.others-row {
|
|
cursor: pointer;
|
|
}
|
|
|
|
.others-row td:first-child::before {
|
|
content: '►';
|
|
display: inline-block;
|
|
margin-right: 8px;
|
|
font-size: 10px;
|
|
transition: transform 0.1s;
|
|
}
|
|
|
|
.others-row.expanded td:first-child::before {
|
|
transform: rotate(90deg);
|
|
}
|
|
|
|
.others-detail {
|
|
display: none;
|
|
background: var(--bg-tertiary);
|
|
}
|
|
|
|
.others-detail.visible {
|
|
display: table-row;
|
|
}
|
|
|
|
.others-detail td {
|
|
padding-left: 32px;
|
|
}
|
|
|
|
/* Scrollbar */
|
|
::-webkit-scrollbar {
|
|
width: 12px;
|
|
height: 12px;
|
|
}
|
|
|
|
::-webkit-scrollbar-track {
|
|
background: var(--bg-tertiary);
|
|
border: 1px solid var(--border-color);
|
|
}
|
|
|
|
::-webkit-scrollbar-thumb {
|
|
background: var(--text-muted);
|
|
border: 1px solid var(--border-color);
|
|
}
|
|
|
|
::-webkit-scrollbar-thumb:hover {
|
|
background: var(--text-secondary);
|
|
}
|
|
|
|
/* Responsive */
|
|
@media (max-width: 600px) {
|
|
body {
|
|
padding: 12px;
|
|
}
|
|
|
|
.stats {
|
|
gap: 12px;
|
|
}
|
|
|
|
.stat {
|
|
padding: 16px 20px;
|
|
min-width: 100px;
|
|
}
|
|
|
|
.stat-value {
|
|
font-size: 28px;
|
|
}
|
|
|
|
.filter-label {
|
|
padding: 6px 10px;
|
|
font-size: 11px;
|
|
}
|
|
|
|
.tabs {
|
|
padding: 0 12px;
|
|
}
|
|
|
|
.tab {
|
|
padding: 10px 16px;
|
|
font-size: 11px;
|
|
}
|
|
|
|
.theme-toggle {
|
|
width: 44px;
|
|
height: 44px;
|
|
font-size: 18px;
|
|
}
|
|
}
|
|
|
|
/* Scroll to Top Button */
|
|
.scroll-top {
|
|
position: fixed;
|
|
bottom: 20px;
|
|
right: 20px;
|
|
z-index: 1000;
|
|
width: 50px;
|
|
height: 50px;
|
|
border: var(--border-width) solid var(--border-color);
|
|
background: var(--bg-primary);
|
|
cursor: pointer;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
box-shadow: var(--shadow-offset) var(--shadow-offset) 0 var(--border-color);
|
|
opacity: 0;
|
|
visibility: hidden;
|
|
transition: opacity 0.2s, visibility 0.2s, transform 0.1s, box-shadow 0.1s;
|
|
}
|
|
|
|
.scroll-top.visible {
|
|
opacity: 1;
|
|
visibility: visible;
|
|
}
|
|
|
|
.scroll-top:hover {
|
|
transform: translate(-2px, -2px);
|
|
box-shadow: calc(var(--shadow-offset) + 2px) calc(var(--shadow-offset) + 2px) 0 var(--border-color);
|
|
}
|
|
|
|
.scroll-top:active {
|
|
transform: translate(2px, 2px);
|
|
box-shadow: calc(var(--shadow-offset) - 2px) calc(var(--shadow-offset) - 2px) 0 var(--border-color);
|
|
}
|
|
|
|
.scroll-top-arrow {
|
|
width: 0;
|
|
height: 0;
|
|
border-left: 10px solid transparent;
|
|
border-right: 10px solid transparent;
|
|
border-bottom: 12px solid var(--text-primary);
|
|
}
|
|
|
|
@media (max-width: 600px) {
|
|
.scroll-top {
|
|
width: 44px;
|
|
height: 44px;
|
|
}
|
|
|
|
.scroll-top-arrow {
|
|
border-left-width: 8px;
|
|
border-right-width: 8px;
|
|
border-bottom-width: 10px;
|
|
}
|
|
}
|
|
</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="brutal-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="brutal-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="brutal-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="brutal-card">
|
|
<div class="card-header">
|
|
<h2 class="card-title">Summaries</h2>
|
|
</div>
|
|
<div class="card-content" style="padding: 0; padding-top: 16px;">
|
|
<div class="tabs">
|
|
<div class="tab active" data-tab="games">Top Games</div>
|
|
<div class="tab" data-tab="categories">By Category</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>
|
|
</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 = '☀️';
|
|
themeIcon.className = 'icon';
|
|
themeToggle.title = 'Theme: Light (click to change)';
|
|
} else {
|
|
themeIcon.textContent = '🌙';
|
|
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__;
|
|
|
|
// Brutalist primary colors
|
|
const colors = [
|
|
'#ff0000', '#0000ff', '#ffff00', '#00ff00', '#ff00ff',
|
|
'#00ffff', '#ff8800', '#8800ff', '#0088ff', '#88ff00',
|
|
'#888888'
|
|
];
|
|
|
|
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
|
|
}));
|
|
|
|
let othersGames = [];
|
|
|
|
if (filtered.length > topN) {
|
|
othersGames = filtered.slice(topN).map(g => ({
|
|
name: g.name,
|
|
playtime: g.playtime,
|
|
service: g.service
|
|
}));
|
|
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' || cat === 'Horny') 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);
|
|
|
|
return { chartData: topGames, othersGames, categoriesData, totalPlaytime, totalGames };
|
|
}
|
|
|
|
function getChartTextColor() {
|
|
const theme = themes[currentThemeIndex];
|
|
if (theme === 'dark') return '#ffffff';
|
|
if (theme === 'light') return '#000000';
|
|
return getSystemTheme() === 'dark' ? '#ffffff' : '#000000';
|
|
}
|
|
|
|
function getChartBorderColor() {
|
|
const theme = themes[currentThemeIndex];
|
|
if (theme === 'dark') return '#ffffff';
|
|
if (theme === 'light') return '#000000';
|
|
return getSystemTheme() === 'dark' ? '#ffffff' : '#000000';
|
|
}
|
|
|
|
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, 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>';
|
|
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: colors.slice(0, chartData.length),
|
|
borderColor: borderColor,
|
|
borderWidth: 3
|
|
}]
|
|
},
|
|
options: {
|
|
responsive: true,
|
|
plugins: {
|
|
legend: {
|
|
position: 'bottom',
|
|
labels: {
|
|
color: textColor,
|
|
font: {
|
|
family: "'Courier New', monospace",
|
|
size: 11,
|
|
weight: 'bold'
|
|
},
|
|
padding: 12,
|
|
usePointStyle: true,
|
|
pointStyle: 'rect'
|
|
}
|
|
},
|
|
tooltip: {
|
|
backgroundColor: '#000000',
|
|
titleColor: '#ffffff',
|
|
bodyColor: '#ffffff',
|
|
borderColor: '#ffffff',
|
|
borderWidth: 2,
|
|
titleFont: { weight: 'bold', family: "'Courier New', monospace" },
|
|
bodyFont: { weight: 'normal', family: "'Courier New', monospace" },
|
|
cornerRadius: 0,
|
|
padding: 12,
|
|
callbacks: {
|
|
title: function(context) {
|
|
return context[0].label.toUpperCase();
|
|
},
|
|
beforeBody: function(context) {
|
|
const index = context[0].dataIndex;
|
|
const service = chartData[index].service;
|
|
if (service && service !== 'others') {
|
|
return service.toUpperCase();
|
|
}
|
|
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: colors.slice(0, categoriesChartData.length),
|
|
borderColor: borderColor,
|
|
borderWidth: 3
|
|
}]
|
|
},
|
|
options: {
|
|
responsive: true,
|
|
plugins: {
|
|
legend: {
|
|
position: 'bottom',
|
|
labels: {
|
|
color: textColor,
|
|
font: {
|
|
family: "'Courier New', monospace",
|
|
size: 11,
|
|
weight: 'bold'
|
|
},
|
|
padding: 12,
|
|
usePointStyle: true,
|
|
pointStyle: 'rect'
|
|
}
|
|
},
|
|
tooltip: {
|
|
backgroundColor: '#000000',
|
|
titleColor: '#ffffff',
|
|
bodyColor: '#ffffff',
|
|
borderColor: '#ffffff',
|
|
borderWidth: 2,
|
|
cornerRadius: 0,
|
|
padding: 12,
|
|
titleFont: { family: "'Courier New', monospace" },
|
|
bodyFont: { family: "'Courier New', monospace" },
|
|
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 row = document.createElement('tr');
|
|
if (isOthers) {
|
|
row.className = 'others-row';
|
|
}
|
|
row.innerHTML = `
|
|
<td>${index + 1}</td>
|
|
<td>
|
|
<span class="color-box" style="background: ${colors[index]}"></span>
|
|
${game.name}${serviceBadge}
|
|
</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 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>
|
|
</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: ${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: ${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'));
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
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>
|