diff options
Diffstat (limited to 'asset-sources')
| -rw-r--r-- | asset-sources/fietsboek.ts | 20 | 
1 files changed, 20 insertions, 0 deletions
diff --git a/asset-sources/fietsboek.ts b/asset-sources/fietsboek.ts index aed2852..1cadfc2 100644 --- a/asset-sources/fietsboek.ts +++ b/asset-sources/fietsboek.ts @@ -369,6 +369,26 @@ function clearInputButtonClicked(event: MouseEvent) {  addHandler(".button-clear-input", "click", clearInputButtonClicked); +/** + * Handler to change the sorting of the home page. + * + * This basically sets the cookie to signal that the home page should be + * returned reversed, and then reloads the page. + * + * @param event - The triggering event. + */ +function changeHomeSorting(_event: MouseEvent) { +    const currentSorting = document.cookie.split("; ") +        .find((row) => row.startsWith("home_sorting=")) +        ?.split("=")[1] ?? "asc"; +    const newSorting = currentSorting == "asc" ? "desc" : "asc"; +    document.cookie = `home_sorting=${newSorting}; SameSite=Lax`; +    window.location.reload(); +} + +addHandler("#changeHomeSorting", "click", changeHomeSorting); + +  document.addEventListener('DOMContentLoaded', function() {      window.fietsboekImageIndex = 0;  | 
