diff --git a/24_11_18/24_11_18 - Frontend.pptx b/24_11_18/24_11_18 - Frontend.pptx new file mode 100644 index 00000000..723aec03 Binary files /dev/null and b/24_11_18/24_11_18 - Frontend.pptx differ diff --git a/24_11_18/feladat1.html b/24_11_18/feladat1.html new file mode 100644 index 00000000..99d39c83 --- /dev/null +++ b/24_11_18/feladat1.html @@ -0,0 +1,34 @@ + + + + + + Document + + +
+ + + +
+ +
+ + + \ No newline at end of file diff --git a/24_11_18/feladat1.js b/24_11_18/feladat1.js new file mode 100644 index 00000000..0f04e2b7 --- /dev/null +++ b/24_11_18/feladat1.js @@ -0,0 +1,57 @@ +const url = "http://127.0.0.1/PHP_digivagyok/20241118_JS/munkasok.json"; + +document.getElementById("button").addEventListener("click", function(){ + let value = document.getElementById("selection").value; + console.log(value); + main(value); + + +}); + + +/* +async function main(munkasNumber) { + let xhttp = new XMLHttpRequest(); + xhttp.open("GET", url, true); + + xhttp.onreadystatechange = async function(){ + if (xhttp.readyState === 4){ + if (xhttp.status === 200){ + let sol = await JSON.parse(xhttp.responseText); + + console.log(sol); + + createDomElement(sol[munkasNumber - 1]); + } else if(xhttp.status === 404){ + console.log("Az erőforrás nem található - 404 hibakód"); + } else{ + console.error(`Hiba történt, státuszkód: ${xhttp.status}`); + } + } + } + xhttp.send(); +} +*/ + +async function main(munkasNumber) { + try{ + let response = await fetch(url); + + if (!response.ok){ + throw new Error(`Hiba történt: ${response.status}`); + } + + let adatok = await response.json(); + + createDomElement(adatok[munkasNumber - 1]); + } catch (error) { + console.error(`Hiba ${error}`); + } +} + + +function createDomElement(element) { + let line = document.createElement("div"); + line.innerHTML = `Név: ${element.nev}, Beosztás: ${element.beosztas}, Kor: ${element.kor}, Fizetés:${element.fizetes}Ft`; + document.getElementById("eredmeny").appendChild(line); +} diff --git a/24_11_18/munkasok.json b/24_11_18/munkasok.json new file mode 100644 index 00000000..0996c15d --- /dev/null +++ b/24_11_18/munkasok.json @@ -0,0 +1 @@ +[{"nev":"Jani","beosztas":"sofőr","kor":45,"fizetes":300000},{"nev":"Pali","beosztas":"naplopó","kor":37,"fizetes":250000},{"nev":"Laci","beosztas":"vezető","kor":46,"fizetes":380000},{"nev":"Zsolt","beosztas":"főnök","kor":25,"fizetes":3000000},{"nev":"Tihamér","beosztas":"sofőr","kor":30,"fizetes":300000}] \ No newline at end of file diff --git a/24_11_18/tojson.js b/24_11_18/tojson.js new file mode 100644 index 00000000..8eea76de --- /dev/null +++ b/24_11_18/tojson.js @@ -0,0 +1,18 @@ +class Munkas { + constructor(nev, beosztas, kor, fizetes){ + this.nev = nev; + this.beosztas = beosztas; + this.kor = kor; + this.fizetes = fizetes; + } +} + +let munkasok = []; + +munkasok.push(new Munkas("Jani", "sofőr", 45, 300000)); +munkasok.push(new Munkas("Pali", "naplopó", 37, 250000)); +munkasok.push(new Munkas("Laci", "vezető", 46, 380000)); +munkasok.push(new Munkas("Zsolt", "főnök", 25, 3000000)); +munkasok.push(new Munkas("Tihamér", "sofőr", 30, 300000)); + +console.log(JSON.stringify(munkasok)); \ No newline at end of file