diff options
author | tg(x) <*@tg-x.net> | 2015-12-03 20:07:03 +0100 |
---|---|---|
committer | tg(x) <*@tg-x.net> | 2015-12-03 20:07:03 +0100 |
commit | 5243a707260af9de820ad02b1972d3280164cf19 (patch) | |
tree | 46e6918fca8edfeddb919b7a89307328390a0ec1 /extension/popup/transactions.js | |
parent | 7b6706bee3cbecc84b330672ecdb5764d7d68756 (diff) |
webext popup
Diffstat (limited to 'extension/popup/transactions.js')
-rw-r--r-- | extension/popup/transactions.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/extension/popup/transactions.js b/extension/popup/transactions.js new file mode 100644 index 000000000..7d38d3b36 --- /dev/null +++ b/extension/popup/transactions.js @@ -0,0 +1,56 @@ +'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'); + table.className = table.className.replace(/\bhidden\b/, ''); + let tr = document.createElement('tr'); + table.appendChild(tr); + + let td_date = document.createElement('td'); + td_date.className = 'date'; + let text_date = document.createTextNode(format_date (date)); + tr.appendChild(td_date).appendChild(text_date); + + let td_amount = document.createElement('td'); + td_amount.className = 'amount'; + let text_amount = document.createTextNode(amount +' '+ currency); + tr.appendChild(td_amount).appendChild(text_amount); + + let td_status = document.createElement('td'); + td_status.className = 'status'; + let text_status = document.createTextNode(status); + tr.appendChild(td_status).appendChild(text_status); + + let td_contract = document.createElement('td'); + td_contract.className = 'contract'; + let btn_contract = document.createElement('button'); + btn_contract.appendChild(document.createTextNode('Contract')); + tr.appendChild(td_contract).appendChild(btn_contract); +} + +document.addEventListener('DOMContentLoaded', function () { + let no = document.getElementById('no-transactions'); + + // FIXME + no.className += ' hidden'; + add_transaction (new Date('2015-12-21 13:37'), 'EUR', 42, 'Completed', {}); + add_transaction (new Date('2015-12-22 10:01'), 'USD', 23, 'Pending', {}); +}); |