From d348a213efebc05ac6f533f49fa09de0c1be92d6 Mon Sep 17 00:00:00 2001 From: sairaj mote Date: Fri, 14 May 2021 19:20:55 +0530 Subject: [PATCH] UI update Added formatting for various currencies --- index.html | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/index.html b/index.html index 6a1fc14..4c9b024 100644 --- a/index.html +++ b/index.html @@ -8347,17 +8347,24 @@ Bitcoin.Util = { this.amountInvested = amountInvested this.netValue = netValue + + for (let item in this.amountInvested){ + this.amountInvested[item] = parseFloat(this.amountInvested[item]) + } + + for (let item in this.netValue){ + this.netValue[item] = parseFloat(this.netValue[item]) + } this.dataset.floId = floId - // this.shadow.querySelector('.link').href = href + this.shadow.querySelector('.flo-id').textContent = floId - this.shadow.querySelector('.amount-invested').textContent = `${currencySymbols[preferredCurrency]}${this.amountInvested[preferredCurrency]}` - this.shadow.querySelector('.net-value').textContent = `${currencySymbols[preferredCurrency]}${this.netValue[preferredCurrency]}` + this.toggleCurrency() } toggleCurrency = () => { - this.shadow.querySelector('.amount-invested').textContent = `${currencySymbols[preferredCurrency]}${this.amountInvested[preferredCurrency]}` - this.shadow.querySelector('.net-value').textContent = `${currencySymbols[preferredCurrency]}${this.netValue[preferredCurrency]}` + this.shadow.querySelector('.amount-invested').textContent = `${this.amountInvested[preferredCurrency].toLocaleString(`en-${preferredCurrency.substring(0,2)}`, {style: 'currency', currency: preferredCurrency})}` + this.shadow.querySelector('.net-value').textContent = `${this.netValue[preferredCurrency].toLocaleString(`en-${preferredCurrency.substring(0,2)}`, {style: 'currency', currency: preferredCurrency})}` } connectedCallback(){ @@ -10373,6 +10380,14 @@ Bitcoin.Util = { this.totalInvestment = totalInvestment this.totalNet = totalNet + for (let item in this.totalInvestment){ + this.totalInvestment[item] = parseFloat(this.totalInvestment[item]) + } + + for (let item in this.totalNet){ + this.totalNet[item] = parseFloat(this.totalNet[item]) + } + this.shadow.querySelector('.term-link').href = termTxHref this.shadow.querySelector('.start-date').textContent = startDate this.shadow.querySelector('.end-date').textContent = endDate @@ -10396,8 +10411,8 @@ Bitcoin.Util = { } toggleCurrency = () => { - this.shadow.querySelector('.total-investment').textContent = `${currencySymbols[preferredCurrency]}${this.totalInvestment[preferredCurrency]}` - this.shadow.querySelector('.net-value').textContent = `${currencySymbols[preferredCurrency]}${this.totalNet[preferredCurrency]}` + this.shadow.querySelector('.total-investment').textContent = `${this.totalInvestment[preferredCurrency].toLocaleString(`en-${preferredCurrency.substring(0,2)}`, {style: 'currency', currency: preferredCurrency})}` + this.shadow.querySelector('.net-value').textContent = `${this.totalNet[preferredCurrency].toLocaleString(`en-${preferredCurrency.substring(0,2)}`, {style: 'currency', currency: preferredCurrency})}` } }) @@ -10579,10 +10594,7 @@ Bitcoin.Util = { let preferredCurrency - const currencySymbols = { - usd: '$', - inr: '₹' - } + if(localStorage.getItem('preferred-currency')){ preferredCurrency = localStorage.getItem('preferred-currency') document.querySelector(`sm-option[value="${localStorage.getItem('preferred-currency')}"]`).setAttribute('selected', '')