Skip to content

Commit

Permalink
Merge pull request #3 from All-Hands-AI/master
Browse files Browse the repository at this point in the history
Add direct linking support for Lite, Verified, and Full tabs
  • Loading branch information
john-b-yang authored Jan 13, 2025
2 parents f8eb692 + c456098 commit 25f6694
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,15 @@ <h2 class="text-title">News</h2>
</div>
</div>
<div class="content-wrapper">
<div class="content-box">
<div class="content-box leaderboard">
<h2 class="text-title">Leaderboard</h2>
<ul class="tab">
<li><button id="tab-lite" class="tablinks" data-leaderboard="Lite">Lite</button></li>
<li><button id="tab-verified" class="tablinks" data-leaderboard="Verified">Verified</button></li>
<li><button id="tab-test" class="tablinks" data-leaderboard="Test">Full</button></li>
<li><button id="tab-full" class="tablinks" data-leaderboard="Full">Full</button></li>
</ul>

<div class="tabcontent" style="display: block" id="leaderboard-Test">
<div class="tabcontent" style="display: block" id="leaderboard-Full">
<table class="table scrollable">
<thead>
<tr>
Expand Down Expand Up @@ -5538,7 +5538,7 @@ <h3 class="text-title" style="margin-bottom:0.5em">Citation</h3>
</section>
</div>
<script>
function openLeaderboard(leaderboard) {
function openLeaderboard(leaderboard, updateHash = true) {
var tabcontent = document.getElementsByClassName("tabcontent");
for (var i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
Expand All @@ -5551,18 +5551,38 @@ <h3 class="text-title" style="margin-bottom:0.5em">Citation</h3>

document.getElementById(`leaderboard-${leaderboard}`).style.display = "block";
document.querySelector(`[data-leaderboard="${leaderboard}"]`).classList.add("active");

// Update URL hash if requested
if (updateHash) {
window.location.hash = leaderboard.toLowerCase();
}
}

document.addEventListener('DOMContentLoaded', function() {
var tabs = document.querySelectorAll('.tablinks');
tabs.forEach(function(tab) {
tab.addEventListener('click', function(event) {
openLeaderboard(this.getAttribute('data-leaderboard'));
// Scroll to leaderboard section after a slight delay
setTimeout(() => {
document.querySelector('.leaderboard').scrollIntoView({ behavior: 'smooth' });
}, 100);
});
});

// Open the 'lite' leaderboard by default
openLeaderboard('Lite');
// Check URL hash for tab selection
const hash = window.location.hash.slice(1).toLowerCase();
if (hash === 'lite' || hash === 'verified' || hash === 'full') {
const tabName = hash.charAt(0).toUpperCase() + hash.slice(1);
openLeaderboard(tabName, false);
// Scroll to leaderboard section after a slight delay
setTimeout(() => {
document.querySelector('.leaderboard').scrollIntoView({ behavior: 'smooth' });
}, 100);
} else {
// Open the 'lite' leaderboard by default if no hash
openLeaderboard('Lite', false);
}
});
</script>
</body>
Expand Down

0 comments on commit 25f6694

Please sign in to comment.