diff --git a/basicswap/http_server.py b/basicswap/http_server.py index 593f61a..7e3f5b6 100644 --- a/basicswap/http_server.py +++ b/basicswap/http_server.py @@ -704,6 +704,11 @@ class HttpHandler(BaseHTTPRequestHandler): with open(os.path.join(static_path, 'css', filename), 'rb') as fp: self.putHeaders(status_code, 'text/css; charset=utf-8') return fp.read() + elif len(url_split) > 3 and url_split[2] == 'js': + filename = os.path.join(*url_split[3:]) + with open(os.path.join(static_path, 'js', filename), 'rb') as fp: + self.putHeaders(status_code, 'application/javascript') + return fp.read() else: self.putHeaders(status_code, 'text/html') return self.page_404(url_split) diff --git a/basicswap/static/css/simple/style.css b/basicswap/static/css/simple/style.css index dbf3da9..d650ab3 100644 --- a/basicswap/static/css/simple/style.css +++ b/basicswap/static/css/simple/style.css @@ -22,3 +22,13 @@ margin: 0; width:calc(33.33% - 25px); } + +.error +{ + background:#ff5b5b; +} + +.error_msg +{ + color:red; +} diff --git a/basicswap/static/js/new_offer.js b/basicswap/static/js/new_offer.js new file mode 100644 index 0000000..c8c28d2 --- /dev/null +++ b/basicswap/static/js/new_offer.js @@ -0,0 +1,27 @@ + +window.addEventListener('DOMContentLoaded', (event) => { + let err_msgs = document.querySelectorAll('p.error_msg'); + for (let i=0; i < err_msgs.length; i++) { + err_msg = err_msgs[i].innerText + if (err_msg.indexOf('coin_to') >= 0 || err_msg.indexOf('Coin To') >= 0) { + e = document.getElementById('coin_to'); + e.classList.add('error'); + } + if (err_msg.indexOf('Coin From') >= 0) { + e = document.getElementById('coin_from'); + e.classList.add('error'); + } + if (err_msg.indexOf('Amount From') >= 0) { + e = document.getElementById('amt_from'); + e.classList.add('error'); + } + if (err_msg.indexOf('Amount To') >= 0) { + e = document.getElementById('amt_to'); + e.classList.add('error'); + } + if (err_msg.indexOf('Minimum Bid Amount') >= 0) { + e = document.getElementById('amt_bid_min'); + e.classList.add('error'); + } + } +}); diff --git a/basicswap/templates/header.html b/basicswap/templates/header.html index f761188..f9bd560 100644 --- a/basicswap/templates/header.html +++ b/basicswap/templates/header.html @@ -19,6 +19,7 @@ floating_div = document.createElement('div'); floating_div.classList.add('floatright'); messages = document.createElement('ul'); + messages.setAttribute('id', 'ul_updates'); ws.onmessage = function (event) { let json = JSON.parse(event.data); @@ -33,7 +34,7 @@ event_message = 'Bid accepted'; } - let messages = document.getElementsByTagName('ul')[0], + let messages = document.getElementById('ul_updates'), message = document.createElement('li'); message.innerHTML = event_message; messages.appendChild(message); diff --git a/basicswap/templates/offer.html b/basicswap/templates/offer.html index 135a30f..e47e6c7 100644 --- a/basicswap/templates/offer.html +++ b/basicswap/templates/offer.html @@ -10,6 +10,9 @@ {% for m in messages %}
{{ m }}
{% endfor %} +{% for m in err_messages %} +Error: {{ m }}
+{% endfor %} {% if sent_bid_id %} @@ -21,6 +24,7 @@{{ m }}
{% endfor %} +{% for m in err_messages %} +Error: {{ m }}
+{% endfor %} +