aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/util.js
diff options
context:
space:
mode:
authorChi Kei Chan <chikeichan@gmail.com>2017-09-19 02:38:39 +0800
committerGitHub <noreply@github.com>2017-09-19 02:38:39 +0800
commita190bb60437e2edcdf7b9be39e69f2d34f2b0957 (patch)
tree64d0547165cbed1af2df5eec1d856c6c1847448d /ui/app/util.js
parent54bbf8d8590014b92e7857f30bdc2d8f3779431a (diff)
parent162a3827c7ba418ce8180d81c54ad09d9b9560b8 (diff)
downloadtangerine-wallet-browser-a190bb60437e2edcdf7b9be39e69f2d34f2b0957.tar
tangerine-wallet-browser-a190bb60437e2edcdf7b9be39e69f2d34f2b0957.tar.gz
tangerine-wallet-browser-a190bb60437e2edcdf7b9be39e69f2d34f2b0957.tar.bz2
tangerine-wallet-browser-a190bb60437e2edcdf7b9be39e69f2d34f2b0957.tar.lz
tangerine-wallet-browser-a190bb60437e2edcdf7b9be39e69f2d34f2b0957.tar.xz
tangerine-wallet-browser-a190bb60437e2edcdf7b9be39e69f2d34f2b0957.tar.zst
tangerine-wallet-browser-a190bb60437e2edcdf7b9be39e69f2d34f2b0957.zip
Merge pull request #2116 from chikeichan/nm
[NewUI] Fix merge conflict with latest master
Diffstat (limited to 'ui/app/util.js')
-rw-r--r--ui/app/util.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/ui/app/util.js b/ui/app/util.js
index 6596ebafb..be26e15a5 100644
--- a/ui/app/util.js
+++ b/ui/app/util.js
@@ -53,6 +53,7 @@ module.exports = {
getTxFeeBn,
shortenBalance,
getContractAtAddress,
+ exportAsFile: exportAsFile,
}
function valuesFor (obj) {
@@ -250,3 +251,18 @@ function getTxFeeBn (gas, gasPrice = MIN_GAS_PRICE_BN.toString(16), blockGasLimi
function getContractAtAddress (tokenAddress) {
return global.eth.contract(abi).at(tokenAddress)
}
+
+function exportAsFile (filename, data) {
+ // source: https://stackoverflow.com/a/33542499 by Ludovic Feltz
+ const blob = new Blob([data], {type: 'text/csv'})
+ if (window.navigator.msSaveOrOpenBlob) {
+ window.navigator.msSaveBlob(blob, filename)
+ } else {
+ const elem = window.document.createElement('a')
+ elem.href = window.URL.createObjectURL(blob)
+ elem.download = filename
+ document.body.appendChild(elem)
+ elem.click()
+ document.body.removeChild(elem)
+ }
+}