This commit is contained in:
sairaj mote 2020-06-18 21:36:41 +05:30
parent d3d4a005ba
commit a6d4005e8a
4 changed files with 260 additions and 198 deletions

View File

@ -396,6 +396,7 @@ p {
transform-origin: left; transform-origin: left;
pointer-events: none; pointer-events: none;
will-change: contents; will-change: contents;
text-transform: capitalize;
} }
.input input { .input input {
@ -561,6 +562,10 @@ form {
padding: 0.6em 1.2em; padding: 0.6em 1.2em;
} }
.popup-container .popup p {
margin-bottom: 1.5rem !important;
}
#show_message { #show_message {
-webkit-transform: translate(0, -100%); -webkit-transform: translate(0, -100%);
transform: translate(0, -100%); transform: translate(0, -100%);
@ -689,15 +694,15 @@ form {
} }
#sign_in_popup h1 { #sign_in_popup h1 {
margin-top: 3em; margin-top: 2rem;
} }
#sign_in_popup p:first-of-type { #sign_in_popup p:first-of-type {
margin-bottom: 4em; margin-bottom: 4em;
} }
#sign_in_popup .action { #sign_in_popup button {
margin-top: 1em; margin: 1rem 0;
} }
#sign_in_popup p:nth-of-type(2) { #sign_in_popup p:nth-of-type(2) {
@ -801,10 +806,6 @@ form {
font-weight: 700; font-weight: 700;
} }
#navbar .navbar-item .banking {
stroke-width: 4;
}
#navbar .active { #navbar .active {
color: var(--primary-color); color: var(--primary-color);
} }
@ -813,8 +814,12 @@ form {
stroke: var(--primary-color); stroke: var(--primary-color);
} }
.banking {
stroke-width: 4;
}
#home_page h1 { #home_page h1 {
margin-top: 4rem; margin-top: 4vw;
margin-bottom: 1rem; margin-bottom: 1rem;
font-weight: 700; font-weight: 700;
} }
@ -854,6 +859,8 @@ form {
} }
.options-tab .option .icon { .options-tab .option .icon {
height: 1.4rem;
width: 1.4rem;
margin-bottom: 1.5rem; margin-bottom: 1.5rem;
} }
@ -898,11 +905,11 @@ form {
.request h5 { .request h5 {
color: rgba(var(--text-light), 1); color: rgba(var(--text-light), 1);
margin-bottom: 0.3rem; margin-bottom: 0.6rem;
} }
.request h3, .request h4 { .request h3, .request h4 {
margin-bottom: 1em; margin-bottom: 1.5rem;
font-family: 'Roboto', sans-serif; font-family: 'Roboto', sans-serif;
font-weight: 500; font-weight: 500;
} }
@ -1081,6 +1088,45 @@ form {
} }
} }
#profile_page h5 {
margin-bottom: 0.5rem;
}
#main_loader {
-webkit-box-shadow: none;
box-shadow: none;
background: none;
text-align: center;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
}
#main_loader svg {
height: 2rem;
width: 2rem;
stroke: var(--primary-color);
stroke-width: 6;
fill: none;
overflow: visible;
stroke-linecap: round;
stroke-dashoffset: 210;
stroke-dasharray: 210;
-ms-grid-column-align: center;
justify-self: center;
-ms-flex-item-align: center;
-ms-grid-row-align: center;
align-self: center;
margin-bottom: 2rem;
}
#main_loader h3 {
width: 100%;
text-transform: uppercase;
font-weight: 400;
word-spacing: 0.16em;
}
@media only screen and (min-width: 800px) { @media only screen and (min-width: 800px) {
.container { .container {
-ms-grid-columns: (1fr)[3]; -ms-grid-columns: (1fr)[3];

File diff suppressed because one or more lines are too long

View File

@ -248,6 +248,7 @@ p{
transform-origin: left; transform-origin: left;
pointer-events: none; pointer-events: none;
will-change: contents; will-change: contents;
text-transform: capitalize;
} }
input{ input{
flex: 1; flex: 1;
@ -359,6 +360,9 @@ form{
padding: 0.6em 1.2em; padding: 0.6em 1.2em;
} }
} }
p{
margin-bottom: 1.5rem !important;
}
} }
} }
#show_message{ #show_message{
@ -445,13 +449,13 @@ form{
width: calc(100vw - 2em); width: calc(100vw - 2em);
background: rgba(var(--foreground), 1); background: rgba(var(--foreground), 1);
h1{ h1{
margin-top: 3em; margin-top: 2rem;
} }
p:first-of-type{ p:first-of-type{
margin-bottom: 4em; margin-bottom: 4em;
} }
.action{ button{
margin-top: 1em; margin: 1rem 0;
} }
p:nth-of-type(2){ p:nth-of-type(2){
margin-top: 2em; margin-top: 2em;
@ -525,9 +529,6 @@ form{
margin-top: 0.4em; margin-top: 0.4em;
font-weight: 700; font-weight: 700;
} }
.banking{
stroke-width: 4;
}
} }
.active{ .active{
color: var(--primary-color); color: var(--primary-color);
@ -536,9 +537,12 @@ form{
} }
} }
} }
.banking{
stroke-width: 4;
}
#home_page{ #home_page{
h1{ h1{
margin-top: 4rem; margin-top: 4vw;
margin-bottom: 1rem; margin-bottom: 1rem;
font-weight: 700; font-weight: 700;
} }
@ -565,6 +569,8 @@ form{
text-transform: capitalize; text-transform: capitalize;
cursor: pointer; cursor: pointer;
.icon{ .icon{
height: 1.4rem;
width: 1.4rem;
margin-bottom: 1.5rem; margin-bottom: 1.5rem;
} }
} }
@ -597,10 +603,10 @@ form{
background: var(--background); background: var(--background);
h5{ h5{
color: rgba(var(--text-light), 1); color: rgba(var(--text-light), 1);
margin-bottom: 0.3rem; margin-bottom: 0.6rem;
} }
h3,h4{ h3,h4{
margin-bottom: 1em; margin-bottom: 1.5rem;
font-family: 'Roboto', sans-serif; font-family: 'Roboto', sans-serif;
font-weight: 500; font-weight: 500;
} }
@ -749,6 +755,37 @@ form{
grid-template-columns: repeat(3, 10rem); grid-template-columns: repeat(3, 10rem);
} }
} }
#profile_page{
h5{
margin-bottom: 0.5rem;
}
}
#main_loader{
box-shadow: none;
background: none;
text-align: center;
justify-content: center;
svg{
height: 2rem;
width: 2rem;
stroke: var(--primary-color);
stroke-width: 6;
fill: none;
overflow: visible;
stroke-linecap: round;
stroke-dashoffset: 210;
stroke-dasharray: 210;
justify-self: center;
align-self: center;
margin-bottom: 2rem;
}
h3{
width: 100%;
text-transform: uppercase;
font-weight: 400;
word-spacing: 0.16em;
}
}
@media only screen and (min-width: 800px){ @media only screen and (min-width: 800px){
.container{ .container{
grid-template-columns: repeat(3, 1fr); grid-template-columns: repeat(3, 1fr);

View File

@ -48,6 +48,17 @@
</svg> </svg>
</button> </button>
</div> </div>
<!-- Loading screen-->
<div class="popup-container solid-background hide">
<div id="main_loader" class="popup">
<svg id="loader" viewBox="0 0 73 73">
<title>Loader</title>
<path d="M72.5,36.5c0,19.88-16.12,36-36,36s-36-16.12-36-36s16.12-36,36-36S72.5,16.62,72.5,36.5" />
</svg>
<h3 id="tip_container">Loading BLOCKCHAIN UPi</h3>
</div>
</div>
<!-- Sign in popup-->
<div class="popup-container solid-background hide"> <div class="popup-container solid-background hide">
<div id="sign_in_popup" class="popup"> <div id="sign_in_popup" class="popup">
<div class="container-header"> <div class="container-header">
@ -56,19 +67,14 @@
<p class="expand light-text">Welcome to RanchiMall Blockchain UPI</b></p> <p class="expand light-text">Welcome to RanchiMall Blockchain UPI</b></p>
<form class="expand" autocomplete="off" onsubmit="return false"> <form class="expand" autocomplete="off" onsubmit="return false">
<div class="input"> <div class="input">
<input id="get_priv_key_field" type="password" required> <input id="get_priv_key_field" type="password" minlength="40" required>
<label>Private Key</label> <label>Private Key</label>
</div> </div>
<div class="action expand" onclick="signIn(this)"> <button id="sign_in_btn" class="primary-btn expand" type="submit" disabled>
<button class="primary-btn expand" type="submit" disabled>
Sign In Sign In
</button> </button>
<svg viewBox="0 0 73 73" class="loader">
<path
d="M72.5,36.5c0,19.88-16.12,36-36,36s-36-16.12-36-36s16.12-36,36-36S72.5,16.62,72.5,36.5" />
</svg>
</div>
</form> </form>
*Sign in button will not be activated until correct value is entered.
</div> </div>
</div> </div>
<header id="main_header" class="flex"> <header id="main_header" class="flex">
@ -92,7 +98,7 @@
</span> </span>
</div> </div>
<div id="display_balance"> <div id="display_balance">
<h5>Rupee Tokens</h5> <h5>Rupee Balance</h5>
<h3 id="token_balance">0</h3> <h3 id="token_balance">0</h3>
</div> </div>
</header> </header>
@ -104,7 +110,7 @@
</svg> </svg>
<h5>Home</h5> <h5>Home</h5>
</div> </div>
<div title="See all cash deposit requests" id="deposit_page_btn" class="navbar-item cashier-option" <div title="See all cash deposit requests" id="deposit_page_btn" class="navbar-item cashier-option hide-completely"
onclick="showPage(this, 'deposit')"> onclick="showPage(this, 'deposit')">
<svg class="icon banking" viewBox="0 0 52 51.5"> <svg class="icon banking" viewBox="0 0 52 51.5">
<line x1="4" y1="28" x2="4" y2="19.5" /> <line x1="4" y1="28" x2="4" y2="19.5" />
@ -118,7 +124,7 @@
</svg> </svg>
<h5>Deposit</h5> <h5>Deposit</h5>
</div> </div>
<div title="See all cash withdraw requests" class="navbar-item cashier-option" <div title="See all cash withdraw requests" class="navbar-item cashier-option hide-completely"
onclick="showPage(this, 'withdraw')"> onclick="showPage(this, 'withdraw')">
<svg class="icon banking" viewBox="0 0 52 60"> <svg class="icon banking" viewBox="0 0 52 60">
<line x1="4" y1="33.5" x2="4" y2="25" /> <line x1="4" y1="33.5" x2="4" y2="25" />
@ -137,7 +143,7 @@
</svg> </svg>
<h5>Withdraw</h5> <h5>Withdraw</h5>
</div> </div>
<div title="See all pay requests" class="navbar-item cashier-option" onclick="showPage(this, 'pay_cashier')"> <div title="See all pay requests" class="navbar-item cashier-option hide-completely" onclick="showPage(this, 'pay_cashier')">
<svg class="icon" viewBox="0 0 64 64"> <svg class="icon" viewBox="0 0 64 64">
<path d="M32,37.75A10.19,10.19,0,1,0,21.81,27.44V46.62" /> <path d="M32,37.75A10.19,10.19,0,1,0,21.81,27.44V46.62" />
<rect height="64" width="64" rx="8"></rect> <rect height="64" width="64" rx="8"></rect>
@ -173,12 +179,37 @@
<polyline <polyline
points="17.04 35.97 14.57 33.5 40.15 7.9 32.75 0.5 55.52 0.5 55.52 23.28 48.12 15.87 23.86 40.14 15.88 48.13 8.48 40.72 8.48 63.5 31.25 63.5 23.85 56.1 49.43 30.5 46.96 28.03" /> points="17.04 35.97 14.57 33.5 40.15 7.9 32.75 0.5 55.52 0.5 55.52 23.28 48.12 15.87 23.86 40.14 15.88 48.13 8.48 40.72 8.48 63.5 31.25 63.5 23.85 56.1 49.43 30.5 46.96 28.03" />
</svg> </svg>
Transfer cash Transfer Rupee
</div> </div>
<div class="option" onclick="showPopup('buy_rupee')"> <div class="option" onclick="showPopup('deposit_rupee')">
buy rupee <svg class="icon banking" viewBox="0 0 52 51.5">
<line x1="4" y1="28" x2="4" y2="19.5" />
<polyline points="4 6 4 1 51 1 51 48 4 48 4 41.5" />
<line x1="9" y1="50" x2="18" y2="50" />
<line x1="36" y1="50" x2="45" y2="50" />
<circle cx="27.5" cy="30" r="9.5" />
<circle cx="27.5" cy="30" r="3.5" />
<rect x="1" y="6" width="6" height="13.5" rx="2.76" />
<rect x="1" y="28" width="6" height="13.5" rx="2.76" />
</svg>
deposit rupee
</div>
<div class="option" onclick="showPopup('withdraw_rupee')">
<svg class="icon banking" viewBox="0 0 52 60">
<line x1="4" y1="33.5" x2="4" y2="25" />
<polyline points="41.52 6.5 51 6.5 51 53.5 41.69 53.5" />
<line x1="9" y1="55.5" x2="14" y2="55.5" />
<line x1="43" y1="55.5" x2="45" y2="55.5" />
<rect x="1" y="11.5" width="6" height="13.5" rx="2.76" />
<rect x="1" y="33.5" width="6" height="13.5" rx="2.76" />
<polyline points="3.81 11.5 3.81 6.5 41.5 1 41.69 59 3.81 53.5 3.81 47" />
<path d="M35.64,39.19c0,6.31-3.25,11.45-7.22,11.48s-7-4.92-7-11.07,3.13-11.29,7.05-11.48S35.64,32.88,35.64,39.19Z"
transform="translate(-6 -2)" />
<path d="M31.06,39.32c0,2.31-1.19,4.2-2.64,4.23s-2.62-1.79-2.62-4.08S27,35.3,28.42,35.24,31.06,37,31.06,39.32Z"
transform="translate(-6 -2)" />
</svg>
withdraw rupee
</div> </div>
<div class="option" onclick="showPopup('withdraw_rupee')">withdraw rupee</div>
<div class="option" onclick="showPopup('pay_anyone')"> <div class="option" onclick="showPopup('pay_anyone')">
<svg class="icon" viewBox="0 0 64 64"> <svg class="icon" viewBox="0 0 64 64">
<path d="M32,37.75A10.19,10.19,0,1,0,21.81,27.44V46.62" /> <path d="M32,37.75A10.19,10.19,0,1,0,21.81,27.44V46.62" />
@ -190,13 +221,17 @@
<div class="popup-container hide"> <div class="popup-container hide">
<div id="cash_transfer" class="popup"> <div id="cash_transfer" class="popup">
<div class="container-header"> <div class="container-header">
<h3>Cash transfer</h3> <h3>Transfer Rupee</h3>
<div id="send_tokens_btn" class="action expand"> <div id="send_tokens_btn" class="action expand">
<button class="primary-btn expand" type="submit" disabled> <button class="primary-btn expand" type="submit" disabled>
transfer transfer
</button> </button>
</div> </div>
</div> </div>
<p>
Transfer your deposited Rupee tokens to any FLO address.<br>
*Requires token to be deposited first.
</p>
<form autocomplete="off" onsubmit="return false"> <form autocomplete="off" onsubmit="return false">
<div class="input"> <div class="input">
<input id="token_receiver" type="text" required> <input id="token_receiver" type="text" required>
@ -210,19 +245,18 @@
</div> </div>
</div> </div>
<div class="popup-container hide"> <div class="popup-container hide">
<div id="buy_rupee" class="popup"> <div id="deposit_rupee" class="popup">
<div class="container-header"> <div class="container-header">
<h3>Buy rupee</h3> <h3>Deposit rupee</h3>
<div id="request_tokens_btn" class="action expand"> <div id="request_tokens_btn" class="action expand">
<button class="primary-btn expand" type="submit" disabled> <button class="primary-btn expand" type="submit" disabled>
buy deposit
</button> </button>
<svg viewBox="0 0 73 73" class="loader">
<path
d="M72.5,36.5c0,19.88-16.12,36-36,36s-36-16.12-36-36s16.12-36,36-36S72.5,16.62,72.5,36.5" />
</svg>
</div> </div>
</div> </div>
<p>
Deposit rupee through UPI to use as Digital currency powered by blockchain.
</p>
<form autocomplete="off" onsubmit="return false"> <form autocomplete="off" onsubmit="return false">
<div class="input"> <div class="input">
<input id="token_amount_to_buy" inputmode="numeric" type="number" required> <input id="token_amount_to_buy" inputmode="numeric" type="number" required>
@ -239,21 +273,20 @@
<button class="primary-btn expand" type="submit" disabled> <button class="primary-btn expand" type="submit" disabled>
withdraw withdraw
</button> </button>
<svg viewBox="0 0 73 73" class="loader">
<path
d="M72.5,36.5c0,19.88-16.12,36-36,36s-36-16.12-36-36s16.12-36,36-36S72.5,16.62,72.5,36.5" />
</svg>
</div> </div>
</div> </div>
<p>
Withdraw or redeem your rupee tokens back to your specified UPI address.
</p>
<form autocomplete="off" onsubmit="return false"> <form autocomplete="off" onsubmit="return false">
<div class="input">
<input id="withdraw_cash_amount" type="text" required>
<label for="withdraw_cash_amount">Reciever's FLO ID</label>
</div>
<div class="input"> <div class="input">
<input id="user_withdraw_upi" type="text" required> <input id="user_withdraw_upi" type="text" required>
<label for="user_withdraw_upi">Reciever's UPI address</label> <label for="user_withdraw_upi">Reciever's UPI address</label>
</div> </div>
<div class="input">
<input id="withdraw_cash_amount" type="number" inputmode="numeric" required>
<label for="withdraw_cash_amount">amount</label>
</div>
</form> </form>
</div> </div>
</div> </div>
@ -266,12 +299,11 @@
<button class="primary-btn expand" type="submit" disabled> <button class="primary-btn expand" type="submit" disabled>
pay pay
</button> </button>
<svg viewBox="0 0 73 73" class="loader">
<path
d="M72.5,36.5c0,19.88-16.12,36-36,36s-36-16.12-36-36s16.12-36,36-36S72.5,16.62,72.5,36.5" />
</svg>
</div> </div>
</div> </div>
<p>
Don't have enough token balance? Pay to our cashier through UPI and your cash will be transfered as Rupee tokens.
</p>
<form autocomplete="off" onsubmit="return false"> <form autocomplete="off" onsubmit="return false">
<div class="input"> <div class="input">
<input id="recvr_id" type="text" required> <input id="recvr_id" type="text" required>
@ -502,6 +534,7 @@
depositRequest: function (txid, floId) { depositRequest: function (txid, floId) {
let card = document.createElement('div'); let card = document.createElement('div');
card.classList.add('request') card.classList.add('request')
setAttributes(card, {'data-user-flo-id': floId, 'data-txid': txid})
card.innerHTML = ` <h5>FLO ID</h5> card.innerHTML = ` <h5>FLO ID</h5>
<h4 class="breakable">${floId}</h4> <h4 class="breakable">${floId}</h4>
<h5>UPI TXID</h5> <h5>UPI TXID</h5>
@ -514,6 +547,7 @@
withdrawRequest: function (txid, upiId, floId) { withdrawRequest: function (txid, upiId, floId) {
let card = document.createElement('div'); let card = document.createElement('div');
card.classList.add('request') card.classList.add('request')
setAttributes(card, {'data-txid': txid, 'data-user-flo-id': floId, 'data-upi': upiId })
card.innerHTML = ` <h5>FLO ID</h5> card.innerHTML = ` <h5>FLO ID</h5>
<h4 class="breakable">${floId}</h4> <h4 class="breakable">${floId}</h4>
<h5>UPI ID</h5> <h5>UPI ID</h5>
@ -528,13 +562,14 @@
payRequest: function (sender, txid, floId, amount) { payRequest: function (sender, txid, floId, amount) {
let card = document.createElement('div'); let card = document.createElement('div');
card.classList.add('request') card.classList.add('request')
card.innerHTML = ` <h5>Transaction ID</h5> setAttributes(card, {'data-sender': sender, 'data-receiver-flo-id': floId, 'data-txid': txid, 'data-amount': amount})
card.innerHTML = ` <h5>Transaction ID</h5>
<h4 class="breakable">${txid}</h4> <h4 class="breakable">${txid}</h4>
<h5>Receiver's FLO ID</h5> <h5>Receiver's FLO ID</h5>
<h4 class="breakable">${floId}</h4> <h4 class="breakable">${floId}</h4>
<h5>Amount</h5> <h5>Amount</h5>
<h4 class="breakable">₹${amount}</h4> <h4 class="breakable">₹${amount}</h4>
<button id="" class="confirm-withdraw-btn"> <button id="" class="confirm-pay-btn">
Transfer Transfer
</button>`; </button>`;
return card; return card;
@ -550,11 +585,6 @@
window.addEventListener('online', () => { window.addEventListener('online', () => {
notify('', 'We are back online.', '', true) notify('', 'We are back online.', '', true)
}) })
function clearAllInputs(parent) {
parent.querySelectorAll("input, textarea").forEach((field) => {
field.value = '';
})
}
// function required for popups or modals to appear // function required for popups or modals to appear
class Stack { class Stack {
constructor() { constructor() {
@ -600,8 +630,8 @@
zIndex--; zIndex--;
thisPopup.parentNode.setAttribute('style', `z-index: ${zIndex}`) thisPopup.parentNode.setAttribute('style', `z-index: ${zIndex}`)
}, 400) }, 400)
if (popup === 'main_loader') { if (popup === 'main_loader' || popup === 'sign_in_popup') {
loader.classList.remove('animate-loader') //loader.classList.remove('animate-loader')
document.querySelector('main').classList.remove('hide-completely') document.querySelector('main').classList.remove('hide-completely')
} }
} }
@ -629,6 +659,8 @@
else else
field.checked = false field.checked = false
}) })
if(parent.querySelector("button[type='submit']"))
parent.querySelector("button[type='submit']").disabled = true;
} }
//Function for displaying toast notifications. pass in error for mode param if you want to show an error. //Function for displaying toast notifications. pass in error for mode param if you want to show an error.
@ -666,13 +698,12 @@
// displays a popup for asking permission. Use this instead of JS confirm // displays a popup for asking permission. Use this instead of JS confirm
let askConfirmation = function (message) { let askConfirmation = function (message) {
return new Promise((resolve, reject) => { return new Promise(resolve => {
let popup = document.getElementById('confirmation'); let popup = document.getElementById('confirmation');
showPopup('confirmation') showPopup('confirmation')
popup.children[0].textContent = message; popup.children[0].textContent = message;
popup.children[1].firstElementChild.onclick = function () { popup.children[1].firstElementChild.onclick = function () {
hidePopup() hidePopup()
reject(false)
} }
popup.children[1].children[1].onclick = function () { popup.children[1].children[1].onclick = function () {
hidePopup() hidePopup()
@ -680,33 +711,6 @@
} }
}) })
} }
function enableBtn(btn) {
if (typeof btn === 'string')
btn = document.getElementById(btn);
if (btn.disabled)
btn.disabled = false;
}
function disableBtn(btn) {
if (typeof btn === 'string')
btn = document.getElementById(btn);
if (!btn.disabled)
btn.disabled = true;
}
function btnLoading(btn, option) {
if (typeof btn === 'string')
btn = document.getElementById(btn);
if (option === 'start') {
btn.firstElementChild.focus();
btn.children[0].classList.add('clip')
btn.children[1].classList.add('animate-loader')
}
else {
disableBtn(btn.children[0])
btn.children[0].classList.remove('clip')
btn.children[1].classList.remove('animate-loader')
}
}
// prevents non numerical input on firefox // prevents non numerical input on firefox
function preventNonNumericalInput(e) { function preventNonNumericalInput(e) {
@ -736,6 +740,9 @@
let allForms = document.querySelectorAll('form'); let allForms = document.querySelectorAll('form');
window.addEventListener('load', () => { window.addEventListener('load', () => {
/*document.querySelectorAll('.popup:not(.hide)').forEach(popup => {
popupStack.push(popup.id)
})*/
allForms.forEach((form) => { allForms.forEach((form) => {
form.addEventListener('input', (e) => { form.addEventListener('input', (e) => {
if (e.target.closest('.input')) { if (e.target.closest('.input')) {
@ -763,44 +770,41 @@
// Function for confirming deposit requests // Function for confirming deposit requests
document.getElementById('pending_deposits_container').addEventListener('click', (e) => { document.getElementById('pending_deposits_container').addEventListener('click', (e) => {
let container = document.getElementById('pending_deposits_container');
if (e.target.closest('.confirm-deposit-btn')) if (e.target.closest('.confirm-deposit-btn'))
askConfirmation('Confirm this deposit request?').then((result) => { askConfirmation('Confirm this deposit request?').then(async (result) => {
if (result) { let depositRequest = e.target.closest('.request'),
let depositRequestId = e.target.closest('.confirm-deposit-btn').id; status = await transfer_token(depositRequest.dataset.userFloId, depositRequest.dataset.txid)
btnLoading(e.target.closest('.confirm-deposit-btn'), 'start') if(status){
setTimeout(() => { refresh_balance()
e.target.closest('.request').remove(); depositRequest.remove()
notify('', `Request id: ${depositRequestId} confirmed.`, '', true)
checkBalance();
if (container.children.length === 0) {
document.getElementById('deposit_illustration').classList.remove('hide-completely')
document.getElementById('search_deposit').classList.add('hide-completely')
}
}, 1000)
} }
}) })
}) })
// Function for confirming withdraw requests // Function for confirming withdraw requests
document.getElementById('pending_withdrawals_container').addEventListener('click', (e) => { document.getElementById('pending_withdrawals_container').addEventListener('click', (e) => {
let container = document.getElementById('pending_withdrawals_container'); if (e.target.closest('.confirm-withdraw-btn'))
if (e.target.closest('.confirm-withdraw-btn')) askConfirmation('Confirm this withdraw request?').then(async (result) => {
askConfirmation('Confirm this withdraw request?').then((result) => { let withdrawRequest = e.target.closest('.request'),
if (result) { status = await cash_sent(withdrawRequest.dataset.txid, withdrawRequest.dataset.userFloId, withdrawRequest.dataset.upi)
let withdrawRequestId = e.target.closest('.confirm-withdraw-btn').id; if (status) {
btnLoading(e.target.closest('.confirm-withdraw-btn'), 'start') refresh_balance()
setTimeout(() => { withdrawRequest.remove()
e.target.closest('.request').remove(); }
notify('', `Request id: ${withdrawRequestId} confirmed.`, '', true) })
if (container.children.length === 0) { })
document.getElementById('withdraw_illustration').classList.remove('hide-completely') // Function for confirming pay requests
document.getElementById('search_withdraw').classList.add('hide-completely') document.getElementById('pay_requests_container').addEventListener('click', (e) => {
} if (e.target.closest('.confirm-pay-btn'))
}, 1000) askConfirmation('Confirm this pay request?').then(async (result) => {
} let payRequest = e.target.closest('.request'),
}) status = await pay_through_cashier(payRequest.dataset.sender, payRequest.dataset.userFloId, payRequest.dataset.txid, payRequest.dataset.amount)
}) if (status) {
refresh_balance()
payRequest.remove()
}
})
})
}) })
let allPages = document.querySelectorAll('.page'), let allPages = document.querySelectorAll('.page'),
@ -821,57 +825,33 @@
} }
} }
let balDisplay = document.getElementById('token_balance'); function signIn() {
function checkBalance() { return new Promise((resolve, reject) => {
fetch(`https://ranchimallflo.duckdns.org/api/v1.0/getFloAddressBalance?floAddress=${myFloID}&token=rupee`)
.then((response) => {
if (response.status !== 200) {
console.log('Looks like there was a problem. Status Code: ' +
response.status);
return;
}
// Examine the text in the response
response.json().then(function (data) {
balDisplay.textContent = data.balance;
});
}
)
.catch(function (err) {
console.log('Fetch Error :-S', err);
});
}
function signIn(btn) {
let parentPopup = btn.closest('form');
btnLoading(btn, 'start')
//if operation completes{
setTimeout(() => {
btnLoading(btn, 'stop')
hidePopup() hidePopup()
notify('', 'Signed In') showPopup('sign_in_popup', 'no')
document.querySelector('main').classList.remove('hide-completely') let signInBtn = document.getElementById('sign_in_btn'),
document.getElementById('deposit_page_btn').click() privKeyInput = document.getElementById('get_priv_key_field')
}, 1000) signInBtn.onclick = () => {
//} resolve(privKeyInput.value)
}
})
} }
function signOut() { function signOut() {
askConfirmation('Do you want to sign out?').then((result) => { askConfirmation('Do you want to sign out?').then((result) => {
if (result) { notify('Signed out')
notify('', 'Signed out') document.querySelector('main').classList.add('hide-completely')
document.querySelector('main').classList.add('hide-completely') floDapps.clearCredentials()
showPopup('sign_in_popup') compactIDB.deleteDB().then((message) => {
floDapps.clearCredentials() delete token_app.master_configurations;
compactIDB.deleteDB().then((message) => { onLoadStartUp()
delete token_app.master_configurations; notify('You have logged out successfully.')
onLoadStartUp() }).catch((error) => {
notify('You have logged out successfully.') console.log(error)
}).catch((error) => { })
console.log(error) })
}) .catch(err =>{
} console.log(err)
}) })
} }
</script> </script>
@ -9171,7 +9151,6 @@
updateData: function (dataSet) { updateData: function (dataSet) {
try { try {
dataSet = JSON.parse(dataSet); dataSet = JSON.parse(dataSet);
console.log(dataSet)
for (vc in dataSet) { for (vc in dataSet) {
var message = dataSet[vc].message; var message = dataSet[vc].message;
if (message.diff) { if (message.diff) {
@ -9189,7 +9168,6 @@
storeGeneralData: function (filterStr, dataSet) { storeGeneralData: function (filterStr, dataSet) {
try { try {
dataSet = JSON.parse(dataSet); dataSet = JSON.parse(dataSet);
console.log(dataSet)
if (!Array.isArray(floGlobals.generalData[filterStr])) if (!Array.isArray(floGlobals.generalData[filterStr]))
floGlobals.generalData[filterStr] = [] floGlobals.generalData[filterStr] = []
for (vc in dataSet) { for (vc in dataSet) {
@ -9458,7 +9436,7 @@
} }
var getPrivateKeyCredentials = function () { var getPrivateKeyCredentials = function () {
return new Promise((resolve, reject) => { return new Promise(async (resolve, reject) => {
var indexArr = localStorage.getItem(`${floGlobals.application}#privKey`) var indexArr = localStorage.getItem(`${floGlobals.application}#privKey`)
if (indexArr) { if (indexArr) {
readSharesFromIDB(JSON.parse(indexArr)) readSharesFromIDB(JSON.parse(indexArr))
@ -9466,11 +9444,10 @@
.catch(error => reject(error)) .catch(error => reject(error))
} else { } else {
try { try {
var privKey = prompt("Enter Private Key: ") var privKey = await signIn()
if (!privKey) hidePopup()
return reject("Empty Private Key") showPopup('main_loader', 'no')
var floID = floCrypto.getFloIDfromPubkeyHex(floCrypto.getPubKeyHex(privKey)) var floID = floCrypto.getFloIDfromPubkeyHex(floCrypto.getPubKeyHex(privKey))
console.log(floID)
} catch (error) { } catch (error) {
console.error(error) console.error(error)
return reject("Invalid Private Key") return reject("Invalid Private Key")
@ -9584,19 +9561,19 @@
reactor.registerEvent("startUpSuccessLog"); reactor.registerEvent("startUpSuccessLog");
reactor.addEventListener("startUpSuccessLog", log => console.log(log)) reactor.addEventListener("startUpSuccessLog", log => console.log(log))
reactor.addEventListener("startUpSuccessLog", log => notify(log)) reactor.addEventListener("startUpSuccessLog", log => console.log(log))
reactor.registerEvent("startUpErrorLog"); reactor.registerEvent("startUpErrorLog");
reactor.addEventListener("startUpErrorLog", log => console.error(log)) reactor.addEventListener("startUpErrorLog", log => console.error(log))
function onLoadStartUp() { function onLoadStartUp() {
notify("Starting the app! Please Wait!") showPopup('main_loader', 'no')
console.log("Starting the app! Please Wait!")
floDapps.launchStartUp().then(result => { floDapps.launchStartUp().then(result => {
console.log(result) console.log(result)
notify(result) console.log(`Welcome ${myFloID}`)
notify(`Welcome ${myFloID}`)
token_app.actions.doShreeGanesh(); token_app.actions.doShreeGanesh();
checkBalance() refresh_balance()
document.getElementById('user_flo_id').textContent = myFloID document.getElementById('user_flo_id').textContent = myFloID
}).catch(error => console.error(error)) }).catch(error => console.error(error))
} }
@ -9808,7 +9785,6 @@
); );
} }
deepFreeze(token_app.master_configurations); deepFreeze(token_app.master_configurations);
console.log(token_app);
return token_app; return token_app;
} catch (error) { } catch (error) {
console.error( console.error(
@ -9834,9 +9810,7 @@
transferTokensManually(); transferTokensManually();
const allCashierOptions = document.querySelectorAll('.cashier-option'), const allCashierOptions = document.querySelectorAll('.cashier-option'),
userType = document.getElementById('user_type') userType = document.getElementById('user_type')
console.log(Object.keys(token_app.master_configurations.cashiers))
if (Object.keys(token_app.master_configurations.cashiers).includes(myFloID)) { if (Object.keys(token_app.master_configurations.cashiers).includes(myFloID)) {
console.log(myFloID)
allCashierOptions.forEach(option => { allCashierOptions.forEach(option => {
option.classList.remove('hide-completely') option.classList.remove('hide-completely')
}) })
@ -9848,9 +9822,12 @@
}) })
userType.textContent = 'User' userType.textContent = 'User'
} }
hidePopup()
init_pay_through_cashier_system(); init_pay_through_cashier_system();
show_deposit_request()
show_withdraw_request()
showPayRequests()
// build pay vendors ui // build pay vendors ui
// const pay_vendors_tbl = document.getElementById('pay_vendors_tbl') // const pay_vendors_tbl = document.getElementById('pay_vendors_tbl')
// let vd = ``; // let vd = ``;
@ -9869,7 +9846,7 @@
}, },
retrieveLatestContent: async function (receiverID = floGlobals.adminID, senderIDs = floGlobals.subAdmins) { retrieveLatestContent: async function (receiverID = floGlobals.adminID, senderIDs = floGlobals.subAdmins) {
notify('Loading the latest content') console.log('Loading the latest content')
floCloudAPI.requestObjectData(token_app.master_configurations.SUBJECT, { receiverID, senderIDs }); floCloudAPI.requestObjectData(token_app.master_configurations.SUBJECT, { receiverID, senderIDs });
@ -10099,10 +10076,10 @@
}, "flo_txid") }, "flo_txid")
notify(`Transfer successfull: ${flo_txid}.`); notify(`Transfer successfull: ${flo_txid}.`);
return false; return true;
} }
} catch (error) { } catch (error) {
throw new Error(error) notify(error, 'error')
} }
} }
@ -10151,7 +10128,7 @@
{ receiverID: input_data['withdrawer_flo_id'], senderIDs: [myFloID] }) { receiverID: input_data['withdrawer_flo_id'], senderIDs: [myFloID] })
} catch (error) { } catch (error) {
throw new Error(error) notify(error, 'error')
} }
} }
@ -10197,12 +10174,14 @@
async function refresh_balance() { async function refresh_balance() {
try { try {
const current_token_balance = document.getElementById('token_balance').innerText; const current_token_balance = document.getElementById('token_balance').textContent;
if (typeof current_token_balance == "string") { if (typeof current_token_balance == "string") {
const get_user_balance = await ajaxGet('https://ranchimallflo.duckdns.org/api/v1.0/getFloAddressBalance?token=rupee&floAddress=' + myFloID) const get_user_balance = await ajaxGet('https://ranchimallflo.duckdns.org/api/v1.0/getFloAddressBalance?token=rupee&floAddress=' + myFloID)
if (typeof get_user_balance === "object" && get_user_balance.balance >= 0) { if (typeof get_user_balance === "object" && get_user_balance.balance >= 0) {
document.getElementById('token_balance').innerText if(get_user_balance.balance === null)
= `${get_user_balance.floAddress}: ${get_user_balance.balance}`; get_user_balance.balance = 0;
document.getElementById('token_balance').textContent
= get_user_balance.balance;
} }
} }
return true; return true;
@ -10318,7 +10297,7 @@
}, upi_txid); }, upi_txid);
notify(`Transaction successfull: ${flo_txid}.`); notify(`Transaction successfull: ${flo_txid}.`);
notify(`INR ${amount_to_pay} sent to ${vendor_flo_id}`) notify(`INR ${amount_to_pay} sent to ${vendor_flo_id}`)
return false; return true;
} }
} }