// Web Socket export function webSocketConnect() { var ws = new WebSocket (document.getElementById('connectInput').value); ws.onopen = function () { document.getElementById('connectBtn').classList.replace("btn-outline-danger", "btn-outline-success") servicePortsInformationRequest(ws); } ws.onmessage = function(msg) { console.log(JSON.parse(msg.data).data) var exercises = new Map; var object = (JSON.parse(msg.data)).data; object.forEach((item, index, array) => { if (item.exercisesId != 0) { console.log (item.exerciseId) exercises.set(item.exerciseId, item); document.getElementById('exerciseSelect').innerHTML += `` } console.log(exercises) }) document.getElementById('exerciseSelect').disabled = false; document.getElementById('exerciseBtn').disabled = false; } ws.onclose = function() { document.getElementById('connectBtn').classList.replace("btn-outline-success", "btn-outline-danger") } } // Request function servicePortsInformationRequest(ws) { ws.send(JSON.stringify({ type: "servicePortsInformationRequest", uuid: "UUID" })); }