Skip to content

Commit

Permalink
Add position column to leaderboard.
Browse files Browse the repository at this point in the history
  • Loading branch information
amato-gianluca committed Dec 24, 2019
1 parent d428029 commit a69e22c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions views/leaderboard.pug
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,30 @@ html(lang="en")
link(href="/static/tablesort/tablesort.css" rel="stylesheet")
body
h1 Leaderboard

table(id="sort" border="1")
thead
tr
th(data-sort-method='none') Position
th Computer
th Selfplay games
th Match games
th(data-sort-default) Total games
tbody
each item, key in data
tr
td #{pos}
td #{key}
td #{item.games}
td #{item.match_games}
td #{item.total_games}

script.
new Tablesort(document.getElementById('sort'), { descending: true });
script.
const table = document.getElementById('sort');
table.addEventListener('afterSort', function() {
const body = table.tBodies[0];
for(var i=0; i < body.rows.length; i++) {
const cell = body.rows[i].cells[0];
cell.innerHTML=i+1;
}
});
new Tablesort(table, { descending: true });

0 comments on commit a69e22c

Please sign in to comment.