From fc540db4cd7116d7a715869bdedbbf4d19b0a061 Mon Sep 17 00:00:00 2001 From: louis-e <44675238+louis-e@users.noreply.github.com> Date: Sun, 11 Jan 2026 00:48:32 +0100 Subject: [PATCH] Unify displayBboxSizeStatus function --- src/gui/js/main.js | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/gui/js/main.js b/src/gui/js/main.js index 13c1dac..c3097b3 100644 --- a/src/gui/js/main.js +++ b/src/gui/js/main.js @@ -531,16 +531,7 @@ function handleBboxInput() { // Restore map selection info display but don't update input field const [lng1, lat1, lng2, lat2] = mapSelectedBBox.split(" ").map(Number); const selectedSize = calculateBBoxSize(lng1, lat1, lng2, lat2); - if (selectedSize > threshold2) { - localizeElement(window.localization, { element: bboxInfo }, "area_too_large"); - bboxInfo.style.color = "#fa7878"; - } else if (selectedSize > threshold1) { - localizeElement(window.localization, { element: bboxInfo }, "area_extensive"); - bboxInfo.style.color = "#fecc44"; - } else { - localizeElement(window.localization, { element: bboxInfo }, "selection_confirmed"); - bboxInfo.style.color = "#7bd864"; - } + displayBboxSizeStatus(bboxInfo, selectedSize); } return; } @@ -649,6 +640,24 @@ let selectedBBox = ""; let mapSelectedBBox = ""; // Tracks bbox from map selection let customBBoxValid = false; // Tracks if custom input is valid +/** + * Displays the appropriate bbox size status message based on area thresholds + * @param {HTMLElement} bboxInfo - The element to display the message in + * @param {number} selectedSize - The calculated bbox area in square meters + */ +function displayBboxSizeStatus(bboxInfo, selectedSize) { + if (selectedSize > threshold2) { + localizeElement(window.localization, { element: bboxInfo }, "area_too_large"); + bboxInfo.style.color = "#fa7878"; + } else if (selectedSize > threshold1) { + localizeElement(window.localization, { element: bboxInfo }, "area_extensive"); + bboxInfo.style.color = "#fecc44"; + } else { + localizeElement(window.localization, { element: bboxInfo }, "selection_confirmed"); + bboxInfo.style.color = "#7bd864"; + } +} + // Function to handle incoming bbox data function displayBboxInfoText(bboxText) { let [lng1, lat1, lng2, lat2] = bboxText.split(" ").map(Number); @@ -682,16 +691,7 @@ function displayBboxInfoText(bboxText) { // Calculate the size of the selected bbox const selectedSize = calculateBBoxSize(lng1, lat1, lng2, lat2); - if (selectedSize > threshold2) { - localizeElement(window.localization, { element: bboxInfo }, "area_too_large"); - bboxInfo.style.color = "#fa7878"; - } else if (selectedSize > threshold1) { - localizeElement(window.localization, { element: bboxInfo }, "area_extensive"); - bboxInfo.style.color = "#fecc44"; - } else { - localizeElement(window.localization, { element: bboxInfo }, "selection_confirmed"); - bboxInfo.style.color = "#7bd864"; - } + displayBboxSizeStatus(bboxInfo, selectedSize); } let worldPath = "";