mirror of
https://github.com/basicswap/basicswap.git
synced 2025-02-02 03:06:30 +00:00
Fix wallet page
- Fixed "sweep all" checkbox on XMR and WOW if 100% is selected. - If 100% selected if will select Substract Fee checkbox from 100% amount. - Fixed if selected part/blind/anon and ltc/mweb with 10%/25%/100%.
This commit is contained in:
parent
94303cff93
commit
d93a73c29e
1 changed files with 102 additions and 85 deletions
|
@ -564,11 +564,13 @@
|
||||||
<td class="py-3 px-6">
|
<td class="py-3 px-6">
|
||||||
<div class="flex"> <input placeholder="{{ w.ticker }} Amount" class="hover:border-blue-500 bg-gray-50 text-gray-900 appearance-none pr-10 dark:bg-gray-500 dark:text-white border border-gray-300 dark:border-gray-400 dark:text-gray-50 dark:placeholder-gray-400 text-sm rounded-lg outline-none focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 focus:ring-0" type="text" id="amount" name="amt_{{ w.cid }}" value="{{ w.wd_value }}">
|
<div class="flex"> <input placeholder="{{ w.ticker }} Amount" class="hover:border-blue-500 bg-gray-50 text-gray-900 appearance-none pr-10 dark:bg-gray-500 dark:text-white border border-gray-300 dark:border-gray-400 dark:text-gray-50 dark:placeholder-gray-400 text-sm rounded-lg outline-none focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 focus:ring-0" type="text" id="amount" name="amt_{{ w.cid }}" value="{{ w.wd_value }}">
|
||||||
<div class="ml-2 flex">
|
<div class="ml-2 flex">
|
||||||
{% if w.cid == '1' %}
|
{% if w.cid == '1' %}
|
||||||
{# PART #}
|
{# PART #}
|
||||||
<button type="button" class="py-1 px-2 bg-blue-500 text-white text-sm rounded-md focus:outline-none" onclick="setAmount(0.25, '{{ w.balance }}', '{{ w.blind_balance }}', '{{ w.anon_balance }}')">25%</button> <button type="button" class="ml-2 py-1 px-2 bg-blue-500 text-white text-sm rounded-md focus:outline-none" onclick="setAmount(0.5, '{{ w.balance }}', '{{ w.blind_balance }}', '{{ w.anon_balance }}')">50%</button> <button type="button" class="ml-2 py-1 px-2 bg-blue-500 text-white text-sm rounded-md focus:outline-none" onclick="setAmount(1, '{{ w.balance }}', '{{ w.blind_balance }}', '{{ w.anon_balance }}')">100%</button>
|
<button type="button" class="py-1 px-2 bg-blue-500 text-white text-sm rounded-md focus:outline-none" onclick="setAmount(0.25, '{{ w.balance }}', {{ w.cid }}, '{{ w.blind_balance }}', '{{ w.anon_balance }}')">25%</button>
|
||||||
<script>
|
<button type="button" class="ml-2 py-1 px-2 bg-blue-500 text-white text-sm rounded-md focus:outline-none" onclick="setAmount(0.5, '{{ w.balance }}', {{ w.cid }}, '{{ w.blind_balance }}', '{{ w.anon_balance }}')">50%</button>
|
||||||
function setAmount(percent, balance, blindBalance, anonBalance) {
|
<button type="button" class="ml-2 py-1 px-2 bg-blue-500 text-white text-sm rounded-md focus:outline-none" onclick="setAmount(1, '{{ w.balance }}', {{ w.cid }}, '{{ w.blind_balance }}', '{{ w.anon_balance }}')">100%</button>
|
||||||
|
<script>
|
||||||
|
function setAmount(percent, balance, cid, blindBalance, anonBalance) {
|
||||||
var amountInput = document.getElementById('amount');
|
var amountInput = document.getElementById('amount');
|
||||||
var typeSelect = document.getElementById('withdraw_type');
|
var typeSelect = document.getElementById('withdraw_type');
|
||||||
var selectedType = typeSelect.value;
|
var selectedType = typeSelect.value;
|
||||||
|
@ -578,31 +580,34 @@
|
||||||
switch(selectedType) {
|
switch(selectedType) {
|
||||||
case 'plain':
|
case 'plain':
|
||||||
floatBalance = parseFloat(balance);
|
floatBalance = parseFloat(balance);
|
||||||
calculatedAmount = floatBalance * percent;
|
|
||||||
break;
|
break;
|
||||||
case 'blind':
|
case 'blind':
|
||||||
floatBalance = parseFloat(blindBalance);
|
floatBalance = parseFloat(blindBalance);
|
||||||
calculatedAmount = floatBalance * percent;
|
|
||||||
break;
|
break;
|
||||||
case 'anon':
|
case 'anon':
|
||||||
floatBalance = parseFloat(anonBalance);
|
floatBalance = parseFloat(anonBalance);
|
||||||
calculatedAmount = floatBalance * percent;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
floatBalance = parseFloat(balance);
|
floatBalance = parseFloat(balance);
|
||||||
calculatedAmount = floatBalance * percent;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
calculatedAmount = floatBalance * percent;
|
||||||
amountInput.value = calculatedAmount.toFixed(8);
|
amountInput.value = calculatedAmount.toFixed(8);
|
||||||
|
|
||||||
|
var subfeeCheckbox = document.querySelector(`[name="subfee_${cid}"]`);
|
||||||
|
if (subfeeCheckbox) {
|
||||||
|
subfeeCheckbox.checked = (percent === 1);
|
||||||
}
|
}
|
||||||
</script>
|
}
|
||||||
{# / PART #}
|
</script>
|
||||||
{% elif w.cid == '3' %}
|
{# / PART #}
|
||||||
{# LTC #}
|
{% elif w.cid == '3' %}
|
||||||
<button type="button" class="py-1 px-2 bg-blue-500 text-white text-sm rounded-md focus:outline-none" onclick="setAmount(0.25, '{{ w.balance }}', '{{ w.mweb_balance }}', 'mweb')">25%</button> <button type="button" class="ml-2 py-1 px-2 bg-blue-500 text-white text-sm rounded-md focus:outline-none" onclick="setAmount(0.5, '{{ w.balance }}', '{{ w.mweb_balance }}', 'mweb')">50%</button> <button type="button" class="ml-2 py-1 px-2 bg-blue-500 text-white text-sm rounded-md focus:outline-none" onclick="setAmount(1, '{{ w.balance }}', '{{ w.mweb_balance }}', 'mweb')">100%</button>
|
{# LTC #}
|
||||||
<script>
|
<button type="button" class="py-1 px-2 bg-blue-500 text-white text-sm rounded-md focus:outline-none" onclick="setAmount(0.25, '{{ w.balance }}', {{ w.cid }}, '{{ w.mweb_balance }}')">25%</button>
|
||||||
function setAmount(percent, balance, mwebBalance, selectedType) {
|
<button type="button" class="ml-2 py-1 px-2 bg-blue-500 text-white text-sm rounded-md focus:outline-none" onclick="setAmount(0.5, '{{ w.balance }}', {{ w.cid }}, '{{ w.mweb_balance }}')">50%</button>
|
||||||
|
<button type="button" class="ml-2 py-1 px-2 bg-blue-500 text-white text-sm rounded-md focus:outline-none" onclick="setAmount(1, '{{ w.balance }}', {{ w.cid }}, '{{ w.mweb_balance }}')">100%</button>
|
||||||
|
<script>
|
||||||
|
function setAmount(percent, balance, cid, mwebBalance) {
|
||||||
var amountInput = document.getElementById('amount');
|
var amountInput = document.getElementById('amount');
|
||||||
var typeSelect = document.getElementById('withdraw_type');
|
var typeSelect = document.getElementById('withdraw_type');
|
||||||
var selectedType = typeSelect.value;
|
var selectedType = typeSelect.value;
|
||||||
|
@ -612,36 +617,37 @@
|
||||||
switch(selectedType) {
|
switch(selectedType) {
|
||||||
case 'plain':
|
case 'plain':
|
||||||
floatBalance = parseFloat(balance);
|
floatBalance = parseFloat(balance);
|
||||||
calculatedAmount = floatBalance * percent;
|
|
||||||
break;
|
break;
|
||||||
case 'mweb':
|
case 'mweb':
|
||||||
floatBalance = parseFloat(mwebBalance);
|
floatBalance = parseFloat(mwebBalance);
|
||||||
calculatedAmount = floatBalance * percent;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
floatBalance = parseFloat(balance);
|
floatBalance = parseFloat(balance);
|
||||||
calculatedAmount = floatBalance * percent;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
calculatedAmount = floatBalance * percent;
|
||||||
amountInput.value = calculatedAmount.toFixed(8);
|
amountInput.value = calculatedAmount.toFixed(8);
|
||||||
|
|
||||||
|
var subfeeCheckbox = document.querySelector(`[name="subfee_${cid}"]`);
|
||||||
|
if (subfeeCheckbox) {
|
||||||
|
subfeeCheckbox.checked = (percent === 1);
|
||||||
}
|
}
|
||||||
</script>
|
}
|
||||||
{# / LTC #}
|
</script>
|
||||||
{% else %}
|
{# / LTC #}
|
||||||
<button type="button" class="py-1 px-2 bg-blue-500 text-white text-sm rounded-md focus:outline-none" onclick="setAmount(0.25, '{{ w.balance }}')">25%</button> <button type="button" class="ml-2 py-1 px-2 bg-blue-500 text-white text-sm rounded-md focus:outline-none" onclick="setAmount(0.5, '{{ w.balance }}')">50%</button> <button type="button" class="ml-2 py-1 px-2 bg-blue-500 text-white text-sm rounded-md focus:outline-none" onclick="setAmount(1, '{{ w.balance }}', '{{ w.cid }}')">100%</button>
|
{% else %}
|
||||||
|
<button type="button" class="py-1 px-2 bg-blue-500 text-white text-sm rounded-md focus:outline-none" onclick="setAmount(0.25, '{{ w.balance }}', {{ w.cid }})">25%</button>
|
||||||
|
<button type="button" class="ml-2 py-1 px-2 bg-blue-500 text-white text-sm rounded-md focus:outline-none" onclick="setAmount(0.5, '{{ w.balance }}', {{ w.cid }})">50%</button>
|
||||||
|
<button type="button" class="ml-2 py-1 px-2 bg-blue-500 text-white text-sm rounded-md focus:outline-none" onclick="setAmount(1, '{{ w.balance }}', {{ w.cid }})">100%</button>
|
||||||
<script>
|
<script>
|
||||||
function setAmount(percent, balance, cid) {
|
function setAmount(percent, balance, cid) {
|
||||||
var amountInput = document.getElementById('amount');
|
var amountInput = document.getElementById('amount');
|
||||||
var floatBalance;
|
var floatBalance = parseFloat(balance);
|
||||||
var calculatedAmount;
|
var calculatedAmount = floatBalance * percent;
|
||||||
|
|
||||||
floatBalance = parseFloat(balance);
|
const specialCids = [6, 9];
|
||||||
calculatedAmount = floatBalance * percent;
|
|
||||||
|
|
||||||
var specialCids = [6, 9];
|
if (specialCids.includes(parseInt(cid)) && percent === 1) {
|
||||||
|
|
||||||
if (specialCids.includes(cid) && percent === 1) {
|
|
||||||
amountInput.setAttribute('data-hidden', 'true');
|
amountInput.setAttribute('data-hidden', 'true');
|
||||||
amountInput.placeholder = 'Sweep All';
|
amountInput.placeholder = 'Sweep All';
|
||||||
amountInput.value = '';
|
amountInput.value = '';
|
||||||
|
@ -657,29 +663,40 @@
|
||||||
amountInput.disabled = false;
|
amountInput.disabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var sweepAllCheckbox = document.getElementById('sweepall');
|
let sweepAllCheckbox = document.getElementById('sweepall');
|
||||||
if (sweepAllCheckbox) {
|
if (sweepAllCheckbox) {
|
||||||
if (specialCids.includes(cid) && percent === 1) {
|
if (specialCids.includes(parseInt(cid)) && percent === 1) {
|
||||||
sweepAllCheckbox.checked = true;
|
sweepAllCheckbox.checked = true;
|
||||||
} else {
|
} else {
|
||||||
sweepAllCheckbox.checked = false;
|
sweepAllCheckbox.checked = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let subfeeCheckbox = document.querySelector(`[name="subfee_${cid}"]`);
|
||||||
|
if (subfeeCheckbox) {
|
||||||
|
subfeeCheckbox.checked = (percent === 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="opacity-100 text-gray-500 dark:text-gray-100">
|
<tr class="opacity-100 text-gray-500 dark:text-gray-100">
|
||||||
{% if w.cid in '6, 9' %} {# XMR | WOW #}
|
{% if w.cid in [6, 9] %} {# XMR | WOW #}
|
||||||
<td class="py-3 px-6 bold">Sweep All:</td>
|
<td class="py-3 px-6 bold">Sweep All:</td>
|
||||||
<td class="py-3 px-6"> <input class="hover:border-blue-500 w-5 h-5 form-check-input text-blue-600 bg-gray-50 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-1 dark:bg-gray-500 dark:border-gray-400" type="checkbox" id="sweepall" name="sweepall_{{ w.cid }}" {% if w.wd_sweepall==true %} checked=checked{% endif %}> </td> {% else %} <td class="py-3 px-6 bold">Subtract Fee:</td>
|
<td class="py-3 px-6">
|
||||||
<td class="py-3 px-6"> <input class="hover:border-blue-500 w-5 h-5 form-check-input text-blue-600 bg-gray-50 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-1 dark:bg-gray-500 dark:border-gray-400" type="checkbox" name="subfee_{{ w.cid }}" {% if w.wd_subfee==true %} checked=checked{% endif %}> </td>
|
<input class="hover:border-blue-500 w-5 h-5 form-check-input text-blue-600 bg-gray-50 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-1 dark:bg-gray-500 dark:border-gray-400" type="checkbox" id="sweepall" name="sweepall_{{ w.cid }}" {% if w.wd_sweepall==true %} checked=checked{% endif %}>
|
||||||
|
</td>
|
||||||
|
{% else %}
|
||||||
|
<td class="py-3 px-6 bold">Subtract Fee:</td>
|
||||||
|
<td class="py-3 px-6">
|
||||||
|
<input class="hover:border-blue-500 w-5 h-5 form-check-input text-blue-600 bg-gray-50 border-gray-300 rounded focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 focus:ring-1 dark:bg-gray-500 dark:border-gray-400" type="checkbox" name="subfee_{{ w.cid }}" {% if w.wd_subfee==true %} checked=checked{% endif %}>
|
||||||
|
</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td>
|
<td>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% if w.cid == '1' %}
|
{% if w.cid == '1' %}
|
||||||
{# PART #}
|
{# PART #}
|
||||||
<tr class="opacity-100 text-gray-500 dark:text-gray-100">
|
<tr class="opacity-100 text-gray-500 dark:text-gray-100">
|
||||||
|
|
Loading…
Reference in a new issue