diff --git a/assets/scripts/edgeville.coffee b/assets/scripts/edgeville.coffee index 2887d5b..83fa963 100644 --- a/assets/scripts/edgeville.coffee +++ b/assets/scripts/edgeville.coffee @@ -1,7 +1,34 @@ $ -> - # run foundation scripts + # let us know when javascript is running. 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) -> avgScore = 0 minScore = Infinity diff --git a/views/index/index.erb b/views/index/index.erb index 4309ad3..080fae2 100644 --- a/views/index/index.erb +++ b/views/index/index.erb @@ -8,9 +8,9 @@
Test name | -# Benchmarks | -Last Updated | +Test name | +# Benchmarks | +Last Updated |
---|