From 65143ac553866944240763d6aae4f99b66c044c8 Mon Sep 17 00:00:00 2001 From: Abhishek Sinha Date: Sat, 25 Aug 2018 20:39:19 +0530 Subject: [PATCH] download link added in seeding page --- public/js/funcs.js | 24 +++++++++++++++++++++--- routes.js | 2 +- views/magnetic.ejs | 19 ++++++++----------- views/seed.ejs | 13 ++++++++++++- 4 files changed, 42 insertions(+), 16 deletions(-) diff --git a/public/js/funcs.js b/public/js/funcs.js index 1dfa97f..afeb532 100644 --- a/public/js/funcs.js +++ b/public/js/funcs.js @@ -21,8 +21,26 @@ let getFloData = (tx) => { }) } - - +function saveAs(uri, filename) { + var link = document.createElement('a'); + if (typeof link.download === 'string') { + link.href = uri; + link.download = filename; + + //Firefox requires the link to be in the body + document.body.appendChild(link); + + //simulate click + link.click(); + + //remove the link when done + document.body.removeChild(link); + } else { + window.open(uri); + } + } + module.exports = { - getFloData + getFloData, + saveAs } \ No newline at end of file diff --git a/routes.js b/routes.js index 49c5b24..0007df9 100644 --- a/routes.js +++ b/routes.js @@ -71,7 +71,7 @@ router.post('/download-magnetic-uri', (req, res)=>{ var length = files.length // Stream each file to the disk files.forEach(function (file) { - console.log(file); + //console.log(file); let fullpath = path.resolve(file.path) diff --git a/views/magnetic.ejs b/views/magnetic.ejs index 0e5add5..3ef53ae 100644 --- a/views/magnetic.ejs +++ b/views/magnetic.ejs @@ -18,12 +18,6 @@ \ No newline at end of file