From bc4761ac461fe69d57460c3f94d50bd30f389bd4 Mon Sep 17 00:00:00 2001 From: Kumi Date: Fri, 9 Aug 2024 15:03:44 +0200 Subject: [PATCH] feat: Add preferred currencies ordering support Enhanced the configuration and display logic to allow specifying preferred currencies, which are now ordered at the top of the list. This improves user experience by prioritizing commonly used currencies. This also eliminates duplicate entries for the currently selected currency in the drop-down. --- config.dist.php | 3 +++ index.php | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/config.dist.php b/config.dist.php index 1580ce2..25f72d8 100644 --- a/config.dist.php +++ b/config.dist.php @@ -5,5 +5,8 @@ return [ 'footer_links' => [ // Custom links to show in the footer ['text' => 'Clearnet', 'url' => 'https://calc.revuo-xmr.com'], ['text' => 'Tor', 'url' => 'http://calc.revuo75joezkbeitqmas4ab6spbrkr4vzbhjmeuv75ovrfqfp47mtjid.onion'] + ], + 'preferred_currencies' => [ // Currencies that should be displayed at the top of the lists + 'usd', 'eur', 'gbp', 'cad', 'btc', 'eth', 'ltc' ] ]; \ No newline at end of file diff --git a/index.php b/index.php index db8c146..2b8794a 100644 --- a/index.php +++ b/index.php @@ -54,6 +54,16 @@ if (file_exists('config.php')) { $display_servers_guru = isset($config['servers_guru']) && $config['servers_guru'] === true; $attribution = isset($config['attribution']) ? $config['attribution'] : ''; +$preferred_currencies = isset($config['preferred_currencies']) ? $config['preferred_currencies'] : []; + +// Order preferred currencies to the top +foreach (array_reverse($preferred_currencies) as $currency) { + $currency = strtoupper($currency); + if (($key = array_search($currency, $currencies)) !== false) { + unset($currencies[$key]); + array_unshift($currencies, $currency); + } +} ?> @@ -148,12 +158,10 @@ $attribution = isset($config['attribution']) ? $config['attribution'] : '';