walletsBalance.sh: Export in HTML page
This commit is contained in:
parent
bb00097c93
commit
8f085e0e52
|
@ -23,9 +23,11 @@ work() {
|
||||||
if [[ $1 == "members" ]]; then
|
if [[ $1 == "members" ]]; then
|
||||||
username=$(curl -m 20 -s $DUNITER/wot/members | jq -r --arg pubkey "$i" '.results[] | select(.pubkey==$pubkey) | .uid')
|
username=$(curl -m 20 -s $DUNITER/wot/members | jq -r --arg pubkey "$i" '.results[] | select(.pubkey==$pubkey) | .uid')
|
||||||
formatedBalance=$(printf "%-10s | %-45s | %-1s" $balance $i $username)
|
formatedBalance=$(printf "%-10s | %-45s | %-1s" $balance $i $username)
|
||||||
|
htmlBloc="$htmlBloc"$'\n'"<tr><td>$balance</td><td>$i</td><td>$username</td></tr>"
|
||||||
unset username
|
unset username
|
||||||
else
|
else
|
||||||
formatedBalance=$(printf "%-10s | %-45s" $balance $i)
|
formatedBalance=$(printf "%-10s | %-45s" $balance $i)
|
||||||
|
htmlBloc="$htmlBloc"$'\n'"<tr><td>$balance</td><td>$i</td><td> </td></tr>"
|
||||||
fi
|
fi
|
||||||
unset balance
|
unset balance
|
||||||
|
|
||||||
|
@ -49,3 +51,12 @@ work && unset wallets
|
||||||
totalBalance=$(sort -nr <<<$totalBalance)
|
totalBalance=$(sort -nr <<<$totalBalance)
|
||||||
[[ ! -d $GPATH/db ]] && mkdir $GPATH/db
|
[[ ! -d $GPATH/db ]] && mkdir $GPATH/db
|
||||||
grep . <<<"$totalBalance" > $GPATH/db/wallets_balance.txt && rm /tmp/balance-g1.txt
|
grep . <<<"$totalBalance" > $GPATH/db/wallets_balance.txt && rm /tmp/balance-g1.txt
|
||||||
|
|
||||||
|
# Construct HTML
|
||||||
|
cp $GPATH/tpl/css/wallets_balance.css $WEBPATH/css/
|
||||||
|
cp $GPATH/tpl/js/wallets_balance.js $WEBPATH/js/
|
||||||
|
cp $GPATH/tpl/wallets_balance.html $WEBPATH/data/wallets_balance.html
|
||||||
|
|
||||||
|
echo "$htmlBloc" > /tmp/solde_g1_html.txt
|
||||||
|
printf '%s\n' '/_LINE/r /tmp/solde_g1_html.txt' 1 '/_LINE/d' w | ed $WEBPATH/data/wallets_balance.html > /dev/null
|
||||||
|
rm /tmp/solde_g1_html.txt
|
|
@ -0,0 +1,39 @@
|
||||||
|
#pseudo, #key {
|
||||||
|
background-position: 10px 12px; /* Position the search icon */
|
||||||
|
background-repeat: no-repeat; /* Do not repeat the icon image */
|
||||||
|
width: 300px; /* Full-width */
|
||||||
|
font-size: 16px; /* Increase font-size */
|
||||||
|
padding: 12px 20px 12px 20px; /* Add some padding */
|
||||||
|
border: 1px solid #ddd; /* Add a grey border */
|
||||||
|
margin-bottom: 12px; /* Add some space below the input */
|
||||||
|
}
|
||||||
|
|
||||||
|
#soldes {
|
||||||
|
border-collapse: collapse; /* Collapse borders */
|
||||||
|
width: 50%; /* Full-width */
|
||||||
|
border: 1px solid #ddd; /* Add a grey border */
|
||||||
|
font-size: 16px; /* Increase font-size */
|
||||||
|
}
|
||||||
|
|
||||||
|
#soldes th, #soldes td {
|
||||||
|
text-align: left; /* Left-align text */
|
||||||
|
padding: 8px; /* Add padding */
|
||||||
|
}
|
||||||
|
|
||||||
|
#soldes tr {
|
||||||
|
/* Add a bottom border to all table rows */
|
||||||
|
border-bottom: 1px solid #ddd;
|
||||||
|
}
|
||||||
|
|
||||||
|
#soldes tr:hover {
|
||||||
|
/* Add a grey background color to the table header and on hover */
|
||||||
|
background-color: #f1f1f1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#soldes th {
|
||||||
|
/* Add a grey background color to the table header and on hover */
|
||||||
|
background-color: #ddd;
|
||||||
|
cursor: pointer;
|
||||||
|
position: sticky;
|
||||||
|
top: 0px;
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
|
||||||
|
const getCellValue = (tr, idx) => tr.children[idx].innerText || tr.children[idx].textContent;
|
||||||
|
|
||||||
|
const comparer = (idx, asc) => (a, b) => ((v1, v2) =>
|
||||||
|
v1 !== '' && v2 !== '' && !isNaN(v1) && !isNaN(v2) ? v1 - v2 : v1.toString().localeCompare(v2)
|
||||||
|
)(getCellValue(asc ? a : b, idx), getCellValue(asc ? b : a, idx));
|
||||||
|
|
||||||
|
// Sort work
|
||||||
|
document.querySelectorAll('th').forEach(th => th.addEventListener('click', (() => {
|
||||||
|
const table = th.closest('table');
|
||||||
|
Array.from(table.querySelectorAll('tr:nth-child(n+2)'))
|
||||||
|
.sort(comparer(Array.from(th.parentNode.children).indexOf(th), this.asc = !this.asc))
|
||||||
|
.forEach(tr => table.appendChild(tr) );
|
||||||
|
})));
|
||||||
|
|
||||||
|
// Search
|
||||||
|
function recherche(select) {
|
||||||
|
// Declare variables
|
||||||
|
var input, filter, table, tr, td, i, txtValue;
|
||||||
|
input = document.getElementById(select);
|
||||||
|
filter = input.value.toUpperCase();
|
||||||
|
table = document.getElementById("soldes");
|
||||||
|
tr = table.getElementsByTagName("tr");
|
||||||
|
th = table.getElementsByTagName("th");
|
||||||
|
|
||||||
|
// Loop through all table rows, and hide those who don't match the search query
|
||||||
|
for (i = 0; i < tr.length; i++) {
|
||||||
|
if (select == "pseudo") { td = tr[i].getElementsByTagName("td")[2]; }
|
||||||
|
else if (select == "key") { td = tr[i].getElementsByTagName("td")[1]; }
|
||||||
|
|
||||||
|
if (td) {
|
||||||
|
txtValue = td.textContent || td.innerText;
|
||||||
|
if (txtValue.toUpperCase().indexOf(filter) > -1) {
|
||||||
|
tr[i].style.display = "";
|
||||||
|
} else {
|
||||||
|
tr[i].style.display = "none";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<link rel="stylesheet" href="../css/wallets_balance.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<input type="text" id="pseudo" onkeyup="recherche('pseudo')" placeholder="Rechercher un pseudo...">
|
||||||
|
<input type="text" id="key" onkeyup="recherche('key')" placeholder="Rechercher une clé publique...">
|
||||||
|
|
||||||
|
<table id="soldes (Ḡ1)">
|
||||||
|
<tr><th>Solde</th><th>Clé publique</th><th>Pseudo</th></tr>
|
||||||
|
_LINE
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<script type="text/javascript" src="../js/wallets_balance.js"></script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue