From 55072a51025aa24c7278141db9059def81786dad Mon Sep 17 00:00:00 2001 From: Graham Date: Sat, 29 Oct 2022 21:34:13 +0100 Subject: [PATCH] Sort build column numerically Signed-off-by: Graham --- .../org/openrs2/archive/static/js/openrs2.js | 21 +++++++++++++++++++ .../archive/templates/caches/index.html | 2 +- .../org/openrs2/archive/templates/layout.html | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 archive/src/main/resources/org/openrs2/archive/static/js/openrs2.js 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 new file mode 100644 index 00000000..228234b7 --- /dev/null +++ b/archive/src/main/resources/org/openrs2/archive/static/js/openrs2.js @@ -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; +} 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 188a8126..94f6d69e 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 @@ -18,7 +18,7 @@ Game Env Lang - Build(s) + Build(s) Timestamp Source(s) Archives diff --git a/archive/src/main/resources/org/openrs2/archive/templates/layout.html b/archive/src/main/resources/org/openrs2/archive/templates/layout.html index f0a5576e..57f78ad7 100644 --- a/archive/src/main/resources/org/openrs2/archive/templates/layout.html +++ b/archive/src/main/resources/org/openrs2/archive/templates/layout.html @@ -13,6 +13,7 @@ +