From da4efb6c60a06f33fbf9042a47ddc635209e9eb0 Mon Sep 17 00:00:00 2001 From: Hans5958 Date: Thu, 15 Jun 2023 22:57:35 +0700 Subject: [PATCH] Use index (position on Atlas data) for temporal order --- web/_js/main/main.js | 4 +++- web/_js/main/view.js | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/web/_js/main/main.js b/web/_js/main/main.js index 3174804f..4a60b860 100644 --- a/web/_js/main/main.js +++ b/web/_js/main/main.js @@ -500,7 +500,9 @@ async function init() { } function updateAtlasAll(atlas = atlasAll) { - for (const entry of atlas) { + for (const index in atlas) { + const entry = atlas[index] + entry._index = index const currentLinks = entry.links entry.links = { website: [], diff --git a/web/_js/main/view.js b/web/_js/main/view.js index 9b209a7b..b4f9e373 100644 --- a/web/_js/main/view.js +++ b/web/_js/main/view.js @@ -370,10 +370,10 @@ function buildObjectsList(filter, sort = defaultSort) { sortFunction = (a, b) => b.name.toLowerCase().localeCompare(a.name.toLowerCase()) break case "newest": - sortFunction = (a, b) => b.id.length - a.id.length || b.id.localeCompare(a.id) + sortFunction = (a, b) => b._index - a._index break case "oldest": - sortFunction = (a, b) => a.id.length - b.id.length || a.id.localeCompare(b.id) + sortFunction = (a, b) => a._index - b._index break case "area": sortFunction = (a, b) => calcPolygonArea(b.path) - calcPolygonArea(a.path)