diff --git a/index.html b/index.html index b025f3d..c88faae 100644 --- a/index.html +++ b/index.html @@ -175,7 +175,7 @@ var isConnected = false; var apiIsAlive = false; // TODO: change to valid url - var apiServer = "localhost:8080" + var apiServer = "localhost" function hello_api() { $.ajax({ @@ -188,8 +188,8 @@ ok_msg_conn("API-Server is running. Connection established"); apiIsAlive = true; }, - error: function(data){ - err_msg_conn("API-Server unreachable"); + error: function(er){ + err_msg_conn(`API-Server unreachable. Error: ${JSON.stringify(er)}`); } }); } @@ -208,8 +208,8 @@ isConnected = true; return true; }, - error: function(data){ - err_msg_conn(`Cannot open web-socket with ${ip}:${port}`); + error: function(er){ + err_msg_conn(`Cannot open web-socket with ${ip}:${port}. Error: ${JSON.stringify(er)}`); return false; } }); @@ -234,8 +234,8 @@ ok_msg_conn(`Successfully sent data to ${address}`); return true; }, - error: function(data){ - err_msg_conn(`Cannot send data to ${address}`); + error: function(er){ + err_msg_conn(`Cannot send data to ${address}. Error: ${JSON.stringify(er)}`); return false; } }); @@ -273,14 +273,9 @@ } const address = document.getElementById('address').value; const data = document.getElementById('data').value; - // wr or rd - const wrd = document.querySelector('input[type=radio]:checked').value; - // true or false + const wrd = () => document.querySelector('input[type=radio]:checked')?.value === "rd"; const inc = document.querySelector('#inc').checked; - // const wr = document.getElementById('wr').value; - // const rd = document.getElementById('rd').value; - // const inc = document.getElementById('inc').value; - // console.log(`${document.querySelector('input[type=radio]:checked').value} ${document.querySelector('#inc').checked}`); + if (isConnected) { valid('ipAddress'); valid('port'); @@ -293,7 +288,7 @@ ok_msg_conn(`Sending data to address ${address}`); valid('address'); valid('data'); - if (!sendData(data, address, wrd, inc)) { + if (!sendData(data, address, wrd(), inc)) { invalid('address'); invalid('data'); }