Spaces:
Running
Running
Set model_title to every row (not cell) and only if table is scrolled
Browse files
app.py
CHANGED
@@ -397,9 +397,9 @@ tr.row_odd {
|
|
397 |
font-weight: bolder;
|
398 |
}
|
399 |
|
400 |
-
.leaderboard-table
|
401 |
content: attr(model_title);
|
402 |
-
position:
|
403 |
background-color: rgba(50, 50, 50, 0.9);
|
404 |
color: white;
|
405 |
padding: 5px;
|
@@ -407,6 +407,8 @@ tr.row_odd {
|
|
407 |
white-space: nowrap;
|
408 |
z-index: 10;
|
409 |
pointer-events: none;
|
|
|
|
|
410 |
}
|
411 |
|
412 |
"""
|
@@ -414,34 +416,43 @@ tr.row_odd {
|
|
414 |
custom_js = """
|
415 |
<script>
|
416 |
|
417 |
-
function
|
418 |
-
const
|
419 |
|
420 |
-
|
421 |
-
|
422 |
-
const firstCellLink = row.querySelector('td a');
|
423 |
|
424 |
-
if (
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
435 |
|
436 |
-
//
|
437 |
-
|
438 |
}
|
439 |
});
|
440 |
}
|
441 |
});
|
442 |
}
|
443 |
|
444 |
-
const intervalId = setInterval(
|
445 |
|
446 |
</script>
|
447 |
"""
|
|
|
397 |
font-weight: bolder;
|
398 |
}
|
399 |
|
400 |
+
.leaderboard-table tr[model_title]:hover::after, .leaderboard-table-model-details tr[model_title]:hover::after {
|
401 |
content: attr(model_title);
|
402 |
+
position: fixed;
|
403 |
background-color: rgba(50, 50, 50, 0.9);
|
404 |
color: white;
|
405 |
padding: 5px;
|
|
|
407 |
white-space: nowrap;
|
408 |
z-index: 10;
|
409 |
pointer-events: none;
|
410 |
+
left: 120px;
|
411 |
+
transform: translateY(150%);
|
412 |
}
|
413 |
|
414 |
"""
|
|
|
416 |
custom_js = """
|
417 |
<script>
|
418 |
|
419 |
+
function addTitleForEachRowOfLeaderboardTable(){
|
420 |
+
const tables = document.querySelectorAll('.leaderboard-table table, .leaderboard-table-model-details table');
|
421 |
|
422 |
+
tables.forEach(table => {
|
423 |
+
const rows = table.querySelectorAll('tr');
|
|
|
424 |
|
425 |
+
if (table.scrollLeft > 10) {
|
426 |
+
rows.forEach(row => {
|
427 |
+
// Find the first cell in the row that contains a link
|
428 |
+
const firstCellLink = row.querySelector('td a');
|
429 |
+
|
430 |
+
if (firstCellLink) {
|
431 |
+
// Get the value of the title attribute from the first link
|
432 |
+
const titleText = firstCellLink.getAttribute('title');
|
433 |
+
|
434 |
+
// Set the model_title attribute for the row
|
435 |
+
row.setAttribute('model_title', titleText);
|
436 |
+
}
|
437 |
+
});
|
438 |
+
} else {
|
439 |
+
rows.forEach(row => {
|
440 |
+
// Find the first cell in the row that contains a link
|
441 |
+
const firstCellLink = row.querySelector('td a');
|
442 |
+
|
443 |
+
if (firstCellLink) {
|
444 |
+
// Get the value of the title attribute from the first link
|
445 |
+
const titleText = firstCellLink.getAttribute('title');
|
446 |
|
447 |
+
// Remove the model_title attribute for the row
|
448 |
+
row.removeAttribute('model_title');
|
449 |
}
|
450 |
});
|
451 |
}
|
452 |
});
|
453 |
}
|
454 |
|
455 |
+
const intervalId = setInterval(addTitleForEachRowOfLeaderboardTable, 1000);
|
456 |
|
457 |
</script>
|
458 |
"""
|