Added some basic table sorting
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -1,7 +1,34 @@
|
|||||||
$ ->
|
$ ->
|
||||||
# run foundation scripts
|
# let us know when javascript is running.
|
||||||
console.log('Ready.')
|
console.log('Ready.')
|
||||||
|
|
||||||
|
lastColumn = null
|
||||||
|
ascending = true
|
||||||
|
|
||||||
|
tableHeaders = $('th')
|
||||||
|
tableHeaders.click (e) ->
|
||||||
|
column = $(this).index()
|
||||||
|
table = $(this).closest('table')
|
||||||
|
|
||||||
|
if column is lastColumn
|
||||||
|
ascending = not ascending
|
||||||
|
else
|
||||||
|
ascending = true
|
||||||
|
|
||||||
|
lastColumn = column
|
||||||
|
sortTable(table, column, ascending)
|
||||||
|
|
||||||
|
sortTable = (table, column, ascending) ->
|
||||||
|
rows = table.find('tbody tr').get()
|
||||||
|
|
||||||
|
compareFunction = (a, b) ->
|
||||||
|
res = a.cells[column].textContent.localeCompare b.cells[column].textContent
|
||||||
|
if ascending then res else -res
|
||||||
|
|
||||||
|
rows.sort compareFunction
|
||||||
|
$(rows).detach().appendTo(table.find('tbody'))
|
||||||
|
return
|
||||||
|
|
||||||
averageResults = (results, decimals = 2) ->
|
averageResults = (results, decimals = 2) ->
|
||||||
avgScore = 0
|
avgScore = 0
|
||||||
minScore = Infinity
|
minScore = Infinity
|
||||||
|
@@ -8,9 +8,9 @@
|
|||||||
<table class="table table-hover table-responsive">
|
<table class="table table-hover table-responsive">
|
||||||
<thead class="table-light">
|
<thead class="table-light">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Test name</th>
|
<th data-sort="name">Test name</th>
|
||||||
<th># Benchmarks</th>
|
<th data-sort="benchmark-count"># Benchmarks</th>
|
||||||
<th>Last Updated</th>
|
<th data-sort="updated'">Last Updated</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
Reference in New Issue
Block a user