{"id":1129,"date":"2025-05-30T08:57:51","date_gmt":"2025-05-30T08:57:51","guid":{"rendered":"https:\/\/oneroyal.academy\/?page_id=1129"},"modified":"2025-12-15T13:40:55","modified_gmt":"2025-12-15T13:40:55","slug":"currency-converter","status":"publish","type":"page","link":"https:\/\/oneroyal.academy\/ms\/calculators\/currency-converter\/","title":{"rendered":"Penukar Mata Wang"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-page\" data-elementor-id=\"1129\" class=\"elementor elementor-1129\" data-elementor-post-type=\"page\">\n\t\t\t\t<div class=\"elementor-element elementor-element-45afc9e e-con-full hero-section-wrapper e-flex e-con e-parent\" data-id=\"45afc9e\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t<div class=\"elementor-element elementor-element-3233333 elementor-widget elementor-widget-template\" data-id=\"3233333\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"template.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-template\">\n\t\t\t\t\t<div data-elementor-type=\"section\" data-elementor-id=\"75\" class=\"elementor elementor-75\" data-elementor-post-type=\"elementor_library\">\n\t\t\t<div class=\"elementor-element elementor-element-7ab5fd80 hero-section e-flex e-con-boxed e-con e-parent\" data-id=\"7ab5fd80\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t<div class=\"elementor-element elementor-element-515a88e e-con-full left e-flex e-con e-child\" data-id=\"515a88e\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t<div class=\"elementor-element elementor-element-1e73acea hero-heading elementor-widget elementor-widget-heading\" data-id=\"1e73acea\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h1 class=\"elementor-heading-title elementor-size-default\">OneRoyal\u2019s Currency Converter\u00a0<\/h1>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-f81ef53 hero-description elementor-widget elementor-widget-heading\" data-id=\"f81ef53\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<p class=\"elementor-heading-title elementor-size-default\">You understand values best in your base currency. That\u2019s why our online Currency Converter is among the most popular forex trading tools.\r\nConvert forex pairs instantly and accurately, based on real-time exchange rates. Simplify your trading with this currency calculator.<\/p>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-f2b1eac e-con-full ctas e-flex e-con e-child\" data-id=\"f2b1eac\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-591de12a e-con-full right e-flex e-con e-child\" data-id=\"591de12a\" data-element_type=\"container\" data-e-type=\"container\" data-settings=\"{&quot;background_background&quot;:&quot;classic&quot;}\">\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-cfc1330 e-flex e-con-boxed e-con e-parent\" data-id=\"cfc1330\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-92946e1 calculators-title elementor-widget elementor-widget-heading\" data-id=\"92946e1\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Currency Converter<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-7be7418 calculators-subtitle elementor-widget elementor-widget-heading\" data-id=\"7be7418\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<p class=\"elementor-heading-title elementor-size-default\">Convert forex pairs instantly based on the latest exchange rate\u00a0<\/p>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-493ecac e-con-full e-flex e-con e-child\" data-id=\"493ecac\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t<div class=\"elementor-element elementor-element-e16ca58 e-con-full e-flex e-con e-child\" data-id=\"e16ca58\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t<div class=\"elementor-element elementor-element-250d7f9 elementor-widget elementor-widget-html\" data-id=\"250d7f9\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\n<div class=\"currency-converter\">\n    <div class=\"currency-converter-columns\">\n        <div class=\"currency-converter-column\">\n            <label>Amount<\/label>\n            <div class=\"calc-row\">\n                <div class=\"calc-field\">\n                    <input type=\"number\" id=\"amount\" value=\"10000\" min=\"0\" step=\"0.01\">\n                <\/div>\n                <div class=\"calc-field\">\n                    <select id=\"fromCurrency\">\n                        <option value=\"AUD\">AUD<\/option>\n                        <option value=\"CAD\">CAD<\/option>\n                        <option value=\"CHF\">CHF<\/option>\n                        <option value=\"DKK\">DKK<\/option>\n                        <option value=\"EUR\" selected>EUR<\/option>\n                        <option value=\"GBP\">GBP<\/option>\n                        <option value=\"HKD\">HKD<\/option>\n                        <option value=\"HUF\">HUF<\/option>\n                        <option value=\"JPY\">JPY<\/option>\n                        <option value=\"MXN\">MXN<\/option>\n                        <option value=\"NOK\">NOK<\/option>\n                        <option value=\"NZD\">NZD<\/option>\n                        <option value=\"PLN\">PLN<\/option>\n                        <option value=\"RUB\">RUB<\/option>\n                        <option value=\"SEK\">SEK<\/option>\n                        <option value=\"SGD\">SGD<\/option>\n                        <option value=\"TRY\">TRY<\/option>\n                        <option value=\"USD\">USD<\/option>\n                        <option value=\"ZAR\">ZAR<\/option>\n                    <\/select>\n                <\/div>\n            <\/div>\n            <p class=\"instructions\">\n                Enter the amount you wish to convert and select the currency in which the amount was originally stated.\n            <\/p>\n        <\/div>\n        <div class=\"currency-converter-column\">\n            <label>Currency<\/label>\n            <div class=\"calc-row\">\n                <div class=\"calc-field full-width\">\n                    <select id=\"toCurrency\">\n                        <option value=\"AUD\">AUD<\/option>\n                        <option value=\"CAD\">CAD<\/option>\n                        <option value=\"CHF\">CHF<\/option>\n                        <option value=\"DKK\">DKK<\/option>\n                        <option value=\"EUR\">EUR<\/option>\n                        <option value=\"GBP\">GBP<\/option>\n                        <option value=\"HKD\">HKD<\/option>\n                        <option value=\"HUF\">HUF<\/option>\n                        <option value=\"JPY\">JPY<\/option>\n                        <option value=\"MXN\">MXN<\/option>\n                        <option value=\"NOK\">NOK<\/option>\n                        <option value=\"NZD\">NZD<\/option>\n                        <option value=\"PLN\">PLN<\/option>\n                        <option value=\"RUB\">RUB<\/option>\n                        <option value=\"SEK\">SEK<\/option>\n                        <option value=\"SGD\">SGD<\/option>\n                        <option value=\"TRY\">TRY<\/option>\n                        <option value=\"USD\" selected>USD<\/option>\n                        <option value=\"ZAR\">ZAR<\/option>\n                    <\/select>\n                <\/div>\n            <\/div>\n            <p class=\"instructions\">\n                Select the currency in which you wish to convert the amount.\n            <\/p>\n        <\/div>  \n    <\/div>\n    <div class=\"calc-field result\">\n        <div class=\"result-box\">\n            <div class=\"result-label\">Convertion Value:<\/div>\n            <div class=\"result-value\" id=\"result\">0.00<\/div>\n        <\/div>\n    <\/div>\n    <div class=\"error-message\" id=\"errorMessage\"><\/div>\n<\/div>\n\n<script>\n    \/\/ Currency pair configurations\n    const CURRENCY_PAIRS = [\n        { n: \"AUDCAD\", d: 5, p: 0.0001 },\n        { n: \"AUDCHF\", d: 5, p: 0.0001 },\n        { n: \"AUDJPY\", d: 3, p: 0.01 },\n        { n: \"AUDNZD\", d: 5, p: 0.0001 },\n        { n: \"AUDSGD\", d: 5, p: 0.0001 },\n        { n: \"AUDUSD\", d: 5, p: 0.0001 },\n        { n: \"CADCHF\", d: 5, p: 0.0001 },\n        { n: \"CADJPY\", d: 3, p: 0.01 },\n        { n: \"CHFJPY\", d: 3, p: 0.01 },\n        { n: \"CHFSGD\", d: 5, p: 0.0001 },\n        { n: \"EURAUD\", d: 5, p: 0.0001 },\n        { n: \"EURCAD\", d: 5, p: 0.0001 },\n        { n: \"EURCHF\", d: 5, p: 0.0001 },\n        { n: \"EURDKK\", d: 5, p: 0.0001 },\n        { n: \"EURGBP\", d: 5, p: 0.0001 },\n        { n: \"EURHKD\", d: 5, p: 0.0001 },\n        { n: \"EURJPY\", d: 3, p: 0.01 },\n        { n: \"EURNOK\", d: 5, p: 0.0001 },\n        { n: \"EURNZD\", d: 5, p: 0.0001 },\n        { n: \"EURPLN\", d: 5, p: 0.0001 },\n        { n: \"EURSEK\", d: 5, p: 0.0001 },\n        { n: \"EURSGD\", d: 5, p: 0.0001 },\n        { n: \"EURTRY\", d: 5, p: 0.0001 },\n        { n: \"EURUSD\", d: 5, p: 0.0001 },\n        { n: \"EURZAR\", d: 5, p: 0.0001 },\n        { n: \"GBPAUD\", d: 5, p: 0.0001 },\n        { n: \"GBPCAD\", d: 5, p: 0.0001 },\n        { n: \"GBPCHF\", d: 5, p: 0.0001 },\n        { n: \"GBPDKK\", d: 5, p: 0.0001 },\n        { n: \"GBPJPY\", d: 3, p: 0.01 },\n        { n: \"GBPNOK\", d: 5, p: 0.0001 },\n        { n: \"GBPNZD\", d: 5, p: 0.0001 },\n        { n: \"GBPSEK\", d: 5, p: 0.0001 },\n        { n: \"GBPSGD\", d: 5, p: 0.0001 },\n        { n: \"GBPUSD\", d: 5, p: 0.0001 },\n        { n: \"NOKJPY\", d: 3, p: 0.01 },\n        { n: \"NOKSEK\", d: 5, p: 0.0001 },\n        { n: \"NZDCAD\", d: 5, p: 0.0001 },\n        { n: \"NZDCHF\", d: 5, p: 0.0001 },\n        { n: \"NZDJPY\", d: 3, p: 0.01 },\n        { n: \"NZDUSD\", d: 5, p: 0.0001 },\n        { n: \"SEKJPY\", d: 3, p: 0.01 },\n        { n: \"SGDJPY\", d: 3, p: 0.01 },\n        { n: \"USDCAD\", d: 5, p: 0.0001 },\n        { n: \"USDCHF\", d: 5, p: 0.0001 },\n        { n: \"USDCNH\", d: 5, p: 0.0001 },\n        { n: \"USDCZK\", d: 4, p: 0.001 },\n        { n: \"USDDKK\", d: 5, p: 0.0001 },\n        { n: \"USDHKD\", d: 5, p: 0.0001 },\n        { n: \"USDHUF\", d: 3, p: 0.01 },\n        { n: \"USDJPY\", d: 3, p: 0.01 },\n        { n: \"USDMXN\", d: 5, p: 0.0001 },\n        { n: \"USDNOK\", d: 5, p: 0.0001 },\n        { n: \"USDPLN\", d: 5, p: 0.0001 },\n        { n: \"USDSEK\", d: 5, p: 0.0001 },\n        { n: \"USDSGD\", d: 5, p: 0.0001 },\n        { n: \"USDTHB\", d: 5, p: 0.0001 },\n        { n: \"USDTRY\", d: 5, p: 0.0001 },\n        { n: \"USDZAR\", d: 5, p: 0.0001 }\n    ];\n\n    \/\/ API Configuration\n    const API_ENDPOINT = 'https:\/\/api.OneRoyal.io';\n\n    let converterData = null;\n    let isLoading = false;\n\n    const amountInput = document.getElementById('amount');\n    const fromSelect = document.getElementById('fromCurrency');\n    const toSelect = document.getElementById('toCurrency');\n    const resultDiv = document.getElementById('result');\n    const errorMessage = document.getElementById('errorMessage');\n    const container = document.querySelector('.currency-converter');\n\n    function showError(message) {\n        errorMessage.textContent = message;\n        errorMessage.style.display = 'block';\n        setTimeout(() => {\n            errorMessage.style.display = 'none';\n        }, 5000);\n    }\n\n    function hideError() {\n        errorMessage.style.display = 'none';\n    }\n\n    function setLoading(loading) {\n        isLoading = loading;\n        if (loading) {\n            container.classList.add('loading');\n            resultDiv.textContent = 'Loading...';\n        } else {\n            container.classList.remove('loading');\n        }\n    }\n\n    async function fetchData(url) {\n        try {\n            const response = await fetch(url);\n            if (!response.ok) {\n                throw new Error(`HTTP error! status: ${response.status}`);\n            }\n            const data = await response.json();\n            return data;\n        } catch (error) {\n            console.error('Error fetching data:', error);\n            throw error;\n        }\n    }\n\n    async function getConverterData() {\n        if (isLoading) return;\n        \n        setLoading(true);\n        hideError();\n        \n        try {\n            const url = `${API_ENDPOINT}\/api\/calculator\/converter?from=${fromSelect.value}&to=${toSelect.value}&amount=${amountInput.value}`;\n            const res = await fetchData(url);\n            \n            if (!res?.result) {\n                throw new Error('Invalid response from server');\n            }\n            \n            converterData = res.result;\n            updateConverter();\n        } catch (error) {\n            showError('Failed to fetch exchange rates. Using demo data.');\n            updateConverterDemo();\n        } finally {\n            setLoading(false);\n        }\n    }\n\n    function updateConverter() {\n        if (!converterData) return getConverterData();\n        \n        const amount = parseFloat(amountInput.value) || 0;\n        const from = fromSelect.value;\n        const to = toSelect.value;\n        const price = converterData.rates[to] || 1;\n        \n        let currencyPair = CURRENCY_PAIRS.find(c => c.n === from + to);\n        if (!currencyPair) currencyPair = CURRENCY_PAIRS.find(c => c.n === to + from);\n        if (!currencyPair) currencyPair = CURRENCY_PAIRS.find(c => c.n === from + 'USD');\n        if (!currencyPair) currencyPair = CURRENCY_PAIRS.find(c => c.n === 'USD' + from);\n        if (!currencyPair) currencyPair = CURRENCY_PAIRS.find(c => c.n === to + 'USD');\n        if (!currencyPair) currencyPair = CURRENCY_PAIRS.find(c => c.n === 'USD' + to);\n        if (!currencyPair) currencyPair = { d: 5, p: 0.0001 };\n        \n        const value = (amount * price).toFixed(2);\n        resultDiv.textContent = value;\n    }\n\n    \/\/ Demo function for fallback\n    function updateConverterDemo() {\n        const amount = parseFloat(amountInput.value) || 0;\n        const from = fromSelect.value;\n        const to = toSelect.value;\n        \n        \/\/ Demo exchange rates\n        const demoRates = {\n            'EUR': { 'USD': 1.08, 'GBP': 0.85, 'JPY': 160, 'AUD': 1.62, 'CAD': 1.47 },\n            'USD': { 'EUR': 0.93, 'GBP': 0.79, 'JPY': 148, 'AUD': 1.50, 'CAD': 1.36 },\n            'GBP': { 'EUR': 1.18, 'USD': 1.27, 'JPY': 188, 'AUD': 1.91, 'CAD': 1.73 },\n            'JPY': { 'EUR': 0.0063, 'USD': 0.0068, 'GBP': 0.0053, 'AUD': 0.010, 'CAD': 0.0092 },\n            'AUD': { 'EUR': 0.62, 'USD': 0.67, 'GBP': 0.52, 'JPY': 99, 'CAD': 0.91 },\n            'CAD': { 'EUR': 0.68, 'USD': 0.74, 'GBP': 0.58, 'JPY': 109, 'AUD': 1.10 }\n        };\n        \n        let rate = 1;\n        if (from !== to) {\n            if (demoRates[from] && demoRates[from][to]) {\n                rate = demoRates[from][to];\n            } else if (demoRates[to] && demoRates[to][from]) {\n                rate = 1 \/ demoRates[to][from];\n            } else {\n                \/\/ Fallback to USD conversion\n                const fromToUsd = demoRates[from] && demoRates[from]['USD'] ? demoRates[from]['USD'] : 1;\n                const usdToTo = demoRates['USD'] && demoRates['USD'][to] ? demoRates['USD'][to] : 1;\n                rate = fromToUsd * usdToTo;\n            }\n        }\n        \n        const value = (amount * rate).toFixed(2);\n        resultDiv.textContent = value;\n    }\n\n    \/\/ Debounce function to limit API calls\n    function debounce(func, wait) {\n        let timeout;\n        return function executedFunction(...args) {\n            const later = () => {\n                clearTimeout(timeout);\n                func(...args);\n            };\n            clearTimeout(timeout);\n            timeout = setTimeout(later, wait);\n        };\n    }\n\n    \/\/ Create debounced version of getConverterData\n    const debouncedGetConverterData = debounce(getConverterData, 300);\n\n    \/\/ Event listeners\n    amountInput.addEventListener('input', debouncedGetConverterData);\n    fromSelect.addEventListener('change', () => {\n        converterData = null;\n        getConverterData();\n    });\n    toSelect.addEventListener('change', () => {\n        converterData = null;\n        getConverterData();\n    });\n\n    \/\/ Initialize\n    getConverterData();\n<\/script>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-ebc444f e-con-full e-flex e-con e-child\" data-id=\"ebc444f\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t<div class=\"elementor-element elementor-element-33864d8 elementor-widget elementor-widget-text-editor\" data-id=\"33864d8\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\">\n<path d=\"M12 16V12M12 8H12.01M22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12Z\" stroke=\"#111827\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\/>\n<\/svg>\n<p>Let\u2019s say you want to know how much \u20ac1,000 is worth in US dollars. Input 1,000 in the amount field. Select EUR in the first currency dropdown. Select USD in the second currency dropdown. You will instantly see the current amount, updated in real-time, in the Conversion Value field.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Currency Converter Convert forex pairs instantly based on the latest exchange rate\u00a0 Amount AUDCADCHFDKKEURGBPHKDHUFJPYMXNNOKNZDPLNRUBSEKSGDTRYUSDZAR Enter the amount you wish to convert and select the currency in which the amount was originally stated. Currency AUDCADCHFDKKEURGBPHKDHUFJPYMXNNOKNZDPLNRUBSEKSGDTRYUSDZAR Select the currency in which you wish to convert the amount. Convertion Value: 0.00 Let\u2019s say you want to know how [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"parent":1127,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"class_list":["post-1129","page","type-page","status-publish","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/oneroyal.academy\/ms\/wp-json\/wp\/v2\/pages\/1129","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oneroyal.academy\/ms\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/oneroyal.academy\/ms\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/oneroyal.academy\/ms\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/oneroyal.academy\/ms\/wp-json\/wp\/v2\/comments?post=1129"}],"version-history":[{"count":74,"href":"https:\/\/oneroyal.academy\/ms\/wp-json\/wp\/v2\/pages\/1129\/revisions"}],"predecessor-version":[{"id":2043,"href":"https:\/\/oneroyal.academy\/ms\/wp-json\/wp\/v2\/pages\/1129\/revisions\/2043"}],"up":[{"embeddable":true,"href":"https:\/\/oneroyal.academy\/ms\/wp-json\/wp\/v2\/pages\/1127"}],"wp:attachment":[{"href":"https:\/\/oneroyal.academy\/ms\/wp-json\/wp\/v2\/media?parent=1129"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}