swap out form to contenteditable cell

This commit is contained in:
Jethro Grassie 2020-01-05 04:33:56 -05:00
parent 595ddd934e
commit 01f3b34c4b
No known key found for this signature in database
GPG Key ID: DE8ED755616565BB
1 changed files with 27 additions and 22 deletions

View File

@ -22,9 +22,24 @@
td:last-child { td:last-child {
white-space: unset; white-space: unset;
} }
.wallet { .miner {
display: none; display: none;
} }
td.address {
min-width: 10ch;
max-width: 10ch;
overflow: hidden;
border-bottom: 1px dashed black;
text-overflow: ellipsis;
white-space: nowrap;
word-wrap: unset;
}
td.address:focus {
outline: 0px solid transparent;
text-overflow: initial;
white-space: initial;
word-wrap: break-word;
}
</style> </style>
</head> </head>
<body> <body>
@ -41,17 +56,9 @@
<tr><td>Pool port: </td><td id="pool_port"></td></tr> <tr><td>Pool port: </td><td id="pool_port"></td></tr>
<tr><td>Allow self-select: </td><td id="allow_self_select"></td></tr> <tr><td>Allow self-select: </td><td id="allow_self_select"></td></tr>
<tr><td>Miners connected: </td><td id="connected_miners"></td></tr> <tr><td>Miners connected: </td><td id="connected_miners"></td></tr>
<tr class="wallet"><td>Your HR: </td><td id="miner_hashrate"></td></tr> <tr class="miner"><td>Your HR: </td><td id="miner_hashrate"></td></tr>
<tr class="wallet"><td>Balance due: </td><td id="miner_balance"></td></tr> <tr class="miner"><td>Balance due: </td><td id="miner_balance"></td></tr>
<tr> <tr><td>Miner address: </td><td class="address" contenteditable="true"></td></tr>
<td>Miner address: </td>
<td>
<form>
<input type="text" id="wa" name="wa" />
<input type="submit" value="Submit" />
</form>
</td>
</tr>
</table> </table>
<small><a href="https://github.com/jtgrassie/monero-pool">https://github.com/jtgrassie/monero-pool</a></small> <small><a href="https://github.com/jtgrassie/monero-pool">https://github.com/jtgrassie/monero-pool</a></small>
<script> <script>
@ -96,8 +103,7 @@
return parseFloat(hr/1000000000).toFixed(2) + " GH/s"; return parseFloat(hr/1000000000).toFixed(2) + " GH/s";
} }
var f = document.querySelector("form"); var wf = document.querySelector(".address");
var wa = document.querySelector("#wa");
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.onload = function() xhr.onload = function()
@ -121,12 +127,11 @@
} }
}; };
f.onsubmit = function(e) wf.onblur = function(e)
{ {
e.preventDefault();
var d = new Date(); var d = new Date();
d.setTime(d.getTime() + (86400 * 365 * 1000)); d.setTime(d.getTime() + (86400 * 365 * 1000));
document.cookie = "wa=" + wa.value + ";expires=" + d.toGMTString(); document.cookie = "wa=" + this.innerText + ";expires=" + d.toGMTString();
window.location.reload(); window.location.reload();
return false; return false;
}; };
@ -135,13 +140,13 @@
{ {
if (/wa=[0-9a-fA-F]+/.test(document.cookie)) if (/wa=[0-9a-fA-F]+/.test(document.cookie))
{ {
var wh = document.querySelectorAll(".wallet"); var m = document.querySelectorAll(".miner");
wh.forEach(function(e) for (var i=0; i<m.length; i++)
{ {
e.style = "display: table-row;"; m[i].style = "display: table-row;";
}); }
var c = document.cookie.split("="); var c = document.cookie.split("=");
wa.value = c[1]; wf.innerText = c[1];
} }
var get_stats = function() var get_stats = function()
{ {