diff --git a/MainPage/LogForMainPage.js b/MainPage/LogForMainPage.js index d387d23..5f586a4 100644 --- a/MainPage/LogForMainPage.js +++ b/MainPage/LogForMainPage.js @@ -1,40 +1,52 @@ 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(); + operate("number"); }; -function operate(){ +operateStringButton.onclick=function(){ + operate("string"); +} + +operateFButton.onclick=function(){ + operate("numberF"); +}; + +function operate(param){ switch(parseInt(select.value)){ case 1: - doOperation("calc1") + doOperation("calc1", param) break; case 2: - doOperation("calc2") + doOperation("calc2", param) break; case 3: - doOperation("calc3") + doOperation("calc3", param) break; case 4: - doOperation("calc4") + doOperation("calc4", param) break; }; } + function checkNumber(res){ - if(res.indexOf(".") != -1){ - return parseInt(res); - } - else{ - return res; - } + return res; } -async function doOperation(address) { - const response = await fetch(`http://localhost:8080/${address}?val1=${val1.value}&val2=${val2.value}`) - let res = await response.text() - finish.innerHTML = checkNumber(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)); } diff --git a/MainPage/MainPage.html b/MainPage/MainPage.html index b1209e5..921dbf6 100644 --- a/MainPage/MainPage.html +++ b/MainPage/MainPage.html @@ -14,29 +14,33 @@
- - +