Making the balance appear
This commit is contained in:
parent
1c5cb38197
commit
a16589a5d9
15
extension/lib/commonHelpers.js
Normal file
15
extension/lib/commonHelpers.js
Normal file
@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
Handlebars.registerHelper('prettyAmount', function (amount) {
|
||||
let v = amount.value + amount.fraction / 10e6;
|
||||
return v.toFixed(2) + " " + amount.currency;
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('prettyAmountNoCurrency', function (amount) {
|
||||
let v = amount.value + amount.fraction / 10e6;
|
||||
return v.toFixed(2);
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('objectStringifier', function (o) {
|
||||
return JSON.stringify(o);
|
||||
});
|
@ -5,6 +5,7 @@
|
||||
<title>Taler Wallet: Confirm Reserve Creation</title>
|
||||
<script src="../lib/URI.js"></script>
|
||||
<script src="../lib/handlebars-v4.0.5.js"></script>
|
||||
<script src="../lib/commonHelpers.js"></script>
|
||||
<script src="confirm-contract.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../style/wallet.css">
|
||||
|
||||
|
@ -6,14 +6,13 @@
|
||||
<link rel="stylesheet" href="popup.css" type="text/css">
|
||||
<script src="../lib/util.js" type="text/javascript"></script>
|
||||
<script src="../lib/handlebars-v4.0.5.js"></script>
|
||||
<script src="../lib/commonHelpers.js"></script>
|
||||
<script src="balance-overview.js" type="text/javascript"></script>
|
||||
|
||||
|
||||
<script id="balance-template" type="text/x-handlebars-template">
|
||||
<div>
|
||||
{{#each this}}
|
||||
<p>{{this.value + this.fraction / 10e6 + <a> this.currency}}</a></p>
|
||||
{{/each}}
|
||||
</div>
|
||||
{{#each this}}
|
||||
<p>{{prettyAmountNoCurrency this}} <a>{{@key}}</a></p>
|
||||
{{/each}}
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
@ -19,16 +19,17 @@ document.addEventListener('DOMContentLoaded', (e) => {
|
||||
chrome.runtime.sendMessage({ type: "balances" }, function (wallet) {
|
||||
console.log("got balance");
|
||||
let n = 0;
|
||||
/*let table = <div />;*/
|
||||
let table = React.createElement("div", null);
|
||||
let source = document.getElementById("balance-template").innerHTML;
|
||||
console.log("size", Object.keys(wallet).length);
|
||||
if (Object.keys(wallet).length > 0) {
|
||||
let template = Handlebars.compile(source);
|
||||
console.log("DB error? ", chrome.runtime.lastError);
|
||||
console.log("wallet ", JSON.stringify(wallet));
|
||||
let html = template({ wallet: wallet, walletEmpty: wallet.length == 0 });
|
||||
let html = template(wallet);
|
||||
console.log("Hb generated html", html);
|
||||
document.getElementById("content").innerHTML = html;
|
||||
table.innerHTML = html;
|
||||
let p = document.getElementById("content");
|
||||
p.replaceChild(table, p.firstElementChild);
|
||||
}
|
||||
/*
|
||||
for (let curr in wallet) {
|
||||
|
@ -21,17 +21,18 @@ document.addEventListener('DOMContentLoaded', (e) => {
|
||||
chrome.runtime.sendMessage({type: "balances"}, function(wallet) {
|
||||
console.log("got balance");
|
||||
let n = 0;
|
||||
/*let table = <div />;*/
|
||||
let table = <div />;
|
||||
|
||||
let source = document.getElementById("balance-template").innerHTML;
|
||||
console.log("size", Object.keys(wallet).length);
|
||||
if (Object.keys(wallet).length > 0){
|
||||
let template = Handlebars.compile(source);
|
||||
console.log("DB error? ", chrome.runtime.lastError);
|
||||
console.log("wallet ", JSON.stringify(wallet));
|
||||
let html = template({wallet: wallet, walletEmpty: wallet.length == 0});
|
||||
let html = template(wallet);
|
||||
console.log("Hb generated html", html);
|
||||
document.getElementById("content").innerHTML = html;
|
||||
table.innerHTML = html;
|
||||
let p = document.getElementById("content");
|
||||
p.replaceChild(table, p.firstElementChild);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
<body>
|
||||
<div id="header" class="nav">
|
||||
<a href="wallet.html">Wallet</a>
|
||||
<a href="balance-overview.html">Wallet</a>
|
||||
<a href="transactions.html">Transactions</a>
|
||||
<a href="reserves.html" class="active">Reserves</a>
|
||||
</div>
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
<body>
|
||||
<div id="header" class="nav">
|
||||
<a href="wallet.html">Wallet</a>
|
||||
<a href="balance-overview.html">Wallet</a>
|
||||
<a href="transactions.html" class="active">Transactions</a>
|
||||
<a href="reserves.html">Reserves</a>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user