Sort build column numerically

Signed-off-by: Graham <gpe@openrs2.org>
master
Graham 2 years ago
parent 97ca5cbc2f
commit 55072a5102
  1. 21
      archive/src/main/resources/org/openrs2/archive/static/js/openrs2.js
  2. 2
      archive/src/main/resources/org/openrs2/archive/templates/caches/index.html
  3. 1
      archive/src/main/resources/org/openrs2/archive/templates/layout.html

@ -0,0 +1,21 @@
var buildRegex = new RegExp('>([0-9]+)(?:[.]([0-9]+))?<');
function buildSort(a, b) {
a = buildRegex.exec(a);
b = buildRegex.exec(b);
if (!a) {
return -1;
} else if (!b) {
return 1;
}
var aMajor = parseInt(a[1]);
var bMajor = parseInt(b[1]);
if (aMajor !== bMajor) {
return aMajor - bMajor;
}
var aMinor = a[2] ? parseInt(a[2]) : 0;
var bMinor = b[2] ? parseInt(b[2]) : 0;
return aMinor - bMinor;
}

@ -18,7 +18,7 @@
<th data-field="game" data-filter-control="select">Game</th> <th data-field="game" data-filter-control="select">Game</th>
<th data-field="environment" data-filter-control="select">Env</th> <th data-field="environment" data-filter-control="select">Env</th>
<th data-field="language" data-filter-control="select">Lang</th> <th data-field="language" data-filter-control="select">Lang</th>
<th data-field="builds" data-filter-control="input" data-sortable="true">Build(s)</th> <th data-field="builds" data-filter-control="input" data-sortable="true" data-sorter="buildSort">Build(s)</th>
<th data-field="timestamp" data-sortable="true">Timestamp</th> <th data-field="timestamp" data-sortable="true">Timestamp</th>
<th data-field="sources" data-filter-control="input">Source(s)</th> <th data-field="sources" data-filter-control="input">Source(s)</th>
<th>Archives</th> <th>Archives</th>

@ -13,6 +13,7 @@
<script src="/webjars/bootstrap-table/dist/bootstrap-table.min.js" defer></script> <script src="/webjars/bootstrap-table/dist/bootstrap-table.min.js" defer></script>
<script src="/webjars/bootstrap-table/dist/extensions/filter-control/bootstrap-table-filter-control.min.js" defer></script> <script src="/webjars/bootstrap-table/dist/extensions/filter-control/bootstrap-table-filter-control.min.js" defer></script>
<script src="/webjars/bootstrap-table/dist/extensions/sticky-header/bootstrap-table-sticky-header.min.js" defer></script> <script src="/webjars/bootstrap-table/dist/extensions/sticky-header/bootstrap-table-sticky-header.min.js" defer></script>
<script src="/static/js/openrs2.js" defer></script>
</head> </head>
<body> <body>
<nav class="navbar navbar-dark navbar-expand bg-dark mb-4" th:fragment="nav"> <nav class="navbar navbar-dark navbar-expand bg-dark mb-4" th:fragment="nav">

Loading…
Cancel
Save