ui/update: Bug fixes, Added Coin Price Lookup Table (Offer new page) + Update github readme header GFX.

2024-05-20_merge
gerlofvanek 2 years ago
parent 5536c82ded
commit e67ca94dfb
  1. BIN
      .github-readme/basicswap_header.jpg
  2. 2
      basicswap/static/js/coin_icons.js
  3. 2
      basicswap/templates/active.html
  4. 2
      basicswap/templates/header.html
  5. 20
      basicswap/templates/offer_confirm.html
  6. 167
      basicswap/templates/offer_new_1.html
  7. 19
      basicswap/templates/offer_new_2.html
  8. 17
      basicswap/templates/offers.html
  9. 8
      basicswap/ui/page_offers.py

Binary file not shown.

Before

Width:  |  Height:  |  Size: 204 KiB

After

Width:  |  Height:  |  Size: 230 KiB

@ -14,7 +14,7 @@ function updateSelectCache(select) {
function setSelectData(select) { function setSelectData(select) {
const selectedOption = select.options[select.selectedIndex]; const selectedOption = select.options[select.selectedIndex];
const image = selectedOption.getAttribute('data-image') || 'https://dummyimage.com/20x20/000/fff'; // set a default image URL const image = selectedOption.getAttribute('data-image') || '/static/images/other/coin.png'; // set a default image URL
const name = selectedOption.textContent.trim(); const name = selectedOption.textContent.trim();
if (image) { if (image) {
select.style.backgroundImage = `url(${image})`; select.style.backgroundImage = `url(${image})`;

@ -111,7 +111,7 @@
<td class="py-3 px-6 monospace"> <td class="py-3 px-6 monospace">
<a href=/offer/{{ s[1] }}>{{ s[1] }}</a> <a href=/offer/{{ s[1] }}>{{ s[1] }}</a>
</td> </td>
<td class="py-3 px-6">{{ s[2] }}</td> <td class="py-3 px-6 w-52 whitespace-normal break-words">{{ s[2] }}</td>
<td class="py-3 px-6">{{ s[3] }}</td> <td class="py-3 px-6">{{ s[3] }}</td>
<td class="py-3 px-6">{{ s[4] }}</td> <td class="py-3 px-6">{{ s[4] }}</td>
</tr> </tr>

@ -412,7 +412,7 @@
<button data-tooltip-target="tooltip-darkmode" id="theme-toggle" type="button" class="text-gray-500 dark:text-gray-400 focus:outline-none rounded-lg text-sm ml-5"> <button data-tooltip-target="tooltip-darkmode" id="theme-toggle" type="button" class="text-gray-500 dark:text-gray-400 focus:outline-none rounded-lg text-sm ml-5">
<svg id="theme-toggle-dark-icon" class="hidden w-5 h-5" fill="#F59E0B" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M17.293 13.293A8 8 0 016.707 2.707a8.001 8.001 0 1010.586 10.586z"></path></svg> <svg id="theme-toggle-dark-icon" class="hidden w-5 h-5" fill="#F59E0B" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M17.293 13.293A8 8 0 016.707 2.707a8.001 8.001 0 1010.586 10.586z"></path></svg>
<svg id="theme-toggle-light-icon" class="hidden w-5 h-5" fill="#F59E0B" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10 2a1 1 0 011 1v1a1 1 0 11-2 0V3a1 1 0 011-1zm4 8a4 4 0 11-8 0 4 4 0 018 0zm-.464 4.95l.707.707a1 1 0 001.414-1.414l-.707-.707a1 1 0 00-1.414 1.414zm2.12-10.607a1 1 0 010 1.414l-.706.707a1 1 0 11-1.414-1.414l.707-.707a1 1 0 011.414 0zM17 11a1 1 0 100-2h-1a1 1 0 100 2h1zm-7 4a1 1 0 011 1v1a1 1 0 11-2 0v-1a1 1 0 011-1zM5.05 6.464A1 1 0 106.465 5.05l-.708-.707a1 1 0 00-1.414 1.414l.707.707zm1.414 8.486l-.707.707a1 1 0 01-1.414-1.414l.707-.707a1 1 0 011.414 1.414zM4 11a1 1 0 100-2H3a1 1 0 000 2h1z" fill-rule="evenodd" clip-rule="evenodd"></path></svg> <svg id="theme-toggle-light-icon" class="hidden w-5 h-5" fill="#F59E0B" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10 2a1 1 0 011 1v1a1 1 0 11-2 0V3a1 1 0 011-1zm4 8a4 4 0 11-8 0 4 4 0 018 0zm-.464 4.95l.707.707a1 1 0 001.414-1.414l-.707-.707a1 1 0 00-1.414 1.414zm2.12-10.607a1 1 0 010 1.414l-.706.707a1 1 0 11-1.414-1.414l.707-.707a1 1 0 011.414 0zM17 11a1 1 0 100-2h-1a1 1 0 100 2h1zm-7 4a1 1 0 011 1v1a1 1 0 11-2 0v-1a1 1 0 011-1zM5.05 6.464A1 1 0 106.465 5.05l-.708-.707a1 1 0 00-1.414 1.414l.707.707zm1.414 8.486l-.707.707a1 1 0 01-1.414-1.414l.707-.707a1 1 0 011.414 1.414zM4 11a1 1 0 100-2H3a1 1 0 000 2h1z" fill-rule="evenodd" clip-rule="evenodd"></path></svg>
<span data-tooltip-target="tooltip-TOR"></span> <span data-tooltip-target="tooltip-darkmode"></span>
<div class="tooltip-arrow" data-popper-arrow></div> <div class="tooltip-arrow" data-popper-arrow></div>
<div id="tooltip-darkmode" role="tooltip" class="inline-block absolute invisible z-10 py-2 px-3 text-sm font-medium text-white bg-blue-500 rounded-lg shadow-sm opacity-0 transition-opacity duration-300 tooltip">Dark mode</div> <div id="tooltip-darkmode" role="tooltip" class="inline-block absolute invisible z-10 py-2 px-3 text-sm font-medium text-white bg-blue-500 rounded-lg shadow-sm opacity-0 transition-opacity duration-300 tooltip">Dark mode</div>
</button> </button>

@ -668,12 +668,6 @@
<div class="flex flex-wrap justify-end"> <div class="flex flex-wrap justify-end">
<div class="w-full md:w-auto p-1.5"> <div class="w-full md:w-auto p-1.5">
<button name="step2" type="submit" value="Back" class="flex flex-wrap justify-center w-full px-4 py-2.5 font-medium text-sm text-coolGray-500 hover:text-coolGray-600 border border-coolGray-200 hover:border-coolGray-300 bg-white rounded-md focus:ring-0 focus:outline-none dark:text-white dark:hover:text-white dark:bg-gray-600 dark:hover:bg-gray-700 dark:border-gray-600 dark:hover:border-gray-600"> <button name="step2" type="submit" value="Back" class="flex flex-wrap justify-center w-full px-4 py-2.5 font-medium text-sm text-coolGray-500 hover:text-coolGray-600 border border-coolGray-200 hover:border-coolGray-300 bg-white rounded-md focus:ring-0 focus:outline-none dark:text-white dark:hover:text-white dark:bg-gray-600 dark:hover:bg-gray-700 dark:border-gray-600 dark:hover:border-gray-600">
<svg class="mr-2" xmlns="http://www.w3.org/2000/svg" height="20" width="20" viewBox="0 0 24 24">
<g stroke-linecap="round" stroke-width="2" fill="none" stroke="#ffffff" stroke-linejoin="round">
<circle cx="12" cy="12" r="11"></circle>
<polyline points="13 16 9 12 13 8" stroke="#ffffff"></polyline>
</g>
</svg>
</svg> </svg>
<span>Back</span> <span>Back</span>
</button> </button>
@ -698,26 +692,26 @@
</div> </div>
</div> </div>
</section> </section>
<script> <script>
const selects = document.querySelectorAll('select.disabled-select'); const selects = document.querySelectorAll('select.disabled-select');
for (const select of selects) { for (const select of selects) {
if (select.disabled) { if (select.disabled) {
select.classList.add('disabled-select-enabled'); select.classList.add('disabled-select-enabled');
} else { } else {
select.classList.remove('disabled-select-enabled'); select.classList.remove('disabled-select-enabled');
} }
} }
</script> </script>
<script> <script>
const inputs = document.querySelectorAll('input.disabled-input, input[type="checkbox"].disabled-input'); const inputs = document.querySelectorAll('input.disabled-input, input[type="checkbox"].disabled-input');
for (const input of inputs) { for (const input of inputs) {
if (input.readOnly) { if (input.readOnly) {
input.classList.add('disabled-input-enabled'); input.classList.add('disabled-input-enabled');
} else { } else {
input.classList.remove('disabled-input-enabled'); input.classList.remove('disabled-input-enabled');
} }
} }
</script> </script>
<style> <style>
.disabled-input-enabled { .disabled-input-enabled {

@ -252,9 +252,10 @@
<path d="M11.3333 6.1133C11.2084 5.98913 11.0395 5.91943 10.8633 5.91943C10.6872 5.91943 10.5182 5.98913 10.3933 6.1133L8.00001 8.47329L5.64001 6.1133C5.5151 5.98913 5.34613 5.91943 5.17001 5.91943C4.99388 5.91943 4.82491 5.98913 4.70001 6.1133C4.63752 6.17527 4.58792 6.249 4.55408 6.33024C4.52023 6.41148 4.50281 6.49862 4.50281 6.58663C4.50281 6.67464 4.52023 6.76177 4.55408 6.84301C4.58792 6.92425 4.63752 6.99799 4.70001 7.05996L7.52667 9.88663C7.58865 9.94911 7.66238 9.99871 7.74362 10.0326C7.82486 10.0664 7.912 10.0838 8.00001 10.0838C8.08801 10.0838 8.17515 10.0664 8.25639 10.0326C8.33763 9.99871 8.41136 9.94911 8.47334 9.88663L11.3333 7.05996C11.3958 6.99799 11.4454 6.92425 11.4793 6.84301C11.5131 6.76177 11.5305 6.67464 11.5305 6.58663C11.5305 6.49862 11.5131 6.41148 11.4793 6.33024C11.4454 6.249 11.3958 6.17527 11.3333 6.1133Z" fill="#8896AB"></path> <path d="M11.3333 6.1133C11.2084 5.98913 11.0395 5.91943 10.8633 5.91943C10.6872 5.91943 10.5182 5.98913 10.3933 6.1133L8.00001 8.47329L5.64001 6.1133C5.5151 5.98913 5.34613 5.91943 5.17001 5.91943C4.99388 5.91943 4.82491 5.98913 4.70001 6.1133C4.63752 6.17527 4.58792 6.249 4.55408 6.33024C4.52023 6.41148 4.50281 6.49862 4.50281 6.58663C4.50281 6.67464 4.52023 6.76177 4.55408 6.84301C4.58792 6.92425 4.63752 6.99799 4.70001 7.05996L7.52667 9.88663C7.58865 9.94911 7.66238 9.99871 7.74362 10.0326C7.82486 10.0664 7.912 10.0838 8.00001 10.0838C8.08801 10.0838 8.17515 10.0664 8.25639 10.0326C8.33763 9.99871 8.41136 9.94911 8.47334 9.88663L11.3333 7.05996C11.3958 6.99799 11.4454 6.92425 11.4793 6.84301C11.5131 6.76177 11.5305 6.67464 11.5305 6.58663C11.5305 6.49862 11.5131 6.41148 11.4793 6.33024C11.4454 6.249 11.3958 6.17527 11.3333 6.1133Z" fill="#8896AB"></path>
</svg> </svg>
<select class="select hover:border-blue-500 pl-10 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"" id="coin_to" name="coin_to" onchange="set_rate('coin_to');"> <select class="select hover:border-blue-500 pl-10 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"" id="coin_to" name="coin_to" onchange="set_rate('coin_to');">
<option class="no-space" value="-1">Select coin you get</option> <option value="-1">Select coin you get</option>
{% for c in coins %} {% for c in coins %}
<option{% if data.coin_to==c[0] %} selected{% endif %} value="{{ c[0] }}" data-image="/static/images/coins/{{ c[1]|replace(" ", "-") }}-20.png">{{ c[1] }}</option>{% endfor %} <option{% if data.coin_to==c[0] %} selected{% endif %} value="{{ c[0] }}" data-image="/static/images/coins/{{ c[1]|replace(" ", "-") }}-20.png">{{ c[1] }}</option>
{% endfor %}
</select> </select>
<div class="select-dropdown"> <div class="select-dropdown">
<img class="select-icon" src="" alt=""> <img class="select-icon" src="" alt="">
@ -354,15 +355,48 @@
</div> </div>
</div> </div>
</div> </div>
<div class="py-3 border-b items-center justify-between -mx-4 mb-6 pb-6 border-gray-400 border-opacity-20"> <div class="pricejsonhidden hidden py-3 border-b items-center justify-between -mx-4 mb-6 pb-6 border-gray-400 border-opacity-20">
<div class="w-full md:w-10/12"> <div class="w-full md:w-10/12">
<div class="flex flex-wrap -m-3 w-full sm:w-auto px-4 mb-6 sm:mb-0"> <div class="flex flex-wrap -m-3 w-full sm:w-auto px-4 mb-6 sm:mb-0">
<div class="w-full md:w-1/3 p-3"> <div class="w-full md:w-1/3 p-3">
<p class="text-sm text-coolGray-800 dark:text-white font-semibold">Rates</p> <p class="text-sm text-coolGray-800 dark:text-white font-semibold">Coin Prices/Rates (JSON)</p>
</div> </div>
<div class="w-full md:flex-1 p-3 dark:text-white text-sm monospace"> <div class="w-full md:flex-1 p-3 dark:text-white text-sm monospace">
<p id="rates_display"></p> <p id="rates_display"></p>
<!-- todo adjust font-size --> </div>
</div>
</div>
</div>
<div class="pricetablehidden hidden py-3 border-b items-center justify-between -mx-4 mb-6 pb-6 border-gray-400 border-opacity-20">
<div class="w-full md:w-10/12">
<div class="flex flex-wrap -m-3 w-full sm:w-auto px-4 mb-6 sm:mb-0">
<div class="w-full md:w-1/3 p-3">
<p class="text-sm text-coolGray-800 dark:text-white font-semibold">Coin Prices/Rates (Table)</p>
</div>
<div class="w-full md:flex-1 p-3 dark:text-white text-sm">
<table id="priceTable" class="hidden w-full min-w-max text-sm">
<thead class="uppercase">
<tr class="text-left">
<th class="p-0">
<div class="py-3 px-6 rounded-tl-xl bg-coolGray-200 dark:bg-gray-600">
<span class="text-xs text-gray-600 dark:text-gray-300 font-semibold">Coin</span>
</div>
</th>
<th class="p-0">
<div class="py-3 bg-coolGray-200 dark:bg-gray-600">
<span class="text-xs text-gray-600 dark:text-gray-300 font-semibold">Price in USD</span>
</div>
</th>
<th class="p-0">
<div class="py-3 rounded-tr-xl bg-coolGray-200 dark:bg-gray-600">
<span class="text-xs text-gray-600 dark:text-gray-300 font-semibold">Price in BTC (Rate)</span>
</div>
</th>
</tr>
</thead>
<tbody id="priceTableBody" class="text-gray-700">
</tbody>
</table>
</div> </div>
</div> </div>
</div> </div>
@ -381,8 +415,15 @@
<div class="flex flex-wrap justify-end"> <div class="flex flex-wrap justify-end">
<!--<div class="w-full md:w-auto p-1.5"><button name="show_rates_table" type="button" value="Show Rates Table" onclick='lookup_rates_table();' class="flex flex-wrap justify-center w-full px-4 py-2.5 font-medium text-sm text-coolGray-500 hover:text-coolGray-600 border border-coolGray-200 hover:border-coolGray-300 bg-white rounded-md shadow-button focus:ring-0 focus:outline-none"><svg class="mr-2" <!--<div class="w-full md:w-auto p-1.5"><button name="show_rates_table" type="button" value="Show Rates Table" onclick='lookup_rates_table();' class="flex flex-wrap justify-center w-full px-4 py-2.5 font-medium text-sm text-coolGray-500 hover:text-coolGray-600 border border-coolGray-200 hover:border-coolGray-300 bg-white rounded-md shadow-button focus:ring-0 focus:outline-none"><svg class="mr-2"
xmlns="http://www.w3.org/2000/svg" height="20" width="20" viewBox="0 0 24 24"><g fill="#556987"><path fill="#556987" d="M12,3c1.989,0,3.873,0.65,5.43,1.833l-3.604,3.393l9.167,0.983L22.562,0l-3.655,3.442 C16.957,1.862,14.545,1,12,1C5.935,1,1,5.935,1,12h2C3,7.037,7.037,3,12,3z"></path><path data-color="#556987" d="M12,21c-1.989,0-3.873-0.65-5.43-1.833l3.604-3.393l-9.167-0.983L1.438,24l3.655-3.442 C7.043,22.138,9.455,23,12,23c6.065,0,11-4.935,11-11h-2C21,16.963,16.963,21,12,21z"></path></g></svg><span>Show Rates Table</span></button></div>--> xmlns="http://www.w3.org/2000/svg" height="20" width="20" viewBox="0 0 24 24"><g fill="#556987"><path fill="#556987" d="M12,3c1.989,0,3.873,0.65,5.43,1.833l-3.604,3.393l9.167,0.983L22.562,0l-3.655,3.442 C16.957,1.862,14.545,1,12,1C5.935,1,1,5.935,1,12h2C3,7.037,7.037,3,12,3z"></path><path data-color="#556987" d="M12,21c-1.989,0-3.873-0.65-5.43-1.833l3.604-3.393l-9.167-0.983L1.438,24l3.655-3.442 C7.043,22.138,9.455,23,12,23c6.065,0,11-4.935,11-11h-2C21,16.963,16.963,21,12,21z"></path></g></svg><span>Show Rates Table</span></button></div>-->
{% if show_chart %}
<div class="w-full md:w-auto p-1.5"> <div class="w-full md:w-auto p-1.5">
<button name="check_rates" type="button" value="Lookup Rates (RAW)" onclick='lookup_rates();' class="flex flex-wrap justify-center w-full px-4 py-2.5 font-medium text-sm text-coolGray-500 hover:text-coolGray-600 border border-coolGray-200 hover:border-coolGray-300 bg-white rounded-md focus:ring-0 focus:outline-none dark:text-white dark:hover:text-white dark:bg-gray-600 dark:hover:bg-gray-700 dark:border-gray-600 dark:hover:border-gray-600"><span>Check Current Rates</span> <button name="loadPrices" type="button" value="Lookup Rates (RAW)" onclick="loadPrices();" class="flex flex-wrap justify-center w-full px-4 py-2.5 font-medium text-sm text-coolGray-500 hover:text-coolGray-600 border border-coolGray-200 hover:border-coolGray-300 bg-white rounded-md focus:ring-0 focus:outline-none dark:text-white dark:hover:text-white dark:bg-gray-600 dark:hover:bg-gray-700 dark:border-gray-600 dark:hover:border-gray-600">
<span>Check Current Coin Prices/Rates (TABLE)</span>
</button>
</div>
{% endif %}
<div class="w-full md:w-auto p-1.5">
<button name="check_rates" type="button" value="Lookup Rates (RAW)" onclick='lookup_rates();' class="flex flex-wrap justify-center w-full px-4 py-2.5 font-medium text-sm text-coolGray-500 hover:text-coolGray-600 border border-coolGray-200 hover:border-coolGray-300 bg-white rounded-md focus:ring-0 focus:outline-none dark:text-white dark:hover:text-white dark:bg-gray-600 dark:hover:bg-gray-700 dark:border-gray-600 dark:hover:border-gray-600"><span>Check Current Price/Rates (JSON)</span>
</button> </button>
</div> </div>
<div class="w-full md:w-auto p-1.5"> <div class="w-full md:w-auto p-1.5">
@ -413,34 +454,33 @@ select.select-disabled {
opacity: 0.50 !important; opacity: 0.50 !important;
} }
</style> </style>
<script> <script>
const xhr_rates = new XMLHttpRequest(); const xhr_rates = new XMLHttpRequest();
xhr_rates.onload = () => { xhr_rates.onload = () => {
if (xhr_rates.status == 200) { if (xhr_rates.status == 200) {
const obj = JSON.parse(xhr_rates.response); const obj = JSON.parse(xhr_rates.response);
inner_html = '<pre><code>' + JSON.stringify(obj, null, ' ') + '</code></pre>'; inner_html = '<pre><code>' + JSON.stringify(obj, null, ' ') + '</code></pre>';
document.getElementById('rates_display').innerHTML = inner_html; document.getElementById('rates_display').innerHTML = inner_html;
} }
} }
const xhr_rate = new XMLHttpRequest(); const xhr_rate = new XMLHttpRequest();
xhr_rate.onload = () => { xhr_rate.onload = () => {
if (xhr_rate.status == 200) { if (xhr_rate.status == 200) {
const obj = JSON.parse(xhr_rate.response); const obj = JSON.parse(xhr_rate.response);
if (obj.hasOwnProperty('rate')) { if (obj.hasOwnProperty('rate')) {
document.getElementById('rate').value = obj['rate']; document.getElementById('rate').value = obj['rate'];
} } else
else
if (obj.hasOwnProperty('amount_to')) { if (obj.hasOwnProperty('amount_to')) {
document.getElementById('amt_to').value = obj['amount_to']; document.getElementById('amt_to').value = obj['amount_to'];
} } else
else
if (obj.hasOwnProperty('amount_from')) { if (obj.hasOwnProperty('amount_from')) {
document.getElementById('amt_from').value = obj['amount_from']; document.getElementById('amt_from').value = obj['amount_from'];
} }
} }
} }
const xhr_rates_table = new XMLHttpRequest(); const xhr_rates_table = new XMLHttpRequest();
xhr_rates_table.onload = () => { xhr_rates_table.onload = () => {
if (xhr_rates_table.status == 200) { if (xhr_rates_table.status == 200) {
const list = JSON.parse(xhr_rates_table.response); const list = JSON.parse(xhr_rates_table.response);
headings = ['Source', 'Coin From', 'Coin To', 'Coin From USD Rate', 'Coin To USD Rate', 'Coin From BTC Rate', 'Coin To BTC Rate', 'Relative Rate']; headings = ['Source', 'Coin From', 'Coin To', 'Coin From USD Rate', 'Coin To USD Rate', 'Coin From BTC Rate', 'Coin To BTC Rate', 'Relative Rate'];
@ -474,9 +514,9 @@ opacity: 0.50 !important;
display_node.appendChild(heading); display_node.appendChild(heading);
display_node.appendChild(table); display_node.appendChild(table);
} }
} }
function lookup_rates() { function lookup_rates() {
const coin_from = document.getElementById('coin_from').value; const coin_from = document.getElementById('coin_from').value;
const coin_to = document.getElementById('coin_to').value; const coin_to = document.getElementById('coin_to').value;
if (coin_from == '-1' || coin_to == '-1') { if (coin_from == '-1' || coin_to == '-1') {
@ -485,12 +525,17 @@ opacity: 0.50 !important;
} }
inner_html = '<p>Updating...</p>'; inner_html = '<p>Updating...</p>';
document.getElementById('rates_display').innerHTML = inner_html; document.getElementById('rates_display').innerHTML = inner_html;
// Remove the 'hidden' class
document.querySelector(".pricejsonhidden").classList.remove("hidden");
xhr_rates.open('POST', '/json/rates'); xhr_rates.open('POST', '/json/rates');
xhr_rates.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xhr_rates.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhr_rates.send('coin_from=' + coin_from + '&coin_to=' + coin_to); xhr_rates.send('coin_from=' + coin_from + '&coin_to=' + coin_to);
} }
function lookup_rates_table() {
function lookup_rates_table() {
const coin_from = document.getElementById('coin_from').value; const coin_from = document.getElementById('coin_from').value;
const coin_to = document.getElementById('coin_to').value; const coin_to = document.getElementById('coin_to').value;
if (coin_from == '-1' || coin_to == '-1') { if (coin_from == '-1' || coin_to == '-1') {
@ -499,19 +544,24 @@ opacity: 0.50 !important;
} }
inner_html = 'Updating...</p>'; inner_html = 'Updating...</p>';
document.getElementById('rates_display').innerHTML = inner_html; document.getElementById('rates_display').innerHTML = inner_html;
// Remove the 'hidden' class
document.querySelector(".hidden.py-3.border-b").classList.remove("hidden");
xhr_rates_table.open('GET', '/json/rateslist?from=' + coin_from + '&to=' + coin_to); xhr_rates_table.open('GET', '/json/rateslist?from=' + coin_from + '&to=' + coin_to);
xhr_rates_table.send(); xhr_rates_table.send();
} }
function set_swap_type_enabled(coin_from, coin_to, swap_type) { function set_swap_type_enabled(coin_from, coin_to, swap_type) {
let make_hidden = false; let make_hidden = false;
if (coin_to == '6' /* XMR */ || coin_to == '8' /* PART_ANON */ || coin_to == '7' /* PART_BLIND */ || coin_from == '7' /* PART_BLIND */) { if (coin_to == '6' /* XMR */ || coin_to == '8' /* PART_ANON */ || coin_to == '7' /* PART_BLIND */ || coin_from == '7' /* PART_BLIND */ ) {
swap_type.disabled = true; swap_type.disabled = true;
swap_type.value = 'xmr_swap'; swap_type.value = 'xmr_swap';
make_hidden = true; make_hidden = true;
swap_type.classList.add('select-disabled'); // Add the class to the disabled select swap_type.classList.add('select-disabled'); // Add the class to the disabled select
} else } else
if (coin_from == '11' /* PIVX */ || coin_from == '12' /* DASH */ || coin_from == '13' /* FIRO */) { if (coin_from == '11' /* PIVX */ || coin_from == '12' /* DASH */ || coin_from == '13' /* FIRO */ ) {
swap_type.disabled = true; swap_type.disabled = true;
swap_type.value = 'seller_first'; swap_type.value = 'seller_first';
make_hidden = true; make_hidden = true;
@ -534,9 +584,9 @@ opacity: 0.50 !important;
if (swap_type_hidden) { if (swap_type_hidden) {
swap_type_hidden.parentNode.removeChild(swap_type_hidden); swap_type_hidden.parentNode.removeChild(swap_type_hidden);
} }
} }
function set_rate(value_changed) { function set_rate(value_changed) {
const coin_from = document.getElementById('coin_from').value; const coin_from = document.getElementById('coin_from').value;
const coin_to = document.getElementById('coin_to').value; const coin_to = document.getElementById('coin_to').value;
const amt_from = document.getElementById('amt_from').value; const amt_from = document.getElementById('amt_from').value;
@ -571,14 +621,14 @@ opacity: 0.50 !important;
xhr_rate.open('POST', '/json/rate'); xhr_rate.open('POST', '/json/rate');
xhr_rate.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xhr_rate.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhr_rate.send(params); xhr_rate.send(params);
} }
document.addEventListener("DOMContentLoaded", function() { document.addEventListener("DOMContentLoaded", function() {
const coin_from = document.getElementById('coin_from').value; const coin_from = document.getElementById('coin_from').value;
const coin_to = document.getElementById('coin_to').value; const coin_to = document.getElementById('coin_to').value;
const swap_type = document.getElementById('swap_type'); const swap_type = document.getElementById('swap_type');
set_swap_type_enabled(coin_from, coin_to, swap_type); set_swap_type_enabled(coin_from, coin_to, swap_type);
}); });
</script> </script>
<script src="static/js/new_offer.js"></script> <script src="static/js/new_offer.js"></script>
<script src="static/js/coin_icons.js"></script> <script src="static/js/coin_icons.js"></script>
@ -586,5 +636,60 @@ opacity: 0.50 !important;
</div> </div>
{% include 'footer.html' %} {% include 'footer.html' %}
</div> </div>
{% if show_chart %}
<script>
document.addEventListener('DOMContentLoaded', function() {
document.querySelector("button[name='loadPrices']").addEventListener("click", loadPrices);
function loadPrices() {
const api_key = '{{chart_api_key}}';
const coins = ['BTC', 'PART', 'XMR', 'LTC', 'FIRO', 'DASH', 'PIVX'];
document.getElementById("priceTable").classList.remove("hidden");
coins.forEach(coin => {
fetch(`https://min-api.cryptocompare.com/data/pricemultifull?fsyms=${coin}&tsyms=USD,BTC&api_key=${api_key}`)
.then(response => response.json())
.then(data => {
const priceUSD = data.RAW[coin].USD.PRICE;
const priceBTC = data.RAW[coin].BTC.PRICE;
const tableRow = document.createElement("tr");
tableRow.classList.add("opacity-100", "text-gray-500", "dark:text-gray-100", "dark:text-gray-100", "hover:bg-coolGray-200", "dark:hover:bg-gray-600");
const coinCell = document.createElement("td", "py-3", "px-6");
coinCell.textContent = coin;
coinCell.classList.add("py-3", "px-6", "bold");
tableRow.appendChild(coinCell);
const usdPriceCell = document.createElement("td", "py-3", "px-6");
usdPriceCell.textContent = priceUSD.toFixed(2) + ' USD';
coinCell.classList.add("py-3", "px-6");
tableRow.appendChild(usdPriceCell);
const btcPriceCell = document.createElement("td");
if (coin !== 'BTC') {
btcPriceCell.textContent = priceBTC.toFixed(8) + ' BTC';
} else {
btcPriceCell.textContent = '-';
}
coinCell.classList.add("py-3", "px-6");
tableRow.appendChild(btcPriceCell);
document.getElementById("priceTableBody").appendChild(tableRow);
})
.catch(error => console.error(`Error fetching ${coin} data:`, error));
});
// Remove the 'hidden' class from the section when the button is clicked
document.querySelector(".pricetablehidden").classList.remove("hidden");
// Disable the button to prevent multiple clicks
const button = document.querySelector("button[name='loadPrices']");
button.disabled = true;
}
});
</script>
{% endif %}
</body> </body>
</html> </html>

@ -571,13 +571,6 @@
<div class="flex flex-wrap justify-end"> <div class="flex flex-wrap justify-end">
<div class="w-full md:w-auto p-1.5"> <div class="w-full md:w-auto p-1.5">
<button name="step1" type="submit" value="Back" class="flex flex-wrap justify-center w-full px-4 py-2.5 font-medium text-sm text-coolGray-500 hover:text-coolGray-600 border border-coolGray-200 hover:border-coolGray-300 bg-white rounded-md focus:ring-0 focus:outline-none dark:text-white dark:hover:text-white dark:bg-gray-600 dark:hover:bg-gray-700 dark:border-gray-600 dark:hover:border-gray-600"> <button name="step1" type="submit" value="Back" class="flex flex-wrap justify-center w-full px-4 py-2.5 font-medium text-sm text-coolGray-500 hover:text-coolGray-600 border border-coolGray-200 hover:border-coolGray-300 bg-white rounded-md focus:ring-0 focus:outline-none dark:text-white dark:hover:text-white dark:bg-gray-600 dark:hover:bg-gray-700 dark:border-gray-600 dark:hover:border-gray-600">
<svg class="mr-2" xmlns="http://www.w3.org/2000/svg" height="20" width="20" viewBox="0 0 24 24">
<g stroke-linecap="round" stroke-width="2" fill="none" stroke="#ffffff" stroke-linejoin="round">
<circle cx="12" cy="12" r="11"></circle>
<polyline points="13 16 9 12 13 8" stroke="#ffffff"></polyline>
</g>
</svg>
</svg>
<span>Back</span> <span>Back</span>
</button> </button>
</div> </div>
@ -615,25 +608,25 @@
{% endif %} {% endif %}
</form> </form>
<script> <script>
const selects = document.querySelectorAll('select.disabled-select'); const selects = document.querySelectorAll('select.disabled-select');
for (const select of selects) { for (const select of selects) {
if (select.disabled) { if (select.disabled) {
select.classList.add('disabled-select-enabled'); select.classList.add('disabled-select-enabled');
} else { } else {
select.classList.remove('disabled-select-enabled'); select.classList.remove('disabled-select-enabled');
} }
} }
</script> </script>
<script> <script>
const inputs = document.querySelectorAll('input.disabled-input, input[type="checkbox"].disabled-input'); const inputs = document.querySelectorAll('input.disabled-input, input[type="checkbox"].disabled-input');
for (const input of inputs) { for (const input of inputs) {
if (input.readOnly) { if (input.readOnly) {
input.classList.add('disabled-input-enabled'); input.classList.add('disabled-input-enabled');
} else { } else {
input.classList.remove('disabled-input-enabled'); input.classList.remove('disabled-input-enabled');
} }
} }
</script> </script>
<style> <style>

@ -264,7 +264,7 @@
<script> <script>
window.addEventListener('load', function() { window.addEventListener('load', function() {
const api_key = 'price-chart'; const api_key = '{{chart_api_key}}';
const coins = ['BTC', 'PART', 'XMR', 'LTC', 'FIRO', 'DASH', 'PIVX']; const coins = ['BTC', 'PART', 'XMR', 'LTC', 'FIRO', 'DASH', 'PIVX'];
@ -286,7 +286,7 @@ window.addEventListener('load', function() {
document.querySelector(`#${coin.toLowerCase()}-volume-24h`).textContent = volume24h.toFixed(0).replace(/\B(?=(\d{3})+(?!\d))/g, ',') + ' USD'; document.querySelector(`#${coin.toLowerCase()}-volume-24h`).textContent = volume24h.toFixed(0).replace(/\B(?=(\d{3})+(?!\d))/g, ',') + ' USD';
const priceChangeContainer = document.querySelector(`#${coin.toLowerCase()}-price-change-container`); const priceChangeContainer = document.querySelector(`#${coin.toLowerCase()}-price-change-container`);
if (priceChange1h >= 0) { if (priceChange1h >= 0) {
priceChangeContainer.innerHTML = ` priceChangeContainer.innerHTML = `
<div class="flex flex-wrap items-center py-px px-1 border border-green-500 rounded-full"> <div class="flex flex-wrap items-center py-px px-1 border border-green-500 rounded-full">
<svg class="mr-0.5" width="15" height="10" viewBox="0 0 15 10" fill="none" xmlns="http://www.w3.org/2000/svg"> <svg class="mr-0.5" width="15" height="10" viewBox="0 0 15 10" fill="none" xmlns="http://www.w3.org/2000/svg">
@ -294,7 +294,7 @@ if (priceChange1h >= 0) {
</svg> </svg>
<span class="text-xs text-green-500 font-medium">${priceChange1h.toFixed(2)}%</span> <span class="text-xs text-green-500 font-medium">${priceChange1h.toFixed(2)}%</span>
</div>`; </div>`;
} else { } else {
priceChangeContainer.innerHTML = ` priceChangeContainer.innerHTML = `
<div class="flex flex-wrap items-center py-px px-1 border border-red-500 rounded-full"> <div class="flex flex-wrap items-center py-px px-1 border border-red-500 rounded-full">
<svg class="mr-0.5" width="14" height="10" viewBox="0 0 14 10" fill="none" xmlns="http://www.w3.org/2000/svg"> <svg class="mr-0.5" width="14" height="10" viewBox="0 0 14 10" fill="none" xmlns="http://www.w3.org/2000/svg">
@ -302,20 +302,15 @@ if (priceChange1h >= 0) {
</svg> </svg>
<span class="text-xs text-red-500 font-medium">${Math.abs(priceChange1h.toFixed(2))}%</span> <span class="text-xs text-red-500 font-medium">${Math.abs(priceChange1h.toFixed(2))}%</span>
</div>`; </div>`;
} }
}) })
.catch(error => console.error(`Error fetching ${coin} data:`, error)); .catch(error => console.error(`Error fetching ${coin} data:`, error));
}); });
}); });
</script> </script>
{% endif %} {% endif %}
<section> <section>
<div class="pl-6 pr-6 pt-0 pb-0 mt-5 h-full overflow-hidden"> <div class="pl-6 pr-6 pt-0 pb-0 mt-5 h-full overflow-hidden">
<div class="pb-6 border-coolGray-100"> <div class="pb-6 border-coolGray-100">
@ -550,7 +545,7 @@ if (priceChange1h >= 0) {
</td> </td>
<td class="py-3 px-6 text-xs">{{ o[13] }}</td> <td class="py-3 px-6 text-xs">{{ o[13] }}</td>
<td class="py-3 px-6 text-xs"> <td class="py-3 px-6 text-xs">
<span class="inline-flex align-middle items-center justify-center w-9 h-10 bg-white-50 rounded"> <span class="inline-flex align-middle items-center justify-center w-9 h-10 rounded">
{% if o[9]==true %} <img class="h-7" src="/static/images/coins/{{ o[3]|replace(" ", "-") }}.png" alt=""> {% if o[9]==true %} <img class="h-7" src="/static/images/coins/{{ o[3]|replace(" ", "-") }}.png" alt="">
</span>{{ o[3] }} </span>{{ o[3] }}
</td> </td>
@ -562,7 +557,7 @@ if (priceChange1h >= 0) {
<td class="py-3 px-6 text-xs">{{ o[4]|truncate(8,true,'',0) }}</td> <td class="py-3 px-6 text-xs">{{ o[4]|truncate(8,true,'',0) }}</td>
{% endif %} {% endif %}
<td class="py-4 px-6 text-xs"> <td class="py-4 px-6 text-xs">
<span class="inline-flex align-middle items-center justify-center w-9 h-10 bg-white-50 rounded"> {% if o[9]==true %} <img class="h-7" src="/static/images/coins/{{ o[2]|replace(" ", "-") }}.png" alt=""> <span class="inline-flex align-middle items-center justify-center w-9 h-10 rounded"> {% if o[9]==true %} <img class="h-7" src="/static/images/coins/{{ o[2]|replace(" ", "-") }}.png" alt="">
</span>{{ o[2] }} </span>{{ o[2] }}
</td> </td>
<td class="py-3 px-6 text-xs">{{ o[4] }}</td> <td class="py-3 px-6 text-xs">{{ o[4] }}</td>

@ -431,6 +431,11 @@ def page_newoffer(self, url_split, post_string):
automation_filters = {'type_ind': Concepts.OFFER, 'sort_by': 'label'} automation_filters = {'type_ind': Concepts.OFFER, 'sort_by': 'label'}
automation_strategies = swap_client.listAutomationStrategies(automation_filters) automation_strategies = swap_client.listAutomationStrategies(automation_filters)
chart_api_key = swap_client.settings.get('chart_api_key', '')
if chart_api_key == '':
chart_api_key_enc = swap_client.settings.get('chart_api_key_enc', '')
chart_api_key = 'cd7600e7b5fdd99c6f900673ff0ee8f64d6d4219a4bb87191ad4a2e3fc65d7f4' if chart_api_key_enc == '' else bytes.fromhex(chart_api_key_enc).decode('utf-8')
return self.render_template(template, { return self.render_template(template, {
'messages': messages, 'messages': messages,
'err_messages': err_messages, 'err_messages': err_messages,
@ -442,9 +447,10 @@ def page_newoffer(self, url_split, post_string):
'automation_strategies': automation_strategies, 'automation_strategies': automation_strategies,
'summary': summary, 'summary': summary,
'swap_types': [(strSwapType(x), strSwapDesc(x)) for x in SwapTypes if strSwapType(x)], 'swap_types': [(strSwapType(x), strSwapDesc(x)) for x in SwapTypes if strSwapType(x)],
'show_chart': swap_client.settings.get('show_chart', True),
'chart_api_key': chart_api_key,
}) })
def page_offer(self, url_split, post_string): def page_offer(self, url_split, post_string):
ensure(len(url_split) > 2, 'Offer ID not specified') ensure(len(url_split) > 2, 'Offer ID not specified')
offer_id = decode_offer_id(url_split[2]) offer_id = decode_offer_id(url_split[2])

Loading…
Cancel
Save