diff --git a/lnbits/static/app.js b/lnbits/static/app.js index c5d1f50..dd88f14 100644 --- a/lnbits/static/app.js +++ b/lnbits/static/app.js @@ -105,7 +105,7 @@ function sendfundspaste() { function receive() { document.getElementById('receive').innerHTML = "<div class='modal fade receives' tabindex='-1' role='dialog' aria-labelledby='myLargeModalLabel' aria-hidden='true'>"+ - "<div class='modal-dialog' ><div id='QRCODE'><div class='modal-content' style='padding: 0 10px 0 10px;'>"+ + "<div class='modal-dialog' ><div id='QRCODE' ><div class='modal-content' style='padding: 0 10px 0 10px;'>"+ "<br/><center><input style='width:80%' type='number' class='form-control' id='amount' placeholder='Amount' max='1000000' required>" + "<input style='width:80%' type='text' class='form-control' id='memo' placeholder='Memo' required></center></div>" + "<div class='modal-footer'>"+ @@ -416,3 +416,52 @@ if (transactions.length) { if (wallet) { postAjax('/v1/checkpending', '', wallet.adminkey, function(data) {}) } + + +function download_csv(csv, filename) { + var csvFile; + var downloadLink; + + // CSV FILE + csvFile = new Blob([csv], {type: "text/csv"}); + + // Download link + downloadLink = document.createElement("a"); + + // File name + downloadLink.download = filename; + + // We have to create a link to the file + downloadLink.href = window.URL.createObjectURL(csvFile); + + // Make sure that the link is not displayed + downloadLink.style.display = "none"; + + // Add the link to your DOM + document.body.appendChild(downloadLink); + + // Lanzamos + downloadLink.click(); +} + +function export_table_to_csv(html, filename) { + var csv = []; + var rows = document.querySelectorAll("table tr"); + + for (var i = 0; i < rows.length; i++) { + var row = [], cols = rows[i].querySelectorAll("td, th"); + + for (var j = 0; j < cols.length; j++) + row.push(cols[j].innerText); + + csv.push(row.join(",")); + } + + // Download CSV + download_csv(csv.join("\n"), filename); +} + +function exportbut(){ + var html = document.querySelector("table").outerHTML; + export_table_to_csv(html, "table.csv"); +}