From 62df015ad5dbad3d7161494ca79c0fe841d8e5ed Mon Sep 17 00:00:00 2001 From: Graham Date: Sat, 29 Oct 2022 22:18:42 +0100 Subject: [PATCH] Always sort empty rows to the bottom of the table Signed-off-by: Graham --- .../org/openrs2/archive/static/js/openrs2.js | 32 ++++++++++++++++--- .../archive/templates/caches/index.html | 12 ++++--- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/archive/src/main/resources/org/openrs2/archive/static/js/openrs2.js b/archive/src/main/resources/org/openrs2/archive/static/js/openrs2.js index 228234b76c..99a5fe19c8 100644 --- a/archive/src/main/resources/org/openrs2/archive/static/js/openrs2.js +++ b/archive/src/main/resources/org/openrs2/archive/static/js/openrs2.js @@ -1,13 +1,35 @@ var buildRegex = new RegExp('>([0-9]+)(?:[.]([0-9]+))?<'); +function customSort(name, order, data) { + order = order === 'asc' ? 1 : -1; + + data.sort(function (a, b) { + a = a[name]; + b = b[name]; + + if (!a) { + return 1; + } else if (!b) { + return -1; + } + + if (name === 'builds') { + return buildSort(a, b) * order; + } else { + if (a < b) { + return -order; + } else if (a === b) { + return 0; + } else { + return order; + } + } + }); +} + 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]); diff --git a/archive/src/main/resources/org/openrs2/archive/templates/caches/index.html b/archive/src/main/resources/org/openrs2/archive/templates/caches/index.html index 94f6d69e04..6727aeca16 100644 --- a/archive/src/main/resources/org/openrs2/archive/templates/caches/index.html +++ b/archive/src/main/resources/org/openrs2/archive/templates/caches/index.html @@ -12,13 +12,13 @@

Caches

- +
- + @@ -41,9 +41,11 @@
Game Env LangBuild(s)Build(s) Timestamp Source(s) Archives - -
- + + +
+ +