Spaces:
Running
Running
Leaderboard: show the top 20 first, with a Show all button (and Show top 20 to fold it back)
2ad2653 verified Download assets/leaderboard-controls.js from SimWorld-AI/Code4Scene: direct link, hf CLI and curl.
- Browser
- Download file 2.07 kB
-
https://huggingface.co/spaces/SimWorld-AI/Code4Scene/resolve/main/assets/leaderboard-controls.js
- Command line
-
hf download hf://spaces/SimWorld-AI/Code4Scene/assets/leaderboard-controls.js
-
curl -L -o leaderboard-controls.js https://huggingface.co/spaces/SimWorld-AI/Code4Scene/resolve/main/assets/leaderboard-controls.js
2.07 kB
| const input=document.getElementById('model-search'),tables=[...document.querySelectorAll('table.board')],count=document.getElementById('ranking-count'); | |
| // the two tabs rank different line-ups (Text-to-Scene re-run vs the paper's Image-to-Scene), so count the visible one | |
| const visible=()=>tables.find(t=>t.offsetParent!==null)||tables[0]; | |
| // each table shows its top 20 rows at first; "Show all" opens the rest, "Show top 20" folds it back. | |
| // While searching, every match is shown. | |
| const PAGE=20,open_=new Map(tables.map(t=>[t,false])),more=new Map(); | |
| for(const table of tables){ | |
| const bar=document.createElement('div'),all=document.createElement('button'),top=document.createElement('button'); | |
| bar.className='board-more';all.type=top.type='button';top.textContent='Show top '+PAGE; | |
| all.addEventListener('click',()=>{open_.set(table,true);filter();}); | |
| top.addEventListener('click',()=>{open_.set(table,false);filter();(table.closest('.board-wrap')||table).scrollIntoView({block:'nearest'});}); | |
| bar.append(all,top);(table.closest('.board-wrap')||table).after(bar);more.set(table,{bar,all,top}); | |
| } | |
| function filter(){const q=input.value.trim().toLowerCase(); | |
| for(const table of tables){let rank=0;const lim=(q||open_.get(table))?Infinity:PAGE; | |
| for(const row of table.tBodies[0].rows){const hit=row.dataset.search.includes(q);if(hit)row.cells[0].textContent=++rank;row.hidden=!hit||rank>lim;} | |
| const {bar,all,top}=more.get(table); | |
| all.hidden=!!q||open_.get(table)||rank<=PAGE;all.textContent='Show all '+rank; | |
| top.hidden=!!q||!open_.get(table)||rank<=PAGE;bar.hidden=all.hidden&&top.hidden;} | |
| const rows=[...visible().tBodies[0].rows],shown=rows.filter(r=>!r.hidden).length;count.textContent=q?shown+' of '+rows.length+' configurations':rows.length+' configurations';} | |
| input.addEventListener('input',filter);tables.forEach(t=>t.querySelectorAll('th[data-k]').forEach(th=>th.addEventListener('click',()=>setTimeout(filter)))); | |
| document.querySelectorAll('.seg[data-for=leaderboard] button').forEach(b=>b.addEventListener('click',()=>setTimeout(filter))); | |
| filter(); | |