www/index.js: deterministic version order and introduce default_version
authorMoritz Warning <moritzwarning@web.de>
Thu, 17 Sep 2020 22:03:59 +0000 (00:03 +0200)
committerMoritz Warning <moritzwarning@web.de>
Mon, 21 Sep 2020 14:02:48 +0000 (16:02 +0200)
Allow to set a preselected version and sort version, e.g.:
1. SNAPSHOT
2. 19.07.02
3. 19.07.01

www/config.js
www/index.js

index 32740e0d38d4ab6c0aad851414ce6da830399373..1a09712665af464620da3f42eb4aa1518343b0d8 100644 (file)
@@ -11,6 +11,8 @@ var config = {
     "19.07.1": "../misc/19.07.1/overview.json",
     "18.06.7": "../misc/18.06.7/overview.json",
   },
+  // Pre-selected version
+  //default_version: "19.07.1",
   // Build custom images
   // See https://github.com/aparcar/asu
   //asu_url: 'https://chef.libremesh.org'
index b057cd219ba5c1b037c4458ee647e82c85d3e1ac..f5edb4b65717d079b633ad1da4a7a387ed3d1248 100644 (file)
@@ -124,12 +124,18 @@ function build_asu_request() {
 }
 
 function setupSelectList(select, items, onselection) {
-  for (const item of items) {
+  for (const item of items.sort().reverse()) {
     const option = document.createElement("OPTION");
     option.innerHTML = item;
     select.appendChild(option);
   }
 
+  // pre-select version from config.json
+  const preselect = config.default_version;
+  if (preselect) {
+    $("#versions").value = preselect;
+  }
+
   select.addEventListener("change", () => {
     onselection(items[select.selectedIndex]);
   });