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
					
				@ -564,84 +564,90 @@
 | 
			
		||||
                        <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="ml-2 flex">
 | 
			
		||||
                              {% if w.cid == '1' %}
 | 
			
		||||
                              {# 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>
 | 
			
		||||
                              <script>
 | 
			
		||||
                                function setAmount(percent, balance, blindBalance, anonBalance) {
 | 
			
		||||
                                    var amountInput = document.getElementById('amount');
 | 
			
		||||
                                    var typeSelect = document.getElementById('withdraw_type');
 | 
			
		||||
                                    var selectedType = typeSelect.value;
 | 
			
		||||
                                    var floatBalance;
 | 
			
		||||
                                    var calculatedAmount;
 | 
			
		||||
 | 
			
		||||
                                    switch(selectedType) {
 | 
			
		||||
                                        case 'plain':
 | 
			
		||||
                                            floatBalance = parseFloat(balance);
 | 
			
		||||
                                            calculatedAmount = floatBalance * percent;
 | 
			
		||||
                                            break;
 | 
			
		||||
                                        case 'blind':
 | 
			
		||||
                                            floatBalance = parseFloat(blindBalance);
 | 
			
		||||
                                            calculatedAmount = floatBalance * percent;
 | 
			
		||||
                                            break;
 | 
			
		||||
                                        case 'anon':
 | 
			
		||||
                                            floatBalance = parseFloat(anonBalance);
 | 
			
		||||
                                            calculatedAmount = floatBalance * percent;
 | 
			
		||||
                                            break;
 | 
			
		||||
                                        default:
 | 
			
		||||
                                            floatBalance = parseFloat(balance);
 | 
			
		||||
                                            calculatedAmount = floatBalance * percent;
 | 
			
		||||
                                            break;
 | 
			
		||||
                                    }
 | 
			
		||||
 | 
			
		||||
                                    amountInput.value = calculatedAmount.toFixed(8);
 | 
			
		||||
                                }
 | 
			
		||||
                              </script>
 | 
			
		||||
                              {# / PART #}
 | 
			
		||||
                              {% elif w.cid == '3' %}
 | 
			
		||||
                              {# 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 }}', '{{ 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>
 | 
			
		||||
                              <script>
 | 
			
		||||
                                function setAmount(percent, balance, mwebBalance, selectedType) {
 | 
			
		||||
                                  var amountInput = document.getElementById('amount');
 | 
			
		||||
                                  var typeSelect = document.getElementById('withdraw_type');
 | 
			
		||||
                                  var selectedType = typeSelect.value;
 | 
			
		||||
                                  var floatBalance;
 | 
			
		||||
                                  var calculatedAmount;
 | 
			
		||||
 | 
			
		||||
                                  switch(selectedType) {
 | 
			
		||||
                                    case 'plain':
 | 
			
		||||
                                      floatBalance = parseFloat(balance);
 | 
			
		||||
                                      calculatedAmount = floatBalance * percent;
 | 
			
		||||
                                      break;
 | 
			
		||||
                                    case 'mweb':
 | 
			
		||||
                                      floatBalance = parseFloat(mwebBalance);
 | 
			
		||||
                                      calculatedAmount = floatBalance * percent;
 | 
			
		||||
                                      break;
 | 
			
		||||
                                    default:
 | 
			
		||||
                                      floatBalance = parseFloat(balance);
 | 
			
		||||
                                      calculatedAmount = floatBalance * percent;
 | 
			
		||||
                                      break;
 | 
			
		||||
                                  }
 | 
			
		||||
 | 
			
		||||
                                  amountInput.value = calculatedAmount.toFixed(8);
 | 
			
		||||
                                }
 | 
			
		||||
                              </script>
 | 
			
		||||
                              {# / LTC #}
 | 
			
		||||
                              {% 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 }}')">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>
 | 
			
		||||
{% if w.cid == '1' %}
 | 
			
		||||
{# 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.cid }}, '{{ 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.cid }}, '{{ 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.cid }}, '{{ w.blind_balance }}', '{{ w.anon_balance }}')">100%</button>
 | 
			
		||||
<script>
 | 
			
		||||
  function setAmount(percent, balance, cid) {
 | 
			
		||||
  function setAmount(percent, balance, cid, blindBalance, anonBalance) {
 | 
			
		||||
    var amountInput = document.getElementById('amount');
 | 
			
		||||
    var typeSelect = document.getElementById('withdraw_type');
 | 
			
		||||
    var selectedType = typeSelect.value;
 | 
			
		||||
    var floatBalance;
 | 
			
		||||
    var calculatedAmount;
 | 
			
		||||
 | 
			
		||||
    floatBalance = parseFloat(balance);
 | 
			
		||||
    switch(selectedType) {
 | 
			
		||||
      case 'plain':
 | 
			
		||||
        floatBalance = parseFloat(balance);
 | 
			
		||||
        break;
 | 
			
		||||
      case 'blind':
 | 
			
		||||
        floatBalance = parseFloat(blindBalance);
 | 
			
		||||
        break;
 | 
			
		||||
      case 'anon':
 | 
			
		||||
        floatBalance = parseFloat(anonBalance);
 | 
			
		||||
        break;
 | 
			
		||||
      default:
 | 
			
		||||
        floatBalance = parseFloat(balance);
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
    calculatedAmount = floatBalance * percent;
 | 
			
		||||
    amountInput.value = calculatedAmount.toFixed(8);
 | 
			
		||||
 | 
			
		||||
    var specialCids = [6, 9];
 | 
			
		||||
    var subfeeCheckbox = document.querySelector(`[name="subfee_${cid}"]`);
 | 
			
		||||
    if (subfeeCheckbox) {
 | 
			
		||||
      subfeeCheckbox.checked = (percent === 1);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
</script>
 | 
			
		||||
{# / PART #}
 | 
			
		||||
{% elif w.cid == '3' %}
 | 
			
		||||
{# 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 }}', {{ w.cid }}, '{{ w.mweb_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.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 typeSelect = document.getElementById('withdraw_type');
 | 
			
		||||
    var selectedType = typeSelect.value;
 | 
			
		||||
    var floatBalance;
 | 
			
		||||
    var calculatedAmount;
 | 
			
		||||
 | 
			
		||||
    if (specialCids.includes(cid) && percent === 1) {
 | 
			
		||||
    switch(selectedType) {
 | 
			
		||||
      case 'plain':
 | 
			
		||||
        floatBalance = parseFloat(balance);
 | 
			
		||||
        break;
 | 
			
		||||
      case 'mweb':
 | 
			
		||||
        floatBalance = parseFloat(mwebBalance);
 | 
			
		||||
        break;
 | 
			
		||||
      default:
 | 
			
		||||
        floatBalance = parseFloat(balance);
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
    calculatedAmount = floatBalance * percent;
 | 
			
		||||
    amountInput.value = calculatedAmount.toFixed(8);
 | 
			
		||||
 | 
			
		||||
    var subfeeCheckbox = document.querySelector(`[name="subfee_${cid}"]`);
 | 
			
		||||
    if (subfeeCheckbox) {
 | 
			
		||||
      subfeeCheckbox.checked = (percent === 1);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
</script>
 | 
			
		||||
{# / LTC #}
 | 
			
		||||
{% 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>
 | 
			
		||||
  function setAmount(percent, balance, cid) {
 | 
			
		||||
    var amountInput = document.getElementById('amount');
 | 
			
		||||
    var floatBalance = parseFloat(balance);
 | 
			
		||||
    var calculatedAmount = floatBalance * percent;
 | 
			
		||||
 | 
			
		||||
    const specialCids = [6, 9];
 | 
			
		||||
 | 
			
		||||
    if (specialCids.includes(parseInt(cid)) && percent === 1) {
 | 
			
		||||
        amountInput.setAttribute('data-hidden', 'true');
 | 
			
		||||
        amountInput.placeholder = 'Sweep All';
 | 
			
		||||
        amountInput.value = '';
 | 
			
		||||
@ -657,29 +663,40 @@
 | 
			
		||||
        amountInput.disabled = false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    var sweepAllCheckbox = document.getElementById('sweepall');
 | 
			
		||||
    let sweepAllCheckbox = document.getElementById('sweepall');
 | 
			
		||||
    if (sweepAllCheckbox) {
 | 
			
		||||
        if (specialCids.includes(cid) && percent === 1) {
 | 
			
		||||
        if (specialCids.includes(parseInt(cid)) && percent === 1) {
 | 
			
		||||
            sweepAllCheckbox.checked = true;
 | 
			
		||||
        } else {
 | 
			
		||||
            sweepAllCheckbox.checked = false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    let subfeeCheckbox = document.querySelector(`[name="subfee_${cid}"]`);
 | 
			
		||||
    if (subfeeCheckbox) {
 | 
			
		||||
        subfeeCheckbox.checked = (percent === 1);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
</script>
 | 
			
		||||
                              {% endif %}
 | 
			
		||||
                            </div>
 | 
			
		||||
                        </td>
 | 
			
		||||
                      </tr>
 | 
			
		||||
                      <tr class="opacity-100 text-gray-500 dark:text-gray-100">
 | 
			
		||||
                        {% if w.cid in '6, 9' %} {# XMR | WOW #}
 | 
			
		||||
                        <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"> <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 %}
 | 
			
		||||
                        <td>
 | 
			
		||||
                        </td>
 | 
			
		||||
                      </tr>
 | 
			
		||||
{% endif %}
 | 
			
		||||
</div>
 | 
			
		||||
 </td>
 | 
			
		||||
</tr>
 | 
			
		||||
<tr class="opacity-100 text-gray-500 dark:text-gray-100">
 | 
			
		||||
  {% if w.cid in [6, 9] %} {# XMR | WOW #}
 | 
			
		||||
  <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">
 | 
			
		||||
    <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 %}
 | 
			
		||||
  <td>
 | 
			
		||||
  </td>
 | 
			
		||||
</tr>
 | 
			
		||||
                      {% if w.cid == '1' %}
 | 
			
		||||
                      {# PART #}
 | 
			
		||||
                      <tr class="opacity-100 text-gray-500 dark:text-gray-100">
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user