Skip to content

Commit d38eedb

Browse files
committed
Enh(viewer): Jump to round
1 parent 78c64d0 commit d38eedb

3 files changed

Lines changed: 102 additions & 2 deletions

File tree

codeclash/viewer/static/css/style.css

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,3 +948,71 @@ summary:focus {
948948
align-self: flex-start;
949949
}
950950
}
951+
952+
/* Navigation button styles */
953+
.nav-to-round-btn {
954+
background: var(--accent-color);
955+
color: white;
956+
border: none;
957+
padding: 0.5rem 0.75rem;
958+
border-radius: 50%;
959+
cursor: pointer;
960+
font-size: 1rem;
961+
transition: all 0.2s;
962+
display: inline-flex;
963+
align-items: center;
964+
justify-content: center;
965+
min-width: 2rem;
966+
min-height: 2rem;
967+
}
968+
969+
.nav-to-round-btn:hover {
970+
background: var(--accent-hover);
971+
transform: translateY(1px);
972+
}
973+
974+
.nav-to-round-btn:active {
975+
transform: translateY(2px);
976+
}
977+
978+
.nav-arrow {
979+
font-weight: bold;
980+
font-size: 1.1rem;
981+
}
982+
983+
/* Round anchor positioning */
984+
.round-anchor {
985+
position: relative;
986+
top: -80px; /* Offset for fixed header */
987+
visibility: hidden;
988+
}
989+
990+
/* Highlight effect for jumped-to rounds */
991+
.highlight-round {
992+
animation: roundHighlight 2s ease-in-out;
993+
}
994+
995+
@keyframes roundHighlight {
996+
0% {
997+
background-color: var(--accent-color);
998+
opacity: 0.1;
999+
}
1000+
50% {
1001+
background-color: var(--accent-color);
1002+
opacity: 0.2;
1003+
}
1004+
100% {
1005+
background-color: transparent;
1006+
opacity: 1;
1007+
}
1008+
}
1009+
1010+
/* Make table rows clickable-looking on hover */
1011+
.results-table tbody tr:hover {
1012+
background-color: var(--bg-secondary);
1013+
cursor: default;
1014+
}
1015+
1016+
.results-table tbody tr:hover .nav-to-round-btn {
1017+
transform: scale(1.1);
1018+
}

codeclash/viewer/static/js/app.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,29 @@ function collapseTrajectoryMessages(clickedElement) {
224224
}
225225
}
226226

227+
// Round navigation functionality
228+
function scrollToRound(roundNum) {
229+
const roundAnchor = document.getElementById(`round-${roundNum}`);
230+
if (roundAnchor) {
231+
// Smooth scroll to the round section
232+
roundAnchor.scrollIntoView({
233+
behavior: "smooth",
234+
block: "start",
235+
});
236+
237+
// Add a brief highlight effect
238+
const roundSection = roundAnchor.nextElementSibling;
239+
if (roundSection) {
240+
roundSection.classList.add("highlight-round");
241+
setTimeout(() => {
242+
roundSection.classList.remove("highlight-round");
243+
}, 2000);
244+
}
245+
} else {
246+
console.warn(`Round ${roundNum} anchor not found`);
247+
}
248+
}
249+
227250
// Initialize everything when DOM is loaded
228251
document.addEventListener("DOMContentLoaded", function () {
229252
initializeTheme();

codeclash/viewer/templates/index.html

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ <h2>📊 Overview</h2>
117117
{% for trajectory in trajectories_by_round.get(1, []) %}
118118
<th>Player {{ trajectory.player_id }} Steps</th>
119119
{% endfor %}
120+
<th>Actions</th>
120121
</tr>
121122
</thead>
122123
<tbody>
@@ -158,6 +159,11 @@ <h2>📊 Overview</h2>
158159
<td><span class="no-result">-</span></td>
159160
{% endfor %}
160161
{% endif %}
162+
<td>
163+
<button class="nav-to-round-btn" onclick="scrollToRound({{ round_data.round_num }})" title="Jump to Round {{ round_data.round_num }} details">
164+
<span class="nav-arrow"></span>
165+
</button>
166+
</td>
161167
</tr>
162168
{% endfor %}
163169
</tbody>
@@ -172,6 +178,9 @@ <h2>🎯 Detailed Rounds</h2>
172178
{% for round_data in metadata.rounds %}
173179
{% set round_num = round_data.round_num %}
174180

181+
<!-- Round Anchor for Navigation -->
182+
<div id="round-{{ round_num }}" class="round-anchor"></div>
183+
175184
<!-- Player Trajectories for this round -->
176185
{% if round_num in trajectories_by_round %}
177186
{% for trajectory in trajectories_by_round[round_num] %}
@@ -599,7 +608,7 @@ <h3>
599608
modes: ['view', 'tree'],
600609
name: 'metadata'
601610
});
602-
metadataEditor.set({{ metadata.results | tojson }});
611+
metadataEditor.set({{ metadata.results | tojson | safe }});
603612

604613
// Initialize round results JSON editors
605614
{% for round_data in metadata.rounds %}
@@ -609,7 +618,7 @@ <h3>
609618
modes: ['view', 'tree'],
610619
name: 'round_{{ round_data.round_num }}_results'
611620
});
612-
round{{ round_data.round_num }}Editor.set({{ round_data.results | tojson }});
621+
round{{ round_data.round_num }}Editor.set({{ round_data.results | tojson | safe }});
613622
{% endif %}
614623
{% endfor %}
615624
});

0 commit comments

Comments
 (0)