mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-31 17:55:01 +00:00
Feat: Add toggleable detail view to leaderboard table
This commit is contained in:
parent
d33a571f7d
commit
f961eecab6
2 changed files with 74 additions and 24 deletions
|
@ -86,20 +86,25 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Remove row ID assignment and click handler from here,
|
||||||
|
// as it's now handled in the main markdown file's script
|
||||||
|
// to accommodate the new details rows.
|
||||||
|
|
||||||
|
// Add click handler for chart selection (if needed separately from toggle)
|
||||||
var tableBody = document.querySelector('table tbody');
|
var tableBody = document.querySelector('table tbody');
|
||||||
allData.forEach(function(row, index) {
|
var mainRows = tableBody.querySelectorAll('tr[id^="main-row-"]');
|
||||||
var tr = tableBody.children[index];
|
mainRows.forEach(function(tr) {
|
||||||
if (!tr) {
|
// Find the cells to make clickable, excluding the toggle button cell (first child)
|
||||||
// If the row doesn't exist, create it
|
var clickableCells = tr.querySelectorAll('td:not(:first-child)');
|
||||||
tr = document.createElement('tr');
|
clickableCells.forEach(function(cell) {
|
||||||
tableBody.appendChild(tr);
|
cell.style.cursor = 'pointer';
|
||||||
}
|
cell.onclick = function() {
|
||||||
tr.id = 'edit-row-' + index;
|
// Prevent selection when clicking on links or code inside cells if needed
|
||||||
tr.style.cursor = 'pointer';
|
// if (event.target.tagName === 'A' || event.target.tagName === 'CODE') return;
|
||||||
tr.onclick = function() {
|
tr.classList.toggle('selected');
|
||||||
this.classList.toggle('selected');
|
updateChart();
|
||||||
updateChart();
|
};
|
||||||
};
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
var leaderboardChart = new Chart(ctx, {
|
var leaderboardChart = new Chart(ctx, {
|
||||||
|
@ -207,26 +212,38 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||||
document.getElementById('editSearchInput').addEventListener('keyup', function() {
|
document.getElementById('editSearchInput').addEventListener('keyup', function() {
|
||||||
var searchWords = this.value.toLowerCase().split(' ').filter(word => word.length > 0);
|
var searchWords = this.value.toLowerCase().split(' ').filter(word => word.length > 0);
|
||||||
var tableBody = document.querySelector('table:first-of-type tbody');
|
var tableBody = document.querySelector('table:first-of-type tbody');
|
||||||
var rows = tableBody.getElementsByTagName('tr');
|
// Select only main data rows for filtering logic
|
||||||
|
var mainRows = tableBody.querySelectorAll('tr[id^="main-row-"]');
|
||||||
|
|
||||||
displayedData = [];
|
displayedData = [];
|
||||||
leaderboardData.labels = [];
|
leaderboardData.labels = [];
|
||||||
leaderboardData.datasets[0].data = [];
|
leaderboardData.datasets[0].data = [];
|
||||||
leaderboardData.datasets[1].data = [];
|
leaderboardData.datasets[1].data = [];
|
||||||
|
|
||||||
for (var i = 0; i < rows.length; i++) {
|
// Iterate through main rows using their index relative to the allData array
|
||||||
var rowText = rows[i].textContent;
|
mainRows.forEach(function(row, i) {
|
||||||
|
// The index `i` corresponds to the index in `allData` because `mainRows` only contains the primary data rows.
|
||||||
|
var detailsRow = document.getElementById('details-' + i); // Find corresponding details row
|
||||||
|
var rowText = row.textContent; // Search only within the main row's text content
|
||||||
|
|
||||||
if (searchWords.every(word => rowText.toLowerCase().includes(word))) {
|
if (searchWords.every(word => rowText.toLowerCase().includes(word))) {
|
||||||
rows[i].style.display = '';
|
row.style.display = ''; // Show main row
|
||||||
displayedData.push(allData[i]);
|
displayedData.push(allData[i]); // Add data to chart source
|
||||||
leaderboardData.labels.push(allData[i].model);
|
leaderboardData.labels.push(allData[i].model);
|
||||||
leaderboardData.datasets[0].data.push(allData[i].pass_rate);
|
leaderboardData.datasets[0].data.push(allData[i].pass_rate);
|
||||||
// Only include cost if it's not zero (placeholder for unknown)
|
// Only include cost if it's not zero (placeholder for unknown)
|
||||||
leaderboardData.datasets[1].data.push(allData[i].total_cost > 0 ? allData[i].total_cost : null);
|
leaderboardData.datasets[1].data.push(allData[i].total_cost > 0 ? allData[i].total_cost : null);
|
||||||
|
|
||||||
|
// Ensure details row is hidden and toggle is reset when filtering
|
||||||
|
if (detailsRow) detailsRow.style.display = 'none';
|
||||||
|
const toggleButton = row.querySelector('.toggle-details');
|
||||||
|
if (toggleButton) toggleButton.textContent = '+';
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
rows[i].style.display = 'none';
|
row.style.display = 'none'; // Hide main row
|
||||||
|
if (detailsRow) detailsRow.style.display = 'none'; // Hide details row too
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
leaderboardChart.update();
|
leaderboardChart.update();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -23,6 +23,7 @@ Aider works best with high-scoring models, though it [can connect to almost any
|
||||||
<table style="width: 100%; max-width: 800px; margin: auto; border-collapse: collapse; box-shadow: 0 2px 4px rgba(0,0,0,0.1); font-size: 14px;">
|
<table style="width: 100%; max-width: 800px; margin: auto; border-collapse: collapse; box-shadow: 0 2px 4px rgba(0,0,0,0.1); font-size: 14px;">
|
||||||
<thead style="background-color: #f2f2f2;">
|
<thead style="background-color: #f2f2f2;">
|
||||||
<tr>
|
<tr>
|
||||||
|
<th style="padding: 8px; width: 30px;"></th> <!-- Toggle column -->
|
||||||
<th style="padding: 8px; text-align: left;">Model</th>
|
<th style="padding: 8px; text-align: left;">Model</th>
|
||||||
<th style="padding: 8px; text-align: center;">Percent correct</th>
|
<th style="padding: 8px; text-align: center;">Percent correct</th>
|
||||||
<th style="padding: 8px; text-align: center;">Cost (log scale)</th>
|
<th style="padding: 8px; text-align: center;">Cost (log scale)</th>
|
||||||
|
@ -38,8 +39,12 @@ Aider works best with high-scoring models, though it [can connect to almost any
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if max_cost == 0 %}{% assign max_cost = 1 %}{% endif %}
|
{% if max_cost == 0 %}{% assign max_cost = 1 %}{% endif %}
|
||||||
{% assign edit_sorted = site.data.polyglot_leaderboard | sort: 'pass_rate_2' | reverse %}
|
{% assign edit_sorted = site.data.polyglot_leaderboard | sort: 'pass_rate_2' | reverse %}
|
||||||
{% for row in edit_sorted %}
|
{% for row in edit_sorted %} {% comment %} Add loop index for unique IDs {% endcomment %}
|
||||||
<tr style="border-bottom: 1px solid #ddd;">
|
{% assign row_index = forloop.index0 %}
|
||||||
|
<tr style="border-bottom: 1px solid #ddd;" id="main-row-{{ row_index }}">
|
||||||
|
<td style="padding: 8px; text-align: center;">
|
||||||
|
<button class="toggle-details" data-target="details-{{ row_index }}" style="background: none; border: none; cursor: pointer; font-size: 16px; padding: 0;">+</button>
|
||||||
|
</td>
|
||||||
<td style="padding: 8px;"><span>{{ row.model }}</span></td>
|
<td style="padding: 8px;"><span>{{ row.model }}</span></td>
|
||||||
<td class="bar-cell">
|
<td class="bar-cell">
|
||||||
<div class="bar-viz" style="width: {{ row.pass_rate_2 }}%; background-color: rgba(40, 167, 69, 0.3); border-right: 1px solid rgba(40, 167, 69, 0.5);"></div>
|
<div class="bar-viz" style="width: {{ row.pass_rate_2 }}%; background-color: rgba(40, 167, 69, 0.3); border-right: 1px solid rgba(40, 167, 69, 0.5);"></div>
|
||||||
|
@ -54,6 +59,19 @@ Aider works best with high-scoring models, though it [can connect to almost any
|
||||||
</td>
|
</td>
|
||||||
<td style="padding: 8px;"><span><code>{{ row.command }}</code></span></td>
|
<td style="padding: 8px;"><span><code>{{ row.command }}</code></span></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr class="details-row" id="details-{{ row_index }}" style="display: none; background-color: #f9f9f9;">
|
||||||
|
<td colspan="5" style="padding: 15px; border-bottom: 1px solid #ddd;">
|
||||||
|
<ul style="margin: 0; padding-left: 20px; list-style: none;">
|
||||||
|
{% for pair in row %}
|
||||||
|
{% if pair[1] != "" and pair[1] != nil %}
|
||||||
|
<li><strong>{{ pair[0] | replace: '_', ' ' | capitalize }}:</strong>
|
||||||
|
{% if pair[0] == 'command' %}<code>{{ pair[1] }}</code>{% else %}{{ pair[1] }}{% endif %}
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -224,6 +242,21 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add toggle functionality for details
|
||||||
|
const toggleButtons = document.querySelectorAll('.toggle-details');
|
||||||
|
toggleButtons.forEach(button => {
|
||||||
|
button.addEventListener('click', function() {
|
||||||
|
const targetId = this.getAttribute('data-target');
|
||||||
|
const targetRow = document.getElementById(targetId);
|
||||||
|
if (targetRow) {
|
||||||
|
const isVisible = targetRow.style.display !== 'none';
|
||||||
|
targetRow.style.display = isVisible ? 'none' : 'table-row';
|
||||||
|
this.textContent = isVisible ? '+' : '-';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue