Spaces:
Running
Running
Update index.html
Browse files- index.html +21 -35
index.html
CHANGED
|
@@ -229,8 +229,7 @@
|
|
| 229 |
<div class="modal" id="modal" style="display: none;"></div>
|
| 230 |
|
| 231 |
<script>
|
| 232 |
-
|
| 233 |
-
function parseCSV(content) {
|
| 234 |
const rows = [];
|
| 235 |
let currentRow = [];
|
| 236 |
let currentField = '';
|
|
@@ -251,35 +250,27 @@
|
|
| 251 |
currentField += char;
|
| 252 |
}
|
| 253 |
}
|
| 254 |
-
// Add the last field and row if any
|
| 255 |
if (currentField) currentRow.push(currentField.trim());
|
| 256 |
if (currentRow.length > 0) rows.push(currentRow);
|
| 257 |
-
|
| 258 |
-
const headers = rows.shift(); // First row is headers
|
| 259 |
return { headers, rows };
|
| 260 |
}
|
| 261 |
-
|
| 262 |
-
// Function to load CSV from Hugging Face (commented out for Canvas preview)
|
| 263 |
async function loadCSVFromHuggingFace(dataset, filename, token) {
|
| 264 |
-
const url =
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
}
|
| 275 |
-
|
| 276 |
-
const content = await response.text();
|
| 277 |
-
return parseCSV(content);
|
| 278 |
-
} catch (error) {
|
| 279 |
-
console.error("Error loading CSV from Hugging Face:", error);
|
| 280 |
-
// Fallback or error message to user could go here
|
| 281 |
-
return { headers: [], rows: [] };
|
| 282 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 283 |
}
|
| 284 |
|
| 285 |
const metricFilter = document.getElementById('metricFilter');
|
|
@@ -449,16 +440,11 @@
|
|
| 449 |
|
| 450 |
let parsedCSV;
|
| 451 |
|
| 452 |
-
loadCSVFromHuggingFace('UlrickBL/benchmark_overview', 'benchmark_overview.csv', window.huggingface.variables.HF_TOKEN)
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
})
|
| 458 |
-
.catch(error => {
|
| 459 |
-
console.error("Failed to load CSV data:", error);
|
| 460 |
-
tableBody.innerHTML = '<tr><td colspan="7" style="text-align: center; color: #ff6b6b;">Failed to load data. Please check the dataset link or your internet connection.</td></tr>';
|
| 461 |
-
});
|
| 462 |
</script>
|
| 463 |
</body>
|
| 464 |
</html>
|
|
|
|
| 229 |
<div class="modal" id="modal" style="display: none;"></div>
|
| 230 |
|
| 231 |
<script>
|
| 232 |
+
function parseCSV(content) {
|
|
|
|
| 233 |
const rows = [];
|
| 234 |
let currentRow = [];
|
| 235 |
let currentField = '';
|
|
|
|
| 250 |
currentField += char;
|
| 251 |
}
|
| 252 |
}
|
|
|
|
| 253 |
if (currentField) currentRow.push(currentField.trim());
|
| 254 |
if (currentRow.length > 0) rows.push(currentRow);
|
| 255 |
+
const headers = rows.shift();
|
|
|
|
| 256 |
return { headers, rows };
|
| 257 |
}
|
|
|
|
|
|
|
| 258 |
async function loadCSVFromHuggingFace(dataset, filename, token) {
|
| 259 |
+
const url = 'https://huggingface.co/datasets/UlrickBL/benchmark_overview/resolve/main/benchmark_overview.csv'//`https://huggingface.co/datasets/${dataset}/blob/main/${filename}`;
|
| 260 |
+
|
| 261 |
+
const response = await fetch(url, {
|
| 262 |
+
headers: {
|
| 263 |
+
'Authorization': `Bearer ${token}`,
|
| 264 |
+
},
|
| 265 |
+
});
|
| 266 |
+
|
| 267 |
+
if (!response.ok) {
|
| 268 |
+
throw new Error(`Failed to fetch file: ${response.statusText}`);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 269 |
}
|
| 270 |
+
|
| 271 |
+
const content = await response.text();
|
| 272 |
+
|
| 273 |
+
return parseCSV(content);
|
| 274 |
}
|
| 275 |
|
| 276 |
const metricFilter = document.getElementById('metricFilter');
|
|
|
|
| 440 |
|
| 441 |
let parsedCSV;
|
| 442 |
|
| 443 |
+
loadCSVFromHuggingFace('UlrickBL/benchmark_overview', 'benchmark_overview.csv', window.huggingface.variables.HF_TOKEN).then(({ headers, rows }) => {
|
| 444 |
+
parsedCSV = { headers, rows };
|
| 445 |
+
populateFilterOptions(rows, 0);
|
| 446 |
+
populateTable(headers, rows, '', 0);
|
| 447 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 448 |
</script>
|
| 449 |
</body>
|
| 450 |
</html>
|