saving handlebars tryings

This commit is contained in:
Marcello Stanisci 2015-12-16 16:50:11 +01:00
parent 22246ea156
commit f5d359e702
5 changed files with 52 additions and 17 deletions

View File

@ -363,7 +363,7 @@ class SignatureStruct {
constructor(x) {
this.members = {};
for (let k in x) {
this.set(k[0], k[1]);
this.set(x, x[k]);
}
}
toPurpose(a) {

View File

@ -5,6 +5,7 @@
</head>
<body>
<h1>Debug Pages</h1>
<a href="show-db.html">Show DB</a>
<a href="show-db.html">Show DB</a> <br>
<a href="../popup/balance-overview.html">Show balance</a>
</body>
</html>

View File

@ -5,9 +5,18 @@
<meta charset="utf-8">
<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="balance-overview.js" type="text/javascript"></script>
</head>
<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>
</script>
</head>
<body>
<div id="header" class="nav">
<a href="wallet.html" class="active">Wallet</a>
@ -18,9 +27,11 @@
</div>
<div id="content">
<p id="balances">
Looks like your wallet is empty. Want to get some <a id="link-kudos" href="http://bank.demo.taler.net">KUDOS?</a>
</p>
<div id="balance">
<p>Looks like your wallet is empty. Want to get some
<a id="link-kudos" href="http://bank.demo.taler.net">KUDOS?</a>
</p>
</div>
</div>
</body>

View File

@ -19,17 +19,28 @@ document.addEventListener('DOMContentLoaded', (e) => {
chrome.runtime.sendMessage({ type: "balances" }, function (wallet) {
console.log("got balance");
let n = 0;
let table = React.createElement("div", null);
/*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 });
console.log("Hb generated html", html);
document.getElementById("content").innerHTML = html;
}
/*
for (let curr in wallet) {
n++;
let x = wallet[curr];
let num = x.value + x.fraction / 10e6;
table.appendChild(React.createElement("p", null, num, " ", React.createElement("a", null, x.currency)));
n++;
let x = wallet[curr];
let num = x.value + x.fraction / 10e6;
table.appendChild(<p>{num} <a>{x.currency}</a></p>);
}
if (n != 0) {
let p = document.getElementById("content");
p.replaceChild(table, p.firstElementChild);
}
let p = document.getElementById("content");
p.replaceChild(table, p.firstElementChild);
} */
});
document.getElementById("debug").addEventListener("click", (e) => {
chrome.tabs.create({

View File

@ -16,13 +16,25 @@ let React = {
}
}
document.addEventListener('DOMContentLoaded', (e) => {
console.log("content loaded");
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});
console.log("Hb generated html", html);
document.getElementById("content").innerHTML = html;
}
/*
for (let curr in wallet) {
n++;
let x = wallet[curr];
@ -32,7 +44,7 @@ document.addEventListener('DOMContentLoaded', (e) => {
if (n != 0) {
let p = document.getElementById("content");
p.replaceChild(table, p.firstElementChild);
}
} */
});
document.getElementById("debug").addEventListener("click", (e) => {