Linker1907 commited on
Commit
fe64e89
Β·
1 Parent(s): ffc7b47

Fix: Restore JavaScript and update LEADERBOARD_DATA with parametersInBillions

Browse files

- Restore all JavaScript functions that were accidentally removed
- Update LEADERBOARD_DATA with parametersInBillions field from API
- Fix applyAllFilters to use row.dataset.name instead of wrong selector
- Remove debug console.log statements

Files changed (1) hide show
  1. index.html +659 -0
index.html CHANGED
@@ -2807,6 +2807,665 @@ const LEADERBOARD_DATA =
2807
  }
2808
  ]
2809
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2810
  </script>
2811
  </body>
2812
  </html>
 
2807
  }
2808
  ]
2809
  }
2810
+ const BENCHMARK_CATEGORIES = {
2811
+ 'gsm8k': 'math',
2812
+ 'aime2026': 'math',
2813
+ 'hmmt2026': 'math',
2814
+ 'mmluPro': 'knowledge',
2815
+ 'gpqa': 'knowledge',
2816
+ 'hle': 'knowledge',
2817
+ 'sweVerified': 'coding',
2818
+ 'swePro': 'coding',
2819
+ 'olmOcr': 'vision',
2820
+ 'arguana': 'embedding',
2821
+ 'terminalBench': 'agent',
2822
+ 'evasionBench': 'language'
2823
+ };
2824
+
2825
+ // Benchmark filter functions
2826
+ let selectedBenchmarks = ['gsm8k', 'mmluPro', 'gpqa', 'hle', 'sweVerified', 'swePro', 'aime2026', 'terminalBench', 'evasionBench', 'hmmt2026'];
2827
+
2828
+ function toggleBenchmark(benchmarkKey) {
2829
+ const pill = document.querySelector(`.benchmark-pill[data-benchmark="${benchmarkKey}"]`);
2830
+
2831
+ if (selectedBenchmarks.includes(benchmarkKey)) {
2832
+ // Deselect
2833
+ selectedBenchmarks = selectedBenchmarks.filter(b => b !== benchmarkKey);
2834
+ pill.classList.remove('active');
2835
+ } else {
2836
+ // Select
2837
+ selectedBenchmarks.push(benchmarkKey);
2838
+ pill.classList.add('active');
2839
+ }
2840
+
2841
+ // Update table
2842
+ filterByBenchmarks(selectedBenchmarks);
2843
+ }
2844
+
2845
+ function selectAllBenchmarks() {
2846
+ // Get all benchmarks from BENCHMARK_CATEGORIES
2847
+ selectedBenchmarks = Object.keys(BENCHMARK_CATEGORIES);
2848
+
2849
+ // Update all pills to active
2850
+ document.querySelectorAll('.benchmark-pill').forEach(pill => {
2851
+ pill.classList.add('active');
2852
+ });
2853
+
2854
+ // Update table
2855
+ filterByBenchmarks(selectedBenchmarks);
2856
+ }
2857
+
2858
+ function deselectAllBenchmarks() {
2859
+ selectedBenchmarks = [];
2860
+
2861
+ // Update all pills to inactive
2862
+ document.querySelectorAll('.benchmark-pill').forEach(pill => {
2863
+ pill.classList.remove('active');
2864
+ });
2865
+
2866
+ // Update table
2867
+ filterByBenchmarks(selectedBenchmarks);
2868
+ }
2869
+
2870
+ function initBenchmarkFilter() {
2871
+ // Set initial active states based on selectedBenchmarks array
2872
+ selectedBenchmarks.forEach(benchKey => {
2873
+ const pill = document.querySelector(`.benchmark-pill[data-benchmark="${benchKey}"]`);
2874
+ if (pill) pill.classList.add('active');
2875
+ });
2876
+
2877
+ // Initial table population
2878
+ filterByBenchmarks(selectedBenchmarks);
2879
+ }
2880
+
2881
+ // ===== SIZE FILTER FUNCTIONS =====
2882
+
2883
+ function getModelSize(model) {
2884
+ // First try to get from metadata.parametersInBillions
2885
+ if (model.metadata && model.metadata.parametersInBillions !== null && model.metadata.parametersInBillions !== undefined) {
2886
+ return model.metadata.parametersInBillions;
2887
+ }
2888
+
2889
+ // Return null if not available (model will always be shown)
2890
+ return null;
2891
+ }
2892
+
2893
+ function initSizeFilter() {
2894
+ const minSlider = document.getElementById('minSize');
2895
+ const maxSlider = document.getElementById('maxSize');
2896
+ const minLabel = document.getElementById('minSizeLabel');
2897
+ const maxLabel = document.getElementById('maxSizeLabel');
2898
+ const sliderFill = document.getElementById('sliderFill');
2899
+
2900
+ function updateSlider() {
2901
+ let minVal = parseInt(minSlider.value);
2902
+ let maxVal = parseInt(maxSlider.value);
2903
+
2904
+ // Prevent thumbs from crossing
2905
+ if (minVal > maxVal - 1) {
2906
+ minVal = maxVal - 1;
2907
+ minSlider.value = minVal;
2908
+ }
2909
+ if (maxVal < minVal + 1) {
2910
+ maxVal = minVal + 1;
2911
+ maxSlider.value = maxVal;
2912
+ }
2913
+
2914
+ // Update labels
2915
+ minLabel.textContent = minVal + 'B';
2916
+ maxLabel.textContent = maxVal === 800 ? '800B+' : maxVal + 'B';
2917
+
2918
+ // Update fill bar
2919
+ const minPercent = (minVal / 800) * 100;
2920
+ const maxPercent = (maxVal / 800) * 100;
2921
+ sliderFill.style.left = minPercent + '%';
2922
+ sliderFill.style.width = (maxPercent - minPercent) + '%';
2923
+
2924
+ // Apply all filters
2925
+ applyAllFilters();
2926
+ }
2927
+
2928
+ // Real-time filtering on input (drag)
2929
+ minSlider.addEventListener('input', updateSlider);
2930
+ maxSlider.addEventListener('input', updateSlider);
2931
+
2932
+ // Initial update
2933
+ updateSlider();
2934
+ }
2935
+
2936
+ function applyAllFilters() {
2937
+ const searchTerm = document.getElementById('searchBox').value.toLowerCase();
2938
+ const minSize = parseInt(document.getElementById('minSize').value);
2939
+ const maxSize = parseInt(document.getElementById('maxSize').value);
2940
+
2941
+ // Get all rows
2942
+ const rows = document.querySelectorAll('#tableBody tr');
2943
+
2944
+ rows.forEach(row => {
2945
+ // Use dataset.name which is already set
2946
+ const modelName = row.dataset.name || '';
2947
+ const modelSize = parseFloat(row.dataset.size);
2948
+
2949
+ // Search filter
2950
+ const matchesSearch = !searchTerm || modelName.includes(searchTerm);
2951
+
2952
+ // Size filter (always show if no size data)
2953
+ let matchesSize = true;
2954
+ if (!isNaN(modelSize) && modelSize > 0) {
2955
+ matchesSize = modelSize >= minSize && modelSize <= maxSize;
2956
+ }
2957
+
2958
+ // Show row if matches all filters (AND logic)
2959
+ if (matchesSearch && matchesSize) {
2960
+ row.style.display = '';
2961
+ } else {
2962
+ row.style.display = 'none';
2963
+ }
2964
+ });
2965
+ }
2966
+
2967
+ function filterByBenchmarks(selectedBenchmarks) {
2968
+ if (selectedBenchmarks.length === 0) {
2969
+ // Show empty state or all hidden
2970
+ document.getElementById('tableBody').innerHTML = '<tr><td colspan="16" style="text-align:center;padding:40px;color:var(--text-muted);">No benchmarks selected. Please select at least one benchmark.</td></tr>';
2971
+ return;
2972
+ }
2973
+
2974
+ // Get categories for selected benchmarks
2975
+ const categoriesToShow = [...new Set(selectedBenchmarks.map(bench => BENCHMARK_CATEGORIES[bench]))];
2976
+
2977
+ // Populate table with selected benchmarks
2978
+ populateTableWithBenchmarks(selectedBenchmarks);
2979
+
2980
+ // Show/hide columns based on selected benchmarks
2981
+ const headers = document.querySelectorAll('thead th');
2982
+ const benchmarkMapping = {
2983
+ 'gsm8k': 2,
2984
+ 'mmluPro': 3,
2985
+ 'gpqa': 4,
2986
+ 'hle': 5,
2987
+ 'olmOcr': 6,
2988
+ 'sweVerified': 7,
2989
+ 'arguana': 8,
2990
+ 'swePro': 9,
2991
+ 'aime2026': 10,
2992
+ 'terminalBench': 11,
2993
+ 'evasionBench': 12,
2994
+ 'hmmt2026': 13
2995
+ };
2996
+
2997
+ // First show all benchmark columns
2998
+ Object.values(benchmarkMapping).forEach(colIndex => {
2999
+ const th = headers[colIndex];
3000
+ if (th) th.style.display = '';
3001
+ document.querySelectorAll(`tbody td:nth-child(${colIndex + 1})`).forEach(td => {
3002
+ td.style.display = '';
3003
+ });
3004
+ });
3005
+
3006
+ // Then hide unselected ones
3007
+ Object.entries(benchmarkMapping).forEach(([benchKey, colIndex]) => {
3008
+ if (!selectedBenchmarks.includes(benchKey)) {
3009
+ const th = headers[colIndex];
3010
+ if (th) th.style.display = 'none';
3011
+ document.querySelectorAll(`tbody td:nth-child(${colIndex + 1})`).forEach(td => {
3012
+ td.style.display = 'none';
3013
+ });
3014
+ }
3015
+ });
3016
+ }
3017
+
3018
+ function init() {
3019
+ // Initialize benchmark filter (defaults to 10 benchmarks selected, excluding vision and embedding)
3020
+ initBenchmarkFilter();
3021
+
3022
+ // Initialize size filter
3023
+ initSizeFilter();
3024
+
3025
+ // Load dark mode preference
3026
+ if (localStorage.getItem('dark') === 'true') {
3027
+ document.body.classList.add('dark');
3028
+ document.getElementById('darkBtn').textContent = 'β˜€οΈ Light';
3029
+ }
3030
+ }
3031
+
3032
+ function populateTableWithDefaultHidden() {
3033
+ // Populate with all categories except vision and embedding
3034
+ const categoriesToShow = ['math', 'knowledge', 'coding', 'agent', 'language'];
3035
+ populateTableWithCategories(categoriesToShow);
3036
+ hideColumnsByCategory(['vision', 'embedding']);
3037
+ }
3038
+
3039
+ function populateTableWithCategories(categories) {
3040
+ const tbody = document.getElementById('tableBody');
3041
+
3042
+ // Filter models to only show those with scores in visible categories
3043
+ // Keep original aggregate scores for fair ranking
3044
+ const processedModels = LEADERBOARD_DATA.models.map(model => {
3045
+ let visibleScoresCount = 0;
3046
+
3047
+ // Count how many visible benchmarks this model has scores for
3048
+ Object.keys(model.benchmarks).forEach(benchKey => {
3049
+ const benchCategory = BENCHMARK_CATEGORIES[benchKey];
3050
+ if (categories.includes(benchCategory) && model.benchmarks[benchKey]) {
3051
+ visibleScoresCount++;
3052
+ }
3053
+ });
3054
+
3055
+ return {
3056
+ ...model,
3057
+ visibleCoverageCount: visibleScoresCount,
3058
+ hasVisibleScores: visibleScoresCount > 0
3059
+ };
3060
+ });
3061
+
3062
+ // Filter out models with no scores in visible benchmarks
3063
+ // Sort by ORIGINAL aggregate score (not recalculated)
3064
+ const modelsToShow = processedModels
3065
+ .filter(model => model.hasVisibleScores)
3066
+ .sort((a, b) => b.aggregateScore - a.aggregateScore);
3067
+
3068
+ tbody.innerHTML = '';
3069
+
3070
+ // Calculate total visible benchmarks
3071
+ const totalVisibleBenchmarks = Object.keys(BENCHMARK_CATEGORIES).filter(benchKey => {
3072
+ const benchCategory = BENCHMARK_CATEGORIES[benchKey];
3073
+ return categories.includes(benchCategory);
3074
+ }).length;
3075
+
3076
+ modelsToShow.forEach((model, idx) => {
3077
+ const row = document.createElement('tr');
3078
+ if (model.type === 'open' && model.aggregateScore > 80) {
3079
+ row.classList.add('hl');
3080
+ }
3081
+ row.dataset.type = model.type;
3082
+ row.dataset.name = model.name.toLowerCase();
3083
+ row.dataset.provider = model.provider.toLowerCase();
3084
+ row.dataset.size = getModelSize(model) || '';
3085
+
3086
+ const typeBadge = model.type === 'open'
3087
+ ? '<span class="badge-type badge-open">Open</span>'
3088
+ : '<span class="badge-type badge-closed">Closed</span>';
3089
+
3090
+ const aggGrade = getGrade(model.aggregateScore);
3091
+
3092
+ row.innerHTML = `
3093
+ <td class="c-model">
3094
+ <div class="mc">
3095
+ <div class="mn">
3096
+ ${model.providerLogoUrl
3097
+ ? `<img src="${model.providerLogoUrl}" alt="${model.provider}" class="provider-logo-inline" title="${model.provider}" onerror="this.style.display='none';">`
3098
+ : `<span class="provider-logo-fallback-inline" title="${model.provider}">${model.provider.substring(0,2).toUpperCase()}</span>`
3099
+ }
3100
+ <a href="https://huggingface.co/${model.name}" target="_blank" rel="noopener noreferrer">${model.name}</a>
3101
+ </div>
3102
+ <div class="ms">
3103
+ <span class="mp">${model.provider}</span>
3104
+ <span class="mp">${model.metadata.parameters || 'Unknown'}</span>
3105
+ </div>
3106
+ </div>
3107
+ </td>
3108
+ <td>
3109
+ <div class="sc">
3110
+ <div class="sn ${aggGrade.class}">${model.aggregateScore.toFixed(1)}</div>
3111
+ <div class="sb"><div class="sf ${aggGrade.bar}" style="width:${model.aggregateScore}%"></div></div>
3112
+ <div style="font-size:7px;font-family:var(--font-mono);color:var(--text-muted);margin-top:2px">${model.visibleCoverageCount}/${totalVisibleBenchmarks}</div>
3113
+ </div>
3114
+ </td>
3115
+ ${renderScore(model.benchmarks.gsm8k)}
3116
+ ${renderScore(model.benchmarks.mmluPro)}
3117
+ ${renderScore(model.benchmarks.gpqa)}
3118
+ ${renderScore(model.benchmarks.hle)}
3119
+ ${renderScore(model.benchmarks.olmOcr)}
3120
+ ${renderScore(model.benchmarks.sweVerified)}
3121
+ ${renderScore(model.benchmarks.arguana)}
3122
+ ${renderScore(model.benchmarks.swePro)}
3123
+ ${renderScore(model.benchmarks.aime2026)}
3124
+ ${renderScore(model.benchmarks.terminalBench)}
3125
+ ${renderScore(model.benchmarks.evasionBench)}
3126
+ ${renderScore(model.benchmarks.hmmt2026)}
3127
+ `;
3128
+
3129
+ tbody.appendChild(row);
3130
+ });
3131
+
3132
+ // Update stats based on visible categories
3133
+ updateStatsForCategories(categories);
3134
+ }
3135
+
3136
+ function updateStatsForCategories(categories) {
3137
+ const modelsWithScores = LEADERBOARD_DATA.models.filter(model => {
3138
+ return Object.keys(model.benchmarks).some(benchKey => {
3139
+ const benchCategory = BENCHMARK_CATEGORIES[benchKey];
3140
+ return categories.includes(benchCategory) && model.benchmarks[benchKey];
3141
+ });
3142
+ });
3143
+
3144
+ const totalModels = modelsWithScores.length;
3145
+ const totalScores = modelsWithScores.reduce((sum, model) => {
3146
+ const visibleScores = Object.keys(model.benchmarks).filter(benchKey => {
3147
+ const benchCategory = BENCHMARK_CATEGORIES[benchKey];
3148
+ return categories.includes(benchCategory) && model.benchmarks[benchKey];
3149
+ }).length;
3150
+ return sum + visibleScores;
3151
+ }, 0);
3152
+
3153
+ document.getElementById('statModels').textContent = totalModels;
3154
+ document.getElementById('statScores').textContent = totalScores;
3155
+ }
3156
+
3157
+ function populateTableWithBenchmarks(selectedBenchmarks) {
3158
+ const tbody = document.getElementById('tableBody');
3159
+
3160
+ // Filter models to only show those with scores in selected benchmarks
3161
+ const processedModels = LEADERBOARD_DATA.models.map(model => {
3162
+ let visibleScoresCount = 0;
3163
+
3164
+ // Count how many selected benchmarks this model has scores for
3165
+ selectedBenchmarks.forEach(benchKey => {
3166
+ if (model.benchmarks[benchKey]) {
3167
+ visibleScoresCount++;
3168
+ }
3169
+ });
3170
+
3171
+ return {
3172
+ ...model,
3173
+ visibleCoverageCount: visibleScoresCount,
3174
+ hasVisibleScores: visibleScoresCount > 0
3175
+ };
3176
+ });
3177
+
3178
+ // Filter out models with no scores in selected benchmarks
3179
+ // Sort by ORIGINAL aggregate score
3180
+ const modelsToShow = processedModels
3181
+ .filter(model => model.hasVisibleScores)
3182
+ .sort((a, b) => b.aggregateScore - a.aggregateScore);
3183
+
3184
+ tbody.innerHTML = '';
3185
+
3186
+ const totalVisibleBenchmarks = selectedBenchmarks.length;
3187
+
3188
+ modelsToShow.forEach((model, idx) => {
3189
+ const row = document.createElement('tr');
3190
+ if (model.type === 'open' && model.aggregateScore > 80) {
3191
+ row.classList.add('hl');
3192
+ }
3193
+ row.dataset.type = model.type;
3194
+ row.dataset.name = model.name.toLowerCase();
3195
+ row.dataset.provider = model.provider.toLowerCase();
3196
+ row.dataset.size = getModelSize(model) || '';
3197
+
3198
+ const typeBadge = model.type === 'open'
3199
+ ? '<span class="badge-type badge-open">Open</span>'
3200
+ : '<span class="badge-type badge-closed">Closed</span>';
3201
+
3202
+ const aggGrade = getGrade(model.aggregateScore);
3203
+
3204
+ row.innerHTML = `
3205
+ <td class="c-model">
3206
+ <div class="mc">
3207
+ <div class="mn">
3208
+ ${model.providerLogoUrl
3209
+ ? `<img src="${model.providerLogoUrl}" alt="${model.provider}" class="provider-logo-inline" title="${model.provider}" onerror="this.style.display='none';">`
3210
+ : `<span class="provider-logo-fallback-inline" title="${model.provider}">${model.provider.substring(0,2).toUpperCase()}</span>`
3211
+ }
3212
+ <a href="https://huggingface.co/${model.name}" target="_blank" rel="noopener noreferrer">${model.name}</a>
3213
+ </div>
3214
+ <div class="ms">
3215
+ <span class="mp">${model.provider}</span>
3216
+ <span class="mp">${model.metadata.parameters || 'Unknown'}</span>
3217
+ </div>
3218
+ </div>
3219
+ </td>
3220
+ <td>
3221
+ <div class="sc">
3222
+ <div class="sn ${aggGrade.class}">${model.aggregateScore.toFixed(1)}</div>
3223
+ <div class="sb"><div class="sf ${aggGrade.bar}" style="width:${model.aggregateScore}%"></div></div>
3224
+ <div style="font-size:7px;font-family:var(--font-mono);color:var(--text-muted);margin-top:2px">${model.visibleCoverageCount}/${totalVisibleBenchmarks}</div>
3225
+ </div>
3226
+ </td>
3227
+ ${renderScore(model.benchmarks.gsm8k)}
3228
+ ${renderScore(model.benchmarks.mmluPro)}
3229
+ ${renderScore(model.benchmarks.gpqa)}
3230
+ ${renderScore(model.benchmarks.hle)}
3231
+ ${renderScore(model.benchmarks.olmOcr)}
3232
+ ${renderScore(model.benchmarks.sweVerified)}
3233
+ ${renderScore(model.benchmarks.arguana)}
3234
+ ${renderScore(model.benchmarks.swePro)}
3235
+ ${renderScore(model.benchmarks.aime2026)}
3236
+ ${renderScore(model.benchmarks.terminalBench)}
3237
+ ${renderScore(model.benchmarks.evasionBench)}
3238
+ ${renderScore(model.benchmarks.hmmt2026)}
3239
+ `;
3240
+
3241
+ tbody.appendChild(row);
3242
+ });
3243
+
3244
+ // Update stats
3245
+ updateStatsForBenchmarks(selectedBenchmarks);
3246
+ }
3247
+
3248
+ function updateStatsForBenchmarks(selectedBenchmarks) {
3249
+ const modelsWithScores = LEADERBOARD_DATA.models.filter(model => {
3250
+ return selectedBenchmarks.some(benchKey => model.benchmarks[benchKey]);
3251
+ });
3252
+
3253
+ const totalModels = modelsWithScores.length;
3254
+ const totalScores = modelsWithScores.reduce((sum, model) => {
3255
+ const visibleScores = selectedBenchmarks.filter(benchKey => model.benchmarks[benchKey]).length;
3256
+ return sum + visibleScores;
3257
+ }, 0);
3258
+
3259
+ document.getElementById('statModels').textContent = totalModels;
3260
+ document.getElementById('statScores').textContent = totalScores;
3261
+ }
3262
+
3263
+ function hideColumnsByCategory(categories) {
3264
+ const headers = document.querySelectorAll('thead th');
3265
+
3266
+ headers.forEach((th, index) => {
3267
+ if (index < 4) return; // Skip Model, Provider, Aggregate, Coverage
3268
+
3269
+ const classList = th.className.split(' ');
3270
+ const bmClass = classList.find(cls => cls.startsWith('bm-'));
3271
+
3272
+ if (!bmClass) return;
3273
+
3274
+ const benchCategory = bmClass.replace('bm-', '');
3275
+
3276
+ if (categories.includes(benchCategory)) {
3277
+ th.style.display = 'none';
3278
+ const cellSelector = `tbody td:nth-child(${index + 1})`;
3279
+ document.querySelectorAll(cellSelector).forEach(td => {
3280
+ td.style.display = 'none';
3281
+ });
3282
+ }
3283
+ });
3284
+ }
3285
+
3286
+ function toggleDark() {
3287
+ document.body.classList.toggle('dark');
3288
+ const isDark = document.body.classList.contains('dark');
3289
+ localStorage.setItem('dark', isDark);
3290
+ document.getElementById('darkBtn').textContent = isDark ? 'β˜€οΈ Light' : 'πŸŒ™ Dark';
3291
+ }
3292
+
3293
+ function getGrade(score) {
3294
+ if (score >= 90) return { class: 'grade-s', bar: 'bar-s', label: 'S' };
3295
+ if (score >= 75) return { class: 'grade-a', bar: 'bar-a', label: 'A' };
3296
+ if (score >= 60) return { class: 'grade-b', bar: 'bar-b', label: 'B' };
3297
+ return { class: 'grade-c', bar: 'bar-c', label: 'C' };
3298
+ }
3299
+
3300
+ function getConfidenceBadge(confidence) {
3301
+ const badges = {
3302
+ 'official': '<span class="conf-badge conf-official">βœ“βœ“ Official</span>',
3303
+ 'verified': '<span class="conf-badge conf-verified">βœ“ Verified</span>',
3304
+ 'community': '<span class="conf-badge conf-community">~ Community</span>'
3305
+ };
3306
+ return badges[confidence] || '';
3307
+ }
3308
+
3309
+ function renderScore(benchmarkData) {
3310
+ if (!benchmarkData) {
3311
+ return '<td><div class="sc"><span class="na">β€”</span></div></td>';
3312
+ }
3313
+
3314
+ const score = benchmarkData.score;
3315
+ const grade = getGrade(score);
3316
+ const conf = getConfidenceBadge(benchmarkData.confidence);
3317
+
3318
+ return `
3319
+ <td>
3320
+ <div class="sc" title="${benchmarkData.source || ''} (${benchmarkData.date || 'unknown date'})">
3321
+ <div class="sn ${grade.class}">${score.toFixed(1)}</div>
3322
+ <div class="sb"><div class="sf ${grade.bar}" style="width:${score}%"></div></div>
3323
+ ${conf}
3324
+ </div>
3325
+ </td>
3326
+ `;
3327
+ }
3328
+
3329
+
3330
+ function filterType(type) {
3331
+ currentFilter = type;
3332
+
3333
+ // Update button states
3334
+ document.querySelectorAll('.toolbar .fb').forEach(btn => {
3335
+ btn.classList.remove('on');
3336
+ });
3337
+ event.target.classList.add('on');
3338
+
3339
+ // Filter rows
3340
+ const rows = document.querySelectorAll('#tableBody tr');
3341
+ rows.forEach(row => {
3342
+ if (type === 'all') {
3343
+ row.classList.remove('hidden');
3344
+ } else {
3345
+ if (row.dataset.type === type) {
3346
+ row.classList.remove('hidden');
3347
+ } else {
3348
+ row.classList.add('hidden');
3349
+ }
3350
+ }
3351
+ });
3352
+ }
3353
+
3354
+ function filterModels() {
3355
+ // Delegate to unified filter function
3356
+ applyAllFilters();
3357
+ }
3358
+
3359
+ function filterCategory(category) {
3360
+ currentCategory = category;
3361
+
3362
+ // Update button states
3363
+ document.querySelectorAll('.toolbar button[onclick^="filterCategory"]').forEach(btn => {
3364
+ btn.classList.remove('on');
3365
+ });
3366
+ event.target.classList.add('on');
3367
+
3368
+ // Determine which categories to show
3369
+ let categoriesToShow;
3370
+ if (category === 'all') {
3371
+ categoriesToShow = Object.values(BENCHMARK_CATEGORIES).filter((v, i, a) => a.indexOf(v) === i);
3372
+ } else {
3373
+ categoriesToShow = [category];
3374
+ }
3375
+
3376
+ // Repopulate table with filtered benchmarks and recalculated scores
3377
+ populateTableWithCategories(categoriesToShow);
3378
+
3379
+ // Show all columns first
3380
+ const headers = document.querySelectorAll('thead th');
3381
+ headers.forEach((th, index) => {
3382
+ if (index < 4) return;
3383
+ th.style.display = '';
3384
+ const cellSelector = `tbody td:nth-child(${index + 1})`;
3385
+ document.querySelectorAll(cellSelector).forEach(td => {
3386
+ td.style.display = '';
3387
+ });
3388
+ });
3389
+
3390
+ // Hide columns not in the selected category
3391
+ headers.forEach((th, index) => {
3392
+ if (index < 4) return;
3393
+
3394
+ const classList = th.className.split(' ');
3395
+ const bmClass = classList.find(cls => cls.startsWith('bm-'));
3396
+
3397
+ if (!bmClass) return;
3398
+
3399
+ const benchCategory = bmClass.replace('bm-', '');
3400
+
3401
+ if (!categoriesToShow.includes(benchCategory)) {
3402
+ th.style.display = 'none';
3403
+ const cellSelector = `tbody td:nth-child(${index + 1})`;
3404
+ document.querySelectorAll(cellSelector).forEach(td => {
3405
+ td.style.display = 'none';
3406
+ });
3407
+ }
3408
+ });
3409
+ }
3410
+
3411
+ function sortTable(colIndex) {
3412
+ // Not implemented yet - placeholder
3413
+ console.log('Sort by column:', colIndex);
3414
+ }
3415
+
3416
+
3417
+ // Initialize on page load
3418
+ window.addEventListener('DOMContentLoaded', init);
3419
+ </script>
3420
+
3421
+ <script type="module">
3422
+ import { oauthLoginUrl, oauthHandleRedirectIfPresent } from "@huggingface/hub";
3423
+
3424
+ console.log("Initializing OAuth...");
3425
+
3426
+ let oauthResult = localStorage.getItem("oauth");
3427
+
3428
+ if (oauthResult) {
3429
+ try {
3430
+ oauthResult = JSON.parse(oauthResult);
3431
+ } catch {
3432
+ oauthResult = null;
3433
+ }
3434
+ }
3435
+
3436
+ oauthResult ||= await oauthHandleRedirectIfPresent();
3437
+
3438
+ if (oauthResult) {
3439
+ // User is logged in
3440
+ console.log("OAuth success:", oauthResult);
3441
+ localStorage.setItem("oauth", JSON.stringify(oauthResult));
3442
+
3443
+ // Show user info
3444
+ document.getElementById("oauthUser").style.display = "flex";
3445
+ document.getElementById("oauthAvatar").src = oauthResult.userInfo?.avatarUrl || "";
3446
+ document.getElementById("oauthUsername").textContent = oauthResult.userInfo?.name || "User";
3447
+
3448
+ // Setup signout
3449
+ document.getElementById("oauthSignout").onclick = async function() {
3450
+ localStorage.removeItem("oauth");
3451
+ window.location.href = window.location.href.replace(/\?.*$/, '');
3452
+ window.location.reload();
3453
+ };
3454
+
3455
+ // Store token globally for API calls
3456
+ window.HF_TOKEN = oauthResult.accessToken;
3457
+
3458
+ console.log("User logged in:", oauthResult.userInfo?.name);
3459
+ console.log("Token available for gated datasets");
3460
+
3461
+ } else {
3462
+ // User is not logged in
3463
+ document.getElementById("oauthSignin").style.display = "inline-block";
3464
+ document.getElementById("oauthSignin").onclick = async function() {
3465
+ const scopes = window.huggingface?.variables?.OAUTH_SCOPES || "openid profile email read-repos gated-repos";
3466
+ window.location.href = (await oauthLoginUrl({scopes: scopes})) + "&prompt=consent";
3467
+ };
3468
+ }
3469
  </script>
3470
  </body>
3471
  </html>