Skip to content

Commit

Permalink
index.js: change order of images
Browse files Browse the repository at this point in the history
Put the sysupgrade images first, factory images second.
The idea is to make the most often required images to the top.

Signed-off-by: Moritz Warning <moritzwarning@web.de>
  • Loading branch information
mwarning committed Jan 16, 2025
1 parent 4bb5eec commit a394078
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions www/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,16 @@ function formatDate(date) {
return date;
}

// apply preferred order to the download buttons (sysupgrade first)
function sortImages(images) {
const typePrecedence = ["sysupgrade", "factory"];
return images.sort((a, b) => {
let ap = typePrecedence.indexOf(a.type);
let bp = typePrecedence.indexOf(b.type);
return ap == -1 ? 1 : bp == -1 ? -1 : ap - bp;
});
}

function updateImages(mobj) {
// remove download table
$$("#download-table1 *").forEach((e) => e.remove());
Expand Down Expand Up @@ -616,7 +626,7 @@ function updateImages(mobj) {
const extras2 = $("#download-extras2");

// for desktop view
for (const image of mobj.images) {
for (const image of sortImages(mobj.images)) {
const link = createLink(mobj, image, mobj.image_folder);
const extra = createExtra(image);

Expand All @@ -626,7 +636,7 @@ function updateImages(mobj) {
}

// for mobile view
for (const image of mobj.images) {
for (const image of sortImages(mobj.images)) {
const link = createLink(mobj, image, mobj.image_folder);
const extra = createExtra(image);

Expand Down

0 comments on commit a394078

Please sign in to comment.