aboutsummaryrefslogtreecommitdiff
path: root/extension/popup
diff options
context:
space:
mode:
Diffstat (limited to 'extension/popup')
-rw-r--r--extension/popup/transactions.html1
-rw-r--r--extension/popup/transactions.js19
-rw-r--r--extension/popup/wallet.html1
-rw-r--r--extension/popup/wallet.js30
4 files changed, 24 insertions, 27 deletions
diff --git a/extension/popup/transactions.html b/extension/popup/transactions.html
index 2dc3fbea0..f51f64cf0 100644
--- a/extension/popup/transactions.html
+++ b/extension/popup/transactions.html
@@ -4,6 +4,7 @@
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="popup.css" type="text/css">
+ <script src="../lib/util.js" type="text/javascript"></script>
<script src="transactions.js" type="text/javascript"></script>
</head>
diff --git a/extension/popup/transactions.js b/extension/popup/transactions.js
index 7d38d3b36..fbd578114 100644
--- a/extension/popup/transactions.js
+++ b/extension/popup/transactions.js
@@ -1,22 +1,5 @@
'use strict';
-function format_date (date)
-{
- function pad (number) {
- if (number < 10) {
- return '0' + number;
- }
- return number;
- }
-
- return date.getUTCFullYear() +
- '-' + pad(date.getUTCMonth() + 1) +
- '-' + pad(date.getUTCDate()) +
- ' ' + pad(date.getUTCHours()) +
- ':' + pad(date.getUTCMinutes());
- //':' + pad(date.getUTCSeconds());
-}
-
function add_transaction (date, currency, amount, status, contract)
{
let table = document.getElementById('transactions-table');
@@ -26,7 +9,7 @@ function add_transaction (date, currency, amount, status, contract)
let td_date = document.createElement('td');
td_date.className = 'date';
- let text_date = document.createTextNode(format_date (date));
+ let text_date = document.createTextNode(date_format (date));
tr.appendChild(td_date).appendChild(text_date);
let td_amount = document.createElement('td');
diff --git a/extension/popup/wallet.html b/extension/popup/wallet.html
index a6864896b..42d72e676 100644
--- a/extension/popup/wallet.html
+++ b/extension/popup/wallet.html
@@ -4,6 +4,7 @@
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="popup.css" type="text/css">
+ <script src="../lib/util.js" type="text/javascript"></script>
<script src="wallet.js" type="text/javascript"></script>
</head>
diff --git a/extension/popup/wallet.js b/extension/popup/wallet.js
index cb7399dac..c148abc85 100644
--- a/extension/popup/wallet.js
+++ b/extension/popup/wallet.js
@@ -28,8 +28,13 @@ function select_currency (checkbox, currency, amount)
function add_currency (currency, amount)
{
+ let empty = document.getElementById('wallet-empty');
+ if (! /\bhidden\b/.test(empty.className))
+ empty.className += ' hidden';
+
let table = document.getElementById('wallet-table');
table.className = table.className.replace(/\bhidden\b/, '');
+
let tr = document.createElement('tr');
tr.id = 'wallet-table-'+ currency;
table.appendChild(tr);
@@ -73,13 +78,20 @@ function update_currency (currency, amount)
checkbox._amount = amount;
}
-document.addEventListener('DOMContentLoaded', function () {
- let empty = document.getElementById('wallet-empty');
+document.addEventListener(
+ 'DOMContentLoaded',
+ function () {
+ chrome.runtime.sendMessage({type: "WALLET_GET"}, function(wallet) {
+ for (let currency in wallet)
+ {
+ let amount = amount_format(wallet[currency]);
+ add_currency(currency, amount);
+ }
+ });
- // FIXME
- empty.className += ' hidden';
- add_currency('EUR', 42);
- add_currency('USD', 17);
- add_currency('KUD', 1337);
- update_currency('USD', 23);
-});
+ // FIXME: remove
+ add_currency('EUR', 42);
+ add_currency('USD', 17);
+ add_currency('KUD', 1337);
+ update_currency('USD', 23);
+ });