diff --git a/app/src/components/Hero.jsx b/app/src/components/Hero.jsx index 992f7ef..384d23b 100644 --- a/app/src/components/Hero.jsx +++ b/app/src/components/Hero.jsx @@ -8,8 +8,6 @@ import { logo, menu, close } from "../assets"; const Hero = () => { - const [data,setData] = useState([{}]) - //zmienne globalne //zmienna mówiąca który przycisk jest aktywny, jest ona wykorzystywana @@ -19,9 +17,9 @@ const Hero = () => { let number_of_defenders = 0; let number_of_strikers = 0; - let shooterX = 0; - let shooterY = 0; - + var shooterX = 0; + var shooterY = 0; + var eX = " "; // zmienne globalne bedace danymi wejsciowymi do modelu @@ -34,6 +32,15 @@ const Hero = () => { active_bbt = a } + function changeLeg(a){ + + document.getElementById("bbt4").style.background = "white"; + document.getElementById("bbt5").style.background = "white"; + document.getElementById("bbt6").style.background = "white"; + document.getElementById(a).style.background = "grey"; + + Leg_bbt = a + } // Reset Boiska function resetField() { @@ -58,13 +65,11 @@ const Hero = () => { } // Wysłanie zapytania do serwera + const [data,setData] = useState([{}]) function sentQuestion() { var ball = document.querySelector('.football'); if (ball) { - var x = ball.style.left; - var y = ball.style.top; - var query = "http://localhost:5000/LRegresion" + shooterX + "&" + shooterY - fetch(query).then( + fetch("http://localhost:5000/LRegresion" + shooterX + "&" + shooterY).then( res=> res.json() ).then( data => { @@ -72,10 +77,12 @@ const Hero = () => { console.log(data) } ) - alert(data.response) + eX = data.response + document.getElementById("ex").innerHTML = "Ex:"+ eX } else { alert('Piłka nie jest obecnie na boisku.'); } + } /* Funkcja dodająca listener do boiska*/ @@ -83,12 +90,13 @@ const Hero = () => { var x = event.clientX - footballField.getBoundingClientRect().left; var y = event.clientY - footballField.getBoundingClientRect().top; + shooterX = (x * 105)/600 shooterY = ((400 - y) * 69)/ 400 // Przypadek kiedy zaznaczamy strzelca if(active_bbt == "bbt1"){ - var existingBall = document.querySelector('.football'); + let existingBall = document.querySelector('.football'); if (!existingBall) { var ball = document.createElement('div'); @@ -137,6 +145,16 @@ const Hero = () => { document.getElementById("bbt3").addEventListener("click",function(){ changePlayer("bbt3") },false) + + document.getElementById("bbt4").addEventListener("click",function(){ + changeLeg("bbt4") + },false) + document.getElementById("bbt5").addEventListener("click",function(){ + changeLeg("bbt5") + },false) + document.getElementById("bbt6").addEventListener("click",function(){ + changeLeg("bbt6") + },false) },[]); /*zwracany komponent zawierajacy boisko*/ @@ -184,6 +202,9 @@ const Hero = () => { +