Add category badges to game tables in all templates
Display game categories as colored badges after service badges in both top games and others sections. Categories filtered to exclude .hidden, favorite, and Horny. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -445,6 +445,20 @@
|
||||
inset 1px 1px 2px var(--shadow-inset-dark),
|
||||
inset -1px -1px 2px var(--shadow-inset-light);
|
||||
}
|
||||
.category-badge {
|
||||
display: inline-block;
|
||||
font-size: 10px;
|
||||
padding: 3px 10px;
|
||||
background: var(--bg-tertiary);
|
||||
border-radius: 12px;
|
||||
color: var(--accent-color);
|
||||
margin-left: 4px;
|
||||
text-transform: capitalize;
|
||||
font-weight: 500;
|
||||
box-shadow:
|
||||
inset 1px 1px 2px var(--shadow-inset-dark),
|
||||
inset -1px -1px 2px var(--shadow-inset-light);
|
||||
}
|
||||
|
||||
.no-data {
|
||||
text-align: center;
|
||||
@@ -845,7 +859,8 @@
|
||||
const topGames = filtered.slice(0, topN).map(g => ({
|
||||
name: g.name,
|
||||
playtime: g.playtime,
|
||||
service: g.service
|
||||
service: g.service,
|
||||
categories: g.categories || []
|
||||
}));
|
||||
|
||||
let othersGames = [];
|
||||
@@ -854,7 +869,8 @@
|
||||
othersGames = filtered.slice(topN).map(g => ({
|
||||
name: g.name,
|
||||
playtime: g.playtime,
|
||||
service: g.service
|
||||
service: g.service,
|
||||
categories: g.categories || []
|
||||
}));
|
||||
const othersPlaytime = othersGames.reduce((sum, g) => sum + g.playtime, 0);
|
||||
const othersCount = othersGames.length;
|
||||
@@ -1050,6 +1066,12 @@
|
||||
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' && cat !== 'Horny')
|
||||
.map(cat => `<span class="category-badge">${cat}</span>`)
|
||||
.join('')
|
||||
: '';
|
||||
const row = document.createElement('tr');
|
||||
if (isOthers) {
|
||||
row.className = 'others-row';
|
||||
@@ -1058,7 +1080,7 @@
|
||||
<td>${index + 1}</td>
|
||||
<td>
|
||||
<span class="color-box" style="background: ${colors[index]}"></span>
|
||||
${game.name}${serviceBadge}
|
||||
${game.name}${serviceBadge}${categoriesBadges}
|
||||
</td>
|
||||
<td class="time">${formatTime(game.playtime)}</td>
|
||||
<td class="percent">${percent}%</td>
|
||||
@@ -1069,13 +1091,19 @@
|
||||
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' && cat !== 'Horny')
|
||||
.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>
|
||||
<span class="service-badge">${otherGame.service}</span>${otherCategoriesBadges}
|
||||
</td>
|
||||
<td class="time">${formatTime(otherGame.playtime)}</td>
|
||||
<td class="percent">${otherPercent}%</td>
|
||||
|
||||
Reference in New Issue
Block a user