const operateButton = document.getElementById("operate"); const operateStringButton = document.getElementById("operateString"); const val1 = document.getElementById("val1"); const val2 = document.getElementById("val2"); const select = document.getElementById("operation"); const finish = document.getElementById("finish"); const operateFButton = document.getElementById("operateF"); const operateFStringButton = document.getElementById("operateFString"); const float1 = document.getElementById("float1"); const float2 = document.getElementById("float2"); const selectF = document.getElementById("operationF"); const finishF = document.getElementById("finishF"); operateButton.onclick=function(){ operate("number"); }; operateStringButton.onclick=function(){ operate("string"); } operateFButton.onclick=function(){ operate("numberF"); }; function operate(param){ switch(parseInt(select.value)){ case 1: doOperation("calc1", param) break; case 2: doOperation("calc2", param) break; case 3: doOperation("calc3", param) break; case 4: doOperation("calc4", param) break; }; } function checkNumber(res){ return res; } function doOperation(address, type){ console.log("Тип переменных: " + type) fetch(`http://localhost:8080/${address}?val1=${val1.value}&val2=${val2.value}&type=${type}`) .then(response => response.text()) .then(res=>finish.innerHTML=checkNumber(res)); }