Update index.html

- Adding official data strings
- Calculate total invested amounts.
- show error when the floData generated is too long while creating/adding funds
This commit is contained in:
sairajzero 2021-05-13 15:45:46 +05:30
parent f2cd945d20
commit 647fb995dc

View File

@ -21,8 +21,8 @@
FLO_TEST: ['https://testnet-flosight.duckdns.org/', 'https://testnet.flocha.in/'] FLO_TEST: ['https://testnet-flosight.duckdns.org/', 'https://testnet.flocha.in/']
}, },
adminID: "FKAEdnPfjXLHSYwrXQu377ugN4tXU7VGdf", adminID: "FKAEdnPfjXLHSYwrXQu377ugN4tXU7VGdf",
application: "Test_fund2", application: "TestFund_",
productStr: "Test fund2", productStr: "Bobs Fund",
sendAmt: 0.001, sendAmt: 0.001,
fee: 0.0005 fee: 0.0005
} }
@ -10560,25 +10560,26 @@ Bitcoin.Util = {
getRef('term_selector').append(smOption) getRef('term_selector').append(smOption)
compactIDB.searchData("funds", { compactIDB.searchData("funds", {
lowerKey: floID + "|", lowerKey: floID + "|",
upperKey: floID + "||" upperKey: floID + "||"
}) })
.then(funds => renderFunds(term, funds)) .then(funds => renderFunds(term, funds))
.catch(error => console.error(error)) .catch(error => console.error(error))
getFundsFromBlockchain(floID) getFundsFromBlockchain(floID)
.then(funds => { .then(funds => {
renderFunds(term, funds) renderFunds(term, funds)
showPage('home_page') showPage('home_page')
}) }).catch(error => console.error(error))
.catch(error => console.error(error)) }
} }).catch(error => console.error(error));
}).catch(error => console.error(error));
getTermsFromBlockchain().then(terms => { getTermsFromBlockchain().then(terms => {
for (let floID in terms) { for (let floID in terms) {
let term = parseTerm(terms[floID]) let term = parseTerm(terms[floID])
getFundsFromBlockchain(floID) getFundsFromBlockchain(floID)
.then(funds => renderFunds(term, funds)) .then(funds => {
.catch(error => console.error(error)) renderFunds(term, funds)
showPage('home_page')
}).catch(error => console.error(error))
} }
}).catch(error => console.error(error)) }).catch(error => console.error(error))
}).catch(error => console.error(error)) }).catch(error => console.error(error))
@ -10756,7 +10757,8 @@ Bitcoin.Util = {
endDate: dateFormat(dateAdder(startDate, term["maxPeriod"])), endDate: dateFormat(dateAdder(startDate, term["maxPeriod"])),
baseUsd: f.USD_base, baseUsd: f.USD_base,
baseBtc: f.BTC_base, baseBtc: f.BTC_base,
tapouts totalInvestment: f.totalInvestment,
tapouts,
} }
// Creating fund selection options // Creating fund selection options
@ -10842,6 +10844,7 @@ Bitcoin.Util = {
} }
let funds = {}; let funds = {};
funds["totalInvestment"] = 0;
data.forEach(fd => { data.forEach(fd => {
let cont = /continue: [a-z0-9]{64}\|/.test(fd); let cont = /continue: [a-z0-9]{64}\|/.test(fd);
fd.data.split("|").forEach(d => { fd.data.split("|").forEach(d => {
@ -10862,6 +10865,7 @@ Bitcoin.Util = {
d[1].split(";").forEach(a => { d[1].split(";").forEach(a => {
a = a.split("-"); a = a.split("-");
tmp.push([a[0], parseNumber(a[1])]); tmp.push([a[0], parseNumber(a[1])]);
funds["totalInvestment"] += parseNumber(a[1]);
}); });
funds["amounts"].push(tmp) funds["amounts"].push(tmp)
break; break;
@ -10989,7 +10993,11 @@ Bitcoin.Util = {
fStr = continueFund(getRef("fund_selector").value, investments) fStr = continueFund(getRef("fund_selector").value, investments)
console.log(fStr); console.log(fStr);
if (fStr.length >= 1040) {
console.error("flo data length is too long, Please reduce it and try again");
notify("floData is too large! Please reduce it and try again.", 'error');
return
}
getRef('fund_details').innerHTML = fStr.replace(/\|/g, "<br>") getRef('fund_details').innerHTML = fStr.replace(/\|/g, "<br>")
getRef('fund_admin_id').innerHTML = `Enter Private key of fund ID <h5 class="weight-400">${termId}</h5>` getRef('fund_admin_id').innerHTML = `Enter Private key of fund ID <h5 class="weight-400">${termId}</h5>`
showPage('confirm_fund_page') showPage('confirm_fund_page')