idolezal commited on
Commit
9cba749
ยท
1 Parent(s): 578e86d

With JS set the title attribute from the first cell link to all cells in the row

Browse files
Files changed (1) hide show
  1. app.py +34 -1
app.py CHANGED
@@ -399,8 +399,41 @@ tr.row_odd {
399
 
400
  """
401
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
402
  def gradio_app():
403
- with gr.Blocks(theme=gr.themes.Soft(text_size=text_md), css=custom_css) as main:
404
  gr.Markdown(HEADER_MARKDOWN)
405
 
406
  if leaderboard_server.tournament_results_corrupted:
 
399
 
400
  """
401
 
402
+ custom_js = """
403
+ <script>
404
+
405
+ function addTitleForEachCellOfLeaderboardTable(){
406
+ const rows = document.querySelectorAll('.leaderboard-table tr, .leaderboard-table-model-details tr');
407
+
408
+ rows.forEach(row => {
409
+ // Find the first cell in the row that contains a link
410
+ const firstCellLink = row.querySelector('td a');
411
+
412
+ if (firstCellLink) {
413
+ // Get the value of the title attribute from the first link
414
+ const titleText = firstCellLink.getAttribute('title');
415
+
416
+ // Set the title attribute for all cells in the row
417
+ row.querySelectorAll('td').forEach((cell, index) => {
418
+ // If the cell already has a title attribute, break the loop
419
+ if (cell.hasAttribute('title')) {
420
+ return; // Exit the current iteration for this row
421
+ }
422
+
423
+ // Set the title attribute permanently
424
+ cell.setAttribute('title', titleText);
425
+ });
426
+ }
427
+ });
428
+ }
429
+
430
+ const intervalId = setInterval(addTitleForEachCellOfLeaderboardTable, 1000);
431
+
432
+ </script>
433
+ """
434
+
435
  def gradio_app():
436
+ with gr.Blocks(theme=gr.themes.Soft(text_size=text_md), css=custom_css, head=custom_js) as main:
437
  gr.Markdown(HEADER_MARKDOWN)
438
 
439
  if leaderboard_server.tournament_results_corrupted: