aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/util.js
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-09-13 02:51:22 +0800
committerkumavis <aaron@kumavis.me>2017-09-13 02:51:22 +0800
commit114dae5f8070e47409a01981f2aeff96827cbf41 (patch)
treebe37b3fd47a9f95c27d812d1d97b3858fe64a469 /ui/app/util.js
parent8545453a9d58d7a54c10beef52e38107ed937117 (diff)
parentcafebb6417331d9d0a0a83fdc1cc4fdb04d0a5ec (diff)
downloadtangerine-wallet-browser-114dae5f8070e47409a01981f2aeff96827cbf41.tar
tangerine-wallet-browser-114dae5f8070e47409a01981f2aeff96827cbf41.tar.gz
tangerine-wallet-browser-114dae5f8070e47409a01981f2aeff96827cbf41.tar.bz2
tangerine-wallet-browser-114dae5f8070e47409a01981f2aeff96827cbf41.tar.lz
tangerine-wallet-browser-114dae5f8070e47409a01981f2aeff96827cbf41.tar.xz
tangerine-wallet-browser-114dae5f8070e47409a01981f2aeff96827cbf41.tar.zst
tangerine-wallet-browser-114dae5f8070e47409a01981f2aeff96827cbf41.zip
Merge branch 'master' of github.com:MetaMask/metamask-extension into filter-leak-fix3
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 ac3f42c6b..1368ebf11 100644
--- a/ui/app/util.js
+++ b/ui/app/util.js
@@ -36,6 +36,7 @@ module.exports = {
valueTable: valueTable,
bnTable: bnTable,
isHex: isHex,
+ exportAsFile: exportAsFile,
}
function valuesFor (obj) {
@@ -215,3 +216,18 @@ function readableDate (ms) {
function isHex (str) {
return Boolean(str.match(/^(0x)?[0-9a-fA-F]+$/))
}
+
+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)
+ }
+}