first commit

This commit is contained in:
Tóth Ádám
2024-11-19 19:04:02 +01:00
commit de464b937d
8837 changed files with 493452 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="hu">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Újév</title>
<script src="js/UjevFeladat.js" defer></script>
</head>
<body>
<h1>Új évi visszaszámlálás</h1>
<label for="kezdoertek">Add meg a visszaszámlálás kezdőértékét: </label>
<input type="number" name="kezdoertek" id="kezdoertek">
<button style="cursor: pointer;">Visszaszámlálás indítása</button>
<p></p>
</body>
</html>

View File

@@ -0,0 +1,37 @@
const button = document.querySelector("button")
const input = document.getElementById("kezdoertek")
const p = document.querySelector("p")
let myInterval
button.addEventListener("click", () => {
let kezdoertek = Number(input.value)
myInterval = setInterval(() => {
let myPromise = new Promise((resolve, reject) => {
if (kezdoertek >= 0) {
resolve(`Visszaszámlálás: ${kezdoertek}`)
kezdoertek--
} else {
reject("Boldog Új Évet!")
clearInterval(myInterval)
}
})
myPromise
.then(result => {
p.innerHTML = result
})
.catch(error => {
p.innerHTML = error
})
}, 1000)
})
fetch('https://name-day.onrender.com/', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
.then(response => response.json())
.then(data => console.log(data))
.catch((error) => console.error('Error:', error));

View File

@@ -0,0 +1,49 @@
const feladatHozzaadasa = document.getElementById("hozzaadGomb")
const feladatok = document.getElementById("feladatok")
const feladatNev = document.getElementById("feladatNev")
const hatarido = document.getElementById("hatarido")
let modositasGombok = document.getElementsByClassName("modositasGomb")
let keszGombok = document.getElementsByClassName("keszGomb")
feladatHozzaadasa.addEventListener("click", () => {
if (feladatNev.value == "" || hatarido.value == "") {
alert("Nincs minden mező kitöltve!")
return
}
const feladat = document.createElement("div")
feladat.innerHTML = `<b>Feladat: ${feladatNev.value}</b><br>`
feladat.innerHTML += `<b>Határidő: ${hatarido.value}</b>`
feladat.classList.add("feladat")
feladatok.appendChild(feladat)
const modositas = document.createElement("button")
modositas.innerHTML = "Módosítás"
modositas.classList.add("modositasGomb")
feladat.appendChild(modositas)
const kesz = document.createElement("button")
kesz.innerHTML = "Kész"
kesz.classList.add("keszGomb")
feladat.appendChild(kesz)
feladatNev.value = ""
hatarido.value = ""
Array.from(modositasGombok).forEach(gomb => {
gomb.addEventListener("click", () => {
let ujNev = prompt("Adja meg az új feladat nevét:")
let ujDatum = prompt("Adj meg az új határidőt:")
gomb.parentElement.children[0].innerHTML = `Feladat: ${ujNev}`
gomb.parentElement.children[2].innerHTML = `Határidő ${ujDatum}`
})
})
Array.from(keszGombok).forEach(gomb => {
gomb.addEventListener("click", () => {
gomb.parentElement.remove()
})
})
})

View File

@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="hu">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Feladatlista</title>
<script src="js/todo.js" defer></script>
<style>
.feladat {
border: 1px solid #ccc;
padding: 10px;
margin: 5px 0;
border-radius: 5px;
}
.modositasGomb, .keszGomb {
background-color: #007bff;
color: white;
border: none;
border-radius: 3px;
cursor: pointer;
margin-left: 5px;
}
.keszGomb {
background-color: #ff4d4d;
}
</style>
</head>
<body>
<h1>To Do lista</h1>
<label for="feladatNev">Feladat neve:</label>
<input type="text" id="feladatNev">
<label for="hatarido">Határidő:</label>
<input type="text" id="hatarido">
<button id="hozzaadGomb">Feladat hozzáadása</button>
<div id="feladatok"></div>
</body>
</html>

View File

@@ -0,0 +1,3 @@
for (let i = 0; i < 2; i++) {
console.log(" |||");
}

View File

@@ -0,0 +1,46 @@
// function Person(name, age) {
// this.name = name
// this.age = age
// }
// let person1 = new Person("Janos", 19)
// let person2 = new Person("Benedek", 22)
// console.log(person1.name);
// console.log(person2.age);
// let jatek = {
// nev: "Minecraft",
// fejleszto: "Mojang",
// megjelenes: "2009"
// }
// console.log(jatek.nev);
// let nums = [1, 2, 3, 4, 5]
// console.log(nums);
// let userMap = new Map()
// userMap.set("name", "Kristof")
// let numSet = new Set([1, 2, 2, 3, 4])
// console.log(numSet);
// let x = 25
// let y = "25"
// console.log(x === y)
// let num = 35
// let text = "szoveg"
// console.log(`${text}${num}`);
// let num = 35
// console.log(typeof(num));
// const tomb = new Array(1, 2, 3, 4, 5)
// console.log(tomb instanceof Array);

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="js/IntervallumFeladat.js"></script>
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="js/SzamoloFeladat.js" defer></script>
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1,23 @@
let number1 = Number(prompt("Add meg az intervallum elejét:"))
let number2 = Number(prompt("Add meg az intervallum végét:"))
let listaSzamok = []
if (number1 < number2) {
for (; number1 <= number2; number1++) {
listaSzamok.push(number1)
}
} else {
for (; number1 >= number2; number1--) {
listaSzamok.push(number1)
}
}
console.log(listaSzamok);
let sum = listaSzamok.reduce((accumulator, currentValue) => {
return accumulator + currentValue
})
console.log(sum);
console.log(listaSzamok.length);

View File

@@ -0,0 +1,22 @@
let number1 = parseFloat(prompt("Add meg az első számot:"))
let number2 = parseFloat(prompt("Add meg a második számot:"))
if (!isNaN(number1) && !isNaN(number2)) {
console.log((number1 + number2).toFixed(2));
console.log((number1 - number2).toFixed(2));
console.log((number1 * number2).toFixed(2));
if (number2 == 0) {
console.log("Nem lehet nullával osztani!");
} else {
console.log((number1 / number2).toFixed(2));
}
if (number2 == 0) {
console.log("Nem lehet nullával osztani!");
} else {
console.log((number1 % number2).toFixed(2));
}
console.log(((number1 + number2) ** 2).toFixed(2));
} else {
console.log("Érvénytelen bemeneti adat!");
}

View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1 id="azonosito"></h1>
<script>
let name = prompt("Add meg a neved!")
document.getElementById("azonosito").innerHTML = name
</script>
</body>
</html>

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="js/Szokoev.js"></script>
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="Szovegmanipulacio.js"></script>
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1,21 @@
let mondat = prompt("Add meg a nevedet, életkorodat és hogy melyik iskolába jársz:")
console.log(mondat);
if (mondat.includes("Nemes")) {
console.log("Tartalmazza a 'Nemes' szót!");
} else {
console.log("Nem tartalmazza a 'Nemes' szót!");
}
let mondatMinusz5Karakter = mondat.substring(0, mondat.length - 5)
console.log(mondatMinusz5Karakter);
let mondatSlice = mondat.split(" ")
console.log(mondatSlice);
mondatSlice.forEach(element => {
console.log(element);
});
console.log(mondat.charAt(0));

View File

@@ -0,0 +1,17 @@
function fuggvenyNeve(param1, param2) {
return param1 + param2
console.log("Sosem fut le ez a kódsor!");
}
function ParameterNelkulifg() {
return "Nem kaptunk paramétert!"
}
function returnNelkulifg() {
console.log("Nincs return ennél a függvénynél");
}
console.log(fuggvenyNeve(5, 20));
console.log(ParameterNelkulifg());
returnNelkulifg()

View File

@@ -0,0 +1,11 @@
let evszam = Number(prompt("Adj meg egy évszámot:"))
function Szokoev(evszam) {
if ((evszam % 4 == 0 && evszam % 100 != 0) || evszam % 400 == 0) {
return "Szökőév!"
} else {
return "NEM szökőév!"
}
}
console.log(Szokoev(evszam));

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="js/ora.js"></script>
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Kő, papír, olló</title>
<script src="js/KoPapirOllo.js" defer></script>
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1,29 @@
let emberValasztas = prompt("Kő, papír vagy olló?: ")
let lehetosegek = ["kő", "papír", "olló"]
let randomValasztas = lehetosegek[Math.floor(Math.random() * 3)]
const eldontes = {
: {
: "Döntetlen!",
papír: "Vesztettél!",
olló: "Nyertél!"
},
papír: {
: "Nyertél!",
papír: "Döntetlen!",
olló: "Vesztettél!"
},
olló: {
: "Vesztettél!",
papír: "Nyertél!",
olló: "Döntetlen!"
}
}
function KoPapirOllo(ember, gep) {
eredmeny = eldontes[ember][gep]
console.log(eredmeny);
console.log(`${ember}, ${gep}`);
}
KoPapirOllo(emberValasztas, randomValasztas)

View File

@@ -0,0 +1,45 @@
let car = {
name: "Fiat",
model: "500",
engine: {
horsepower: "110",
fuel: "benzin"
},
start: function() {
return "Autó elindult"
},
drive: function() {
return "Autó megy"
},
carInfo: function() {
return `${this.name}, ${this.model}`
}
}
let tombNeve = ["alma", "cseresznye"]
console.log(tombNeve[tombNeve.length - 1]);
tombNeve.forEach(item => {
console.log(item);
})
console.log(new Date().getTime() / (1000));
// let car2 = new Object()
// car2.name = "Fiat"
// car2.model = "500"
// car2.start = function() {
// return "Autó elindult"
// }
// car2.drive = function() {
// return "Autó megy"
// }

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="js/script.js" defer></script>
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="js/KonyvtarObjektumFeladat.js" defer></script>
</head>
<body>
<h1 id="kiiratas"></h1>
</body>
</html>

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="js/Polobolt.js"></script>
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="js/TanfolyamArrayfeladat.js" defer></script>
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1,25 @@
let gyurukUra = {
cim: "Gyűrűk ura",
szerzo: "Tolkein",
megjelenesEve: 1966,
elerheto: true,
kolcsonzoNeve: undefined,
kikolcsonzes: function(kolcsonzoNeve) {
if (this.elerheto) {
this.kolcsonzoNeve = kolcsonzoNeve
this.elerheto = false
return `A ${this.cim} kikölcsönözve ${this.kolcsonzoNeve} által.`
} else {
return "A könyv nem elérhető jelenleg!"
}
},
visszahozas: function() {
this.kolcsonzoNeve = undefined
this.elerheto = true
},
informacio: function() {
return `A köny címe: ${this.cim}, szerzője: ${this.szerzo}, megjelenésének éve: ${this.megjelenesEve}, elérhetősége: ${this.elerheto ? "elérhető" : "nem elérhető"}, kölcsönzője ${this.kolcsonzoNeve}`
}
}
document.getElementById("kiiratas").innerHTML = gyurukUra.informacio()

View File

@@ -0,0 +1,7 @@
let polo = {
meret: 107,
szin: "kék",
meretvaltas: function() {
if (this.meret >= 84 && this.meret <= 88)
}
}

View File

@@ -0,0 +1,26 @@
let tagok = ["Példa Péter", "Fájl Ferenc", "Metódus Mária", "Mező Mihály"]
let utolagJelentkeztek = ["Média Mónika", "Kiterjesztés Kitti", "Típus Tímea"]
tagok.sort()
console.log(tagok);
tagok.unshift("Adat Aranka")
console.log(tagok);
console.log(`A tömb hossza ${tagok.length}`);
console.log(tagok.at(-2));
tagok.pop()
console.log(tagok);
let osszes = tagok.concat(utolagJelentkeztek)
console.log(osszes);
osszes.shift()
console.log(osszes);
osszes.push("Objektum Ottó")
console.log(osszes);
osszes.reverse()
console.log(osszes.join("; "));

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="js/AllatkertObjektumFeladat.js"></script>
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="js/MaganhangzoSzamolas.js"></script>
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1,51 @@
let allatok = {
fajta: "kutya",
szin: "fekete",
kor: 6,
etelallergia: ["gabona", "csoki"],
fiu: true,
eves: function(etel) {
if (!this.etelallergia.includes(etel)) {
return `A(z) ${this.fajta} megeheti az alábbi ételt: ${etel}`
} else {
return `A(z) ${this.fajta} nem eheti meg az alábbi ételt: ${etel}`
}
},
informacio: function() {
return `A(z) ${this.fajta}, aki ${this.szin} színű, ${this.kor} éves és az alábbi ételekre allergiás: ${allatok.etelallergia.join(", ")}`
},
alszik: function(ora) {
if (ora < 0) {
return `A(z) ${this.fajta} nem tud negatív órát aludni!`
} else if (this.kor <= 5) {
if (ora >= 6 && ora <= 8) {
return `A fiatal ${this.fajta} eleget aludt!`
} else {
return `A fiatal ${this.fajta} nem aludt eleget!`
}
} else if (this.kor >= 5) {
if (ora >= 8 && ora <= 10) {
return `Az idős ${this.fajta} eleget aludt!`
} else {
return `Az idős ${this.fajta} nem aludt eleget!`
}
}
},
hozzaad: function(etel) {
this.etelallergia.push(etel)
return `A(z) ${this.fajta} ezekre az ételekre allergiás: ${this.etelallergia.join(", ")}`
},
eletkor: function() {
if (this.fajta == "kutya") {
return `A kutya életkora kutyaévekben: ${this.kor * 7}`
}
},
allergiaABC: function() {
this.etelallergia.sort()
return `A(z) ${this.fajta} allergiás ételei ABC sorrendben: ${this.etelallergia.join(", ")}`
}
}
console.log(allatok.allergiaABC());

View File

@@ -0,0 +1,25 @@
const maganhangzok = ["a", "á", "e", "é", "i", "í", "o", "ó", "ö", "ő", "u", "ú", "ü", "ű"]
let maganhangzokSzamolva = {}
let text = prompt("Adj meg egy szót:")
function maganhangzokSzamolasa(text) {
const betuk = text.split("")
betuk.forEach(element => {
if (!maganhangzok.includes(element.toLowerCase())){
return
}
if (Object.keys(maganhangzokSzamolva).includes(element.toLowerCase())) {
maganhangzokSzamolva[element.toLowerCase()] += 1
} else {
maganhangzokSzamolva[element.toLowerCase()] = 1
}
});
}
maganhangzokSzamolasa(text)
console.log(`A "${text}" szó magánhangzói:`);
Object.keys(maganhangzokSzamolva).forEach(element => {
console.log(`\t${element}: ${maganhangzokSzamolva[element]}`);
})

View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="script.js" defer></script>
</head>
<body>
<h1 id="kaka" name="kakaka"></h1>
<h1 name="kakaka"></h1>
</body>
</html>

View File

@@ -0,0 +1 @@
let elem = document.querySelectorAll("h1")

View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="js/UzenetkezeloFeladat.js" defer></script>
</head>
<body>
<h1>Üzenetkezelő</h1>
<div id="uzenetek"></div>
</body>
</html>

View File

@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<p name="kaka">ihufsf</p>
<script>
let pElem = document.querySelector("[name='kaka']")
pElem.innerText = "<strong>jisakjnkjdakjjinajajnaeiuafeiiuaeiaui</strong>"
pElem.style.backgroundColor = "yellow"
console.log(pElem.getAttribute("name"));
let ujElem = document.createElement("div")
ujElem.innerHTML = "KKAKAKAK"
pElem.appendChild(ujElem)
pElem.removeChild(ujElem)
</script>
</body>
</html>

View File

@@ -0,0 +1,36 @@
const uzenetek = document.getElementById("uzenetek")
let uzenet1 = document.createElement("div")
uzenet1.setAttribute("class", "uzenet")
uzenet1.innerHTML = "Ez az első üzenet tartalma!"
uzenetek.appendChild(uzenet1)
let uzenet2 = document.createElement("div")
uzenet2.setAttribute("class", "uzenet")
uzenet2.setAttribute("id", "masodikUzenet")
uzenet2.innerHTML = "<b>Ez a második üzenet tartalma!</b>"
uzenetek.appendChild(uzenet2)
let uzenet3 = document.createElement("div")
uzenet3.setAttribute("class", uzenet2.getAttribute("class"))
uzenet3.setAttribute("name", "harmadikUzenet")
uzenet3.innerHTML = "Ez a harmadik üzenet tartalma!"
uzenetek.appendChild(uzenet3)
let valaszUzenet = document.createElement("div")
valaszUzenet.setAttribute("class", uzenet3.getAttribute("class"))
valaszUzenet.innerHTML = "<br><br><br>Ez a harmadik üzenetre egy válaszüzenet!"
uzenet3.appendChild(valaszUzenet)
uzenetek.removeChild(uzenet1)
let uzenet2Replace = document.createElement("p")
uzenet2Replace.setAttribute("class", "uzenet")
uzenet2Replace.setAttribute("id", "masodikUzenet")
uzenet2Replace.innerHTML = "<b>Ez a második üzenet tartalma!</b>"
uzenetek.replaceChild(uzenet2Replace, uzenet2)

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="js/HatterSzinValtozasFeladat.js" defer></script>
</head>
<body style="background-color: aqua;">
<button>Katt ide!</button>
</body>
</html>

View File

@@ -0,0 +1,9 @@
const button = document.querySelector("button")
button.addEventListener("click", () => {
if (document.body.style.backgroundColor == "aqua") {
document.body.style.backgroundColor = "brown"
} else {
document.body.style.backgroundColor = "aqua"
}
})

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Diák</title>
<script src="js/DiakFeladat.js"></script>
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="hu">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
let tomb = [10, 20]
let [a, b, c = 30] = tomb
console.log(`${a} \n${b} \n${c}`);
</script>
</body>
</html>

View File

@@ -0,0 +1,5 @@
let diak = {nev: "Kovács Jancsika", eletkor: 16, szak: "informatika"}
let kivalasztas = ({ nev, eletkor, szak }) => `A nevem ${nev}, ${eletkor} éves vagyok, és a választott szakom: ${szak}.`
console.log(kivalasztas(diak));

View File

@@ -0,0 +1,12 @@
import random
from datetime import datetime, timedelta
# Jegyek szimulálása
entries = ["Alice"] * 6 + ["Bob"] * 5 + ["Charlie"] * 4 + ["Dave"] * 4 + ["Eve"] * 4 + ["kaka"] * 3 + ["fos"] * 1
random.shuffle(entries)
# Véletlenszerű nyertes kiválasztása
winner = random.choice(entries)
print(winner)
now = now()

View File

@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="js/AnonimFuggvenyekFeladat.js" defer></script>
</head>
<body>
<h1>Egyszerű összeadás</h1>
Első szám: <input type="number" name="szam1" id="szam1"><br>
Második szám: <input type="number" name="szam2" id="szam2"><br>
<button>Eredmény</button>
<h1 id="eredmeny">Eredmény: </h1>
</body>
</html>

View File

@@ -0,0 +1,14 @@
const button = document.querySelector("button")
const eredmeny = document.getElementById("eredmeny")
button.addEventListener("click", () => {
let szam1 = document.getElementById("szam1")
let szam2 = document.getElementById("szam2")
if (isNaN(szam1.value) || isNaN(szam2.value)) {
eredmeny.innerHTML += "Hibás adatok!"
return
}
eredmeny.innerHTML = `Eredmény: ${Number(szam1.value) + Number(szam2.value)}`
})

View File

@@ -0,0 +1,41 @@
const szamok = [1, 20, -10, -2, -4, 6, -5, 5, 8, 2]
let negativ_szamok_lista = []
let pozitiv_szamok_lista = []
function kiiras(negativ_osszeg, pozitiv_osszeg) {
console.log(`A pozitív számok összege: ${pozitiv_osszeg}`);
console.log(`A negatív számok összege: ${negativ_osszeg}`);
}
function negativak() {
szamok.forEach(szam => {
if (szam < 0) {
negativ_szamok_lista.push(szam)
}
})
}
function pozitivak() {
szamok.forEach(szam => {
if (szam > 0) {
pozitiv_szamok_lista.push(szam)
}
})
}
function vegrehajtas(callbackKiiras) {
negativak()
pozitivak()
var negativ_osszeg = negativ_szamok_lista.reduce((accumulator, currentValue) => {
return accumulator + currentValue
})
var pozitiv_osszeg = pozitiv_szamok_lista.reduce((accumulator, currentValue) => {
return accumulator + currentValue
})
callbackKiiras(negativ_osszeg, pozitiv_osszeg)
}
vegrehajtas(kiiras)

View File

@@ -0,0 +1,7 @@
let inkr = 0
let kiiras = () => {
inkr += 1
console.log(inkr);
}
setInterval(kiiras, 3000)

View File

@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Random Szám Generálása</title>
<link rel="stylesheet" href="css/style.css">
<script src="js/RandomSzamFeladat.js" defer></script>
</head>
<body>
<h1>Szám Generáló</h1>
<div id="randomSzamDiv">
<label for="randomSzam">Hány számot szeretne generálni?</label>
<input type="number" name="randomSzam" id="randomSzam">
<button>Generálás</button>
</div>
<div id="generaltSzamok"></div>
</body>
</html>

View File

@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="hu">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Számítás</title>
<link rel="stylesheet" href="css/style.css">
<script src="js/SzamitasFeladat.js" defer></script>
</head>
<body>
<h1>Számítás</h1>
<div class="form">
<label for="elsoSzam">Első szám: </label>
<input type="number" name="elsoSzam" id="elsoSzam" placeholder="Írja be a első számot:"><br>
<label for="masodikSzam">Második szám: </label>
<input type="number" name="masodikSzam" id="masodikSzam" placeholder="Írja be a második számot:"><br>
<button>Számítás</button>
</div>
<div id="eredmenyek">
</div>
</body>
</html>

View File

@@ -0,0 +1,7 @@
body {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
flex-direction: column;
}

View File

@@ -0,0 +1,44 @@
const randomSzamInput = document.getElementById("randomSzam")
const generaltSzamok = document.getElementById("generaltSzamok")
const button = document.querySelector("button")
button.addEventListener("click", () => {
const randomSzamok = []
let generaltSzamokChildren = Array.from(generaltSzamok.children)
generaltSzamokChildren.forEach(child => {
generaltSzamok.removeChild(child)
})
let myPromise = new Promise((resolve, reject) => {
let success
if (Number.isInteger(Number(randomSzamInput.value))) {
success = true
} else {
success = false
}
setTimeout(() => {
if (success) {
for (let i = 0; i < Number(randomSzamInput.value); i++) {
let randomSzam = Math.floor(Math.random() * 100)
randomSzamok.push(randomSzam)
}
resolve(randomSzamok)
} else {
reject("Probléma volt a kód futásával!")
}
}, 2000)
})
myPromise
.then(result => {
let generaltSzamokP = document.createElement("p")
generaltSzamokP.innerHTML = `Generált számok: ${result.join(", ")}`
generaltSzamok.appendChild(generaltSzamokP)
})
.catch(error => {
let generaltSzamokP = document.createElement("p")
generaltSzamokP.innerHTML = error
generaltSzamok.appendChild(generaltSzamokP)
})
})

View File

@@ -0,0 +1,55 @@
const button = document.querySelector("button")
const elsoSzam = document.getElementById("elsoSzam")
const masodikSzam = document.getElementById("masodikSzam")
const eredmenyekDiv = document.getElementById("eredmenyek")
console.log(eredmenyekDiv.children);
button.addEventListener("click", () => {
const elsoSzamValue = Number(elsoSzam.value)
const masodikSzamValue = Number(masodikSzam.value)
if (isNaN(elsoSzamValue) && isNaN(masodikSzamValue)) {
alert("Nem számot adott meg valamelyik mezőben!")
return
}
let eredmenyekDivChildren = Array.from(eredmenyekDiv.children)
eredmenyekDivChildren.forEach(child => {
eredmenyekDiv.removeChild(child)
})
let eredmenyekH1 = document.createElement("h1")
eredmenyekH1.innerHTML = "Eredmények"
eredmenyekDiv.appendChild(eredmenyekH1)
let osszegP = document.createElement("p")
osszegP.innerHTML = `Összeg: ${elsoSzamValue + masodikSzamValue}`
eredmenyekDiv.appendChild(osszegP)
let kulonbsegP = document.createElement("p")
kulonbsegP.innerHTML = `Különbség: ${elsoSzamValue - masodikSzamValue}`
eredmenyekDiv.appendChild(kulonbsegP)
let szorzatP = document.createElement("p")
szorzatP.innerHTML = `Szorzat: ${elsoSzamValue * masodikSzamValue}`
eredmenyekDiv.appendChild(szorzatP)
let hanyadosP = document.createElement("p")
if (masodikSzamValue == 0) {
hanyadosP.innerHTML = `Hányados: Nem lehetséges nullával osztani!`
eredmenyekDiv.appendChild(hanyadosP)
return
}
hanyadosP.innerHTML = `Hányados: ${elsoSzamValue / masodikSzamValue}`
eredmenyekDiv.appendChild(hanyadosP)
elsoSzam.value = ""
masodikSzam.value = ""
})

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Képmegjelenítés</title>
<script src="js/KepmegjelenitesFeladat.js"></script>
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="js/script.js" defer></script>
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1,5 @@
function duplaz(szam) {
return szam * 2
}
export {duplaz}

View File

@@ -0,0 +1,21 @@
async function adatlekeres() {
let valasz = await fetch("https://jsonplaceholder.typicode.com/photos")
let JSadatkereses = await valasz.json()
JSadatkereses.forEach(element => {
// if (element.id != 3) {
// document.body.innerHTML += element.title
// document.body.innerHTML += element.thumbnailUrl
// document.body.innerHTML += element.url
// }
// console.log(element.id);
});
// for (let i = 0; i < 3; i++) {
// document.body.innerHTML += JSadatkereses[i].title
// document.body.innerHTML += JSadatkereses[i].thumbnailUrl
// document.body.innerHTML += JSadatkereses[i].url
// }
}
adatlekeres()

View File

@@ -0,0 +1,5 @@
import { duplaz } from "./DuplazasFeladatModule.mjs";
import { koszontesDuplazas } from "./KoszontesFeladatModule.mjs";
console.log(duplaz(3));
console.log(koszontesDuplazas("Ádám", 37632762));

View File

@@ -0,0 +1,5 @@
function koszontesDuplazas(nev, szam) {
return `${nev}, ${szam * 2}`
}
export {koszontesDuplazas}

View File

@@ -0,0 +1,14 @@
async function adatlekeres() {
try {
let valasz = await fetch("https://jsonplaceholder.typicode.com/todos")
let JSadatkereses = await valasz.json()
console.log(JSadatkereses);
}
catch (error) {
console.log(error);
}
}
adatlekeres()

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="hu">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Köszöntés és duplázás</title>
<script type="module" src="js/KoszontesDuplazasFeladat.mjs" defer></script>
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html lang="hu">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
let car = {
name: "Fiat",
model: "500",
start: function () {
return "Autó elindul!";
},
drive: function () {
return "Autó megy!";
}
}
//---------------------------------------------------
class Szemely{
static faj = "Ember";
nev = "Sanyi";
kor = 12;
}
let szemely1 = new Szemely();
console.log(Szemely.faj);
//---------------------------------------------------
class Ember{
constructor(nev, kor){
this.nev = nev;
this.kor = kor;
}
}
let ember1 = new Ember("Sanyi", 12);
console.log(ember1.nev);
//---------------------------------------------------
class Valaki{
constructor(nev, kor){
this._nev = nev;
this._kor = kor;
}
}
let valaki1 = new Valaki("Péter", 22);
console.log(valaki1._nev);
//---------------------------------------------------
class Vki{
constructor(nev, kor){
this.nev = nev;
this.kor = kor;
}
static udvozles(){
return "Üdvözöllek!";
}
}
let vki1 = new Vki("Péter", 22);
console.log(Vki.udvozles());
</script>
</body>
</html>

View File

@@ -0,0 +1,28 @@
class Szemely {
constructor(nev, kor) {
this.nev = nev
this.kor = kor
}
bemutatkozas() {
return `A nevem ${this.nev} és ${this.kor} éves vagyok!`
}
}
class Diak extends Szemely {
static diakszam = 0
constructor(nev, kor, osztaly) {
super(nev, kor)
Diak.diakszam++
this.osztaly = osztaly
}
bemutatkozas() {
return `${super.bemutatkozas()} és az ${this.osztaly}-ba/be járok.`
}
}
const diak1 = new Diak("Tóth Ádám", 19, "13.B")
const diak2 = new Diak("Tóth Ádámm", 191, "12.B")
console.log(diak1.bemutatkozas());
console.log(`Jelenleg ${Diak.diakszam} tanuló van a rendszerben`);

View File

@@ -0,0 +1,57 @@
class Szallitas {
constructor(felado, cimzett, suly, azonosito) {
this.felado = felado
this.cimzett = cimzett
this.suly = suly
this.azonosito = azonosito
}
informacio() {
return `A feladó ${this.felado}, a címzett ${this.cimzett}, a csomag súlya ${this.suly} és az azonosítója ${this.azonosito}`
}
}
class Csomag extends Szallitas {
static csomagSzam = 0
constructor(felado, cimzett, suly, azonosito, meret) {
super(felado, cimzett, suly, azonosito)
this.meret = meret
Csomag.csomagSzam++
}
informacio() {
return `${super.informacio()}, valamint a cosmag mérete ${this.meret}.`
}
static osszesCsomag() {
return Csomag.csomagSzam
}
}
class Teherauto extends Szallitas {
static autoSzam = 0
constructor(felado, cimzett, suly, azonosito, maxTerheles) {
super(felado, cimzett, suly, azonosito)
this.maxTerheles = maxTerheles
}
informacio() {
return `${super.informacio()}, valamint a terhelhetősége ${this.maxTerheles}.`
}
static osszesAuto() {
return Teherauto.autoSzam
}
}
const csomag1 = new Csomag("Kutya", "Macska", "15kg", 1)
const csomag2 = new Csomag("Disznaj", "Kecske", "20kg", 2)
console.log(csomag1.informacio());
console.log(Csomag.osszesCsomag())
const teherauto1 = new Teherauto("Kutya", "Macska", "15kg", 1, "250kg")
const teherauto2 = new Teherauto("500kg")
console.log(teherauto1.informacio());
console.log(Teherauto.osszesAuto())

View File

@@ -0,0 +1,86 @@
class Termek {
constructor(nev, ar, mennyiseg, azonosito) {
this.nev = nev
this.ar = ar
this.mennyiseg = mennyiseg
this.azonosito = azonosito
}
adatok() {
return `A termék neve ${this.nev}, a termék ára ${this.ar}, a termék mennyisége ${this.mennyiseg} és azonosítója ${this.azonosito}`
}
}
class Elelmiszer extends Termek {
static elelmiszerSzam = 0
constructor(nev, ar, mennyiseg, azonosito, szavatossagiIdo) {
super(nev, ar, mennyiseg, azonosito)
this.szavatossagiIdo = szavatossagiIdo
Elelmiszer.elelmiszerSzam++
}
adatok() {
return `${super.adatok()}, valamint a szavatossági idő ${this.szavatossagiIdo}`
}
osszesElelmiszer() {
return Elelmiszer.elelmiszerSzam
}
}
class ElektronikaiTermek extends Termek {
static elektronikaSzam = 0
constructor(nev, ar, mennyiseg, azonosito, garancia) {
super(nev, ar, mennyiseg, azonosito)
this.garancia = garancia
ElektronikaiTermek.elektronikaSzam++
}
adatok() {
return `${super.adatok()}, valamint a garancia időtartama ${this.garancia}.`
}
osszesElektronikaiTermek() {
return ElektronikaiTermek.elektronikaSzam
}
}
class Raktar {
constructor(termekek) {
this.termekek = termekek
}
hozzaadTermek(termek) {
this.termekek.push(termek)
}
eltavolitTermek(azonosito) {
this.termekek.forEach(element => {
if (element.azonosito == azonosito) {
this.termekek.splice(element)
}
});
}
keszletKimutatas() {
this.termekek.forEach(element => {
console.log(element.adatok());
})
console.log(this.termekek.length);
}
keresettTermek(nev) {
this.termekek.forEach(element => {
if (element.nev == nev) {
element.
}
})
}
}
const raktar1 = new Raktar([])
const elektronikaiTermek1 = new ElektronikaiTermek("Monitor", "85.000 Ft", 2, 1, "2 év")
raktar1.hozzaadTermek(elektronikaiTermek1)
console.log(raktar1.termekek);
raktar1.keszletKimutatas()

View File

@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="hu">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FetchAPI</title>
<script type="module" src="js/AszinkronFetchAPIFeladat.mjs"></script>
</head>
<body>
<div>
</div>
</body>
</html>

View File

@@ -0,0 +1,50 @@
import Bejegyzes from "./Bejegyzes.mjs";
import BejegyzesLista from "./BejegyzesLista.mjs";
async function fetchAdatok(apiUrl) {
let valasz = await fetch(apiUrl)
try {
if (!valasz.ok) {
throw new Error("Hibás lekérés!")
}
let JSadatszerkezet = await valasz.json()
document.querySelector("div").innerHTML = JSON.stringify(JSadatszerkezet, null, 2)
}
catch (hiba) {
console.log(hiba);
}
}
// fetchAdatok("https://jsonplaceholder.typicode.com/posts")
async function fetchAdatok2(apiUrl) {
let valasz = await fetch(apiUrl)
try {
if (!valasz.ok) {
throw new Error("Hibás lekérés!")
}
let JSadatszerkezet = await valasz.json()
const bejegyzesek = new BejegyzesLista([])
JSadatszerkezet.forEach(element => {
let bejegyzes = new Bejegyzes(element["id"], element["title"], element["body"])
bejegyzesek.hozzaadBejegyzes(bejegyzes)
});
bejegyzesek.megjelenitBejegyzesek()
}
catch (hiba) {
console.log(hiba);
}
}
fetchAdatok2("https://jsonplaceholder.typicode.com/posts")

View File

@@ -0,0 +1,13 @@
class Bejegyzes {
constructor(id, cim, tartalom) {
this.id = id
this.cim = cim
this.tartalom = tartalom
}
getReszletek() {
return `${this.id}, ${this.cim}, ${this.tartalom}`
}
}
export default Bejegyzes;

View File

@@ -0,0 +1,19 @@
class BejegyzesLista {
constructor(tomb) {
this.tomb = tomb
}
hozzaadBejegyzes(bejegyzes) {
this.tomb.push(bejegyzes)
}
megjelenitBejegyzesek() {
this.tomb.forEach(element => {
document.querySelector("div").innerHTML += element.id
document.querySelector("div").innerHTML += element.cim
document.querySelector("div").innerHTML += element.tartalom
})
}
}
export default BejegyzesLista

View File

@@ -0,0 +1,51 @@
class Termek {
constructor(nev, ar, darabszam) {
this.nev = nev
this.ar = ar
this.darabszam = darabszam
}
toSzoveg() {
return `${this.nev}, ${this.ar}, ${this.darabszam}`
}
}
class Raktar {
static termekLista = []
static termekHozzaad(ujTermek) {
Raktar.termekLista.push(ujTermek)
}
static termekTorles(nev) {
Raktar.termekLista.forEach(element => {
if (element.nev.toLowerCase() == nev.toLowerCase()) {
Raktar.termekLista.splice(element, 1)
}
})
}
static termekKeres(nev) {
Raktar.termekLista.forEach(element => {
if (element.nev.toLowerCase() == nev.toLowerCase()) {
console.log(element);
}
})
}
static osszesTermekListaz() {
console.log(Raktar.termekLista);
}
}
termek1 = new Termek("Monitor", "85.000 Ft", 100)
termek2 = new Termek("Billentyűzet", "10.000 Ft", 20)
Raktar.termekHozzaad(termek1)
Raktar.termekHozzaad(termek2)
Raktar.termekKeres("Monitor")
Raktar.osszesTermekListaz()
Raktar.termekTorles("Billentyűzet")
Raktar.osszesTermekListaz()

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="hu">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AJAX</title>
<script src="js/script.js"></script>
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1,25 @@
let xhttp = new XMLHttpRequest()
xhttp.open("GET", "https://jsonplaceholder.typicode.com/posts", true)
xhttp.onreadystatechange = function() {
if (xhttp.readyState === 4) {
if (xhttp.status === 200) {
console.log(`Az eredmény: ${JSON.parse(xhttp.responseText)}`)
// const kaka = JSON.parse(xhttp.responseText)
// kaka.forEach(element => {
// console.log(element);
// });
}
else if (xhttp.status === 404) {
console.log("Erőforrás nem található! - 404-es hibakód")
}
else {
console.error(`Hiba történt, státuszkód: ${xhttp.status}`)
}
}
}
xhttp.send()

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AJAX Lekérés</title>
<script src="js/script.js"></script>
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1,21 @@
let xhttp = new XMLHttpRequest()
xhttp.open("GET", "https://jsonplaceholder.typicode.com/posts", true)
xhttp.onreadystatechange = function() {
if (xhttp.readyState === 4) {
if (xhttp.status === 200) {
console.log("Sikeres kérés:")
let response = JSON.parse(xhttp.responseText)
for (let i = 0; i < 3; i++) {
console.log(response[i]);
}
} else if (xhttp.status === 404) {
console.log("Erőforrás nem található - 404-es hibakód.")
} else {
console.log(`Hiba történt: ${xhttp.status}`)
}
}
}
xhttp.send()

View File

@@ -0,0 +1,16 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=`cygpath -w "$basedir"`
fi
;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../ejs/bin/cli.js" "$@"
else
exec node "$basedir/../ejs/bin/cli.js" "$@"
fi

View File

@@ -0,0 +1,17 @@
@ECHO off
GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\ejs\bin\cli.js" %*

View File

@@ -0,0 +1,28 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../ejs/bin/cli.js" $args
} else {
& "$basedir/node$exe" "$basedir/../ejs/bin/cli.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../ejs/bin/cli.js" $args
} else {
& "node$exe" "$basedir/../ejs/bin/cli.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

View File

@@ -0,0 +1,16 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=`cygpath -w "$basedir"`
fi
;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../jake/bin/cli.js" "$@"
else
exec node "$basedir/../jake/bin/cli.js" "$@"
fi

View File

@@ -0,0 +1,17 @@
@ECHO off
GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\jake\bin\cli.js" %*

View File

@@ -0,0 +1,28 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../jake/bin/cli.js" $args
} else {
& "$basedir/node$exe" "$basedir/../jake/bin/cli.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../jake/bin/cli.js" $args
} else {
& "node$exe" "$basedir/../jake/bin/cli.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

View File

@@ -0,0 +1,16 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=`cygpath -w "$basedir"`
fi
;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../mime/cli.js" "$@"
else
exec node "$basedir/../mime/cli.js" "$@"
fi

View File

@@ -0,0 +1,17 @@
@ECHO off
GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\mime\cli.js" %*

View File

@@ -0,0 +1,28 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../mime/cli.js" $args
} else {
& "$basedir/node$exe" "$basedir/../mime/cli.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../mime/cli.js" $args
} else {
& "node$exe" "$basedir/../mime/cli.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

View File

@@ -0,0 +1,16 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=`cygpath -w "$basedir"`
fi
;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../nodemon/bin/nodemon.js" "$@"
else
exec node "$basedir/../nodemon/bin/nodemon.js" "$@"
fi

View File

@@ -0,0 +1,17 @@
@ECHO off
GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\nodemon\bin\nodemon.js" %*

View File

@@ -0,0 +1,28 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../nodemon/bin/nodemon.js" $args
} else {
& "$basedir/node$exe" "$basedir/../nodemon/bin/nodemon.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../nodemon/bin/nodemon.js" $args
} else {
& "node$exe" "$basedir/../nodemon/bin/nodemon.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

View File

@@ -0,0 +1,16 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=`cygpath -w "$basedir"`
fi
;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../touch/bin/nodetouch.js" "$@"
else
exec node "$basedir/../touch/bin/nodetouch.js" "$@"
fi

View File

@@ -0,0 +1,17 @@
@ECHO off
GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\touch\bin\nodetouch.js" %*

View File

@@ -0,0 +1,28 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../touch/bin/nodetouch.js" $args
} else {
& "$basedir/node$exe" "$basedir/../touch/bin/nodetouch.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../touch/bin/nodetouch.js" $args
} else {
& "node$exe" "$basedir/../touch/bin/nodetouch.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

View File

@@ -0,0 +1,16 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=`cygpath -w "$basedir"`
fi
;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../semver/bin/semver.js" "$@"
else
exec node "$basedir/../semver/bin/semver.js" "$@"
fi

View File

@@ -0,0 +1,17 @@
@ECHO off
GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\semver\bin\semver.js" %*

View File

@@ -0,0 +1,28 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../semver/bin/semver.js" $args
} else {
& "$basedir/node$exe" "$basedir/../semver/bin/semver.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../semver/bin/semver.js" $args
} else {
& "node$exe" "$basedir/../semver/bin/semver.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,243 @@
1.3.8 / 2022-02-02
==================
* deps: mime-types@~2.1.34
- deps: mime-db@~1.51.0
* deps: negotiator@0.6.3
1.3.7 / 2019-04-29
==================
* deps: negotiator@0.6.2
- Fix sorting charset, encoding, and language with extra parameters
1.3.6 / 2019-04-28
==================
* deps: mime-types@~2.1.24
- deps: mime-db@~1.40.0
1.3.5 / 2018-02-28
==================
* deps: mime-types@~2.1.18
- deps: mime-db@~1.33.0
1.3.4 / 2017-08-22
==================
* deps: mime-types@~2.1.16
- deps: mime-db@~1.29.0
1.3.3 / 2016-05-02
==================
* deps: mime-types@~2.1.11
- deps: mime-db@~1.23.0
* deps: negotiator@0.6.1
- perf: improve `Accept` parsing speed
- perf: improve `Accept-Charset` parsing speed
- perf: improve `Accept-Encoding` parsing speed
- perf: improve `Accept-Language` parsing speed
1.3.2 / 2016-03-08
==================
* deps: mime-types@~2.1.10
- Fix extension of `application/dash+xml`
- Update primary extension for `audio/mp4`
- deps: mime-db@~1.22.0
1.3.1 / 2016-01-19
==================
* deps: mime-types@~2.1.9
- deps: mime-db@~1.21.0
1.3.0 / 2015-09-29
==================
* deps: mime-types@~2.1.7
- deps: mime-db@~1.19.0
* deps: negotiator@0.6.0
- Fix including type extensions in parameters in `Accept` parsing
- Fix parsing `Accept` parameters with quoted equals
- Fix parsing `Accept` parameters with quoted semicolons
- Lazy-load modules from main entry point
- perf: delay type concatenation until needed
- perf: enable strict mode
- perf: hoist regular expressions
- perf: remove closures getting spec properties
- perf: remove a closure from media type parsing
- perf: remove property delete from media type parsing
1.2.13 / 2015-09-06
===================
* deps: mime-types@~2.1.6
- deps: mime-db@~1.18.0
1.2.12 / 2015-07-30
===================
* deps: mime-types@~2.1.4
- deps: mime-db@~1.16.0
1.2.11 / 2015-07-16
===================
* deps: mime-types@~2.1.3
- deps: mime-db@~1.15.0
1.2.10 / 2015-07-01
===================
* deps: mime-types@~2.1.2
- deps: mime-db@~1.14.0
1.2.9 / 2015-06-08
==================
* deps: mime-types@~2.1.1
- perf: fix deopt during mapping
1.2.8 / 2015-06-07
==================
* deps: mime-types@~2.1.0
- deps: mime-db@~1.13.0
* perf: avoid argument reassignment & argument slice
* perf: avoid negotiator recursive construction
* perf: enable strict mode
* perf: remove unnecessary bitwise operator
1.2.7 / 2015-05-10
==================
* deps: negotiator@0.5.3
- Fix media type parameter matching to be case-insensitive
1.2.6 / 2015-05-07
==================
* deps: mime-types@~2.0.11
- deps: mime-db@~1.9.1
* deps: negotiator@0.5.2
- Fix comparing media types with quoted values
- Fix splitting media types with quoted commas
1.2.5 / 2015-03-13
==================
* deps: mime-types@~2.0.10
- deps: mime-db@~1.8.0
1.2.4 / 2015-02-14
==================
* Support Node.js 0.6
* deps: mime-types@~2.0.9
- deps: mime-db@~1.7.0
* deps: negotiator@0.5.1
- Fix preference sorting to be stable for long acceptable lists
1.2.3 / 2015-01-31
==================
* deps: mime-types@~2.0.8
- deps: mime-db@~1.6.0
1.2.2 / 2014-12-30
==================
* deps: mime-types@~2.0.7
- deps: mime-db@~1.5.0
1.2.1 / 2014-12-30
==================
* deps: mime-types@~2.0.5
- deps: mime-db@~1.3.1
1.2.0 / 2014-12-19
==================
* deps: negotiator@0.5.0
- Fix list return order when large accepted list
- Fix missing identity encoding when q=0 exists
- Remove dynamic building of Negotiator class
1.1.4 / 2014-12-10
==================
* deps: mime-types@~2.0.4
- deps: mime-db@~1.3.0
1.1.3 / 2014-11-09
==================
* deps: mime-types@~2.0.3
- deps: mime-db@~1.2.0
1.1.2 / 2014-10-14
==================
* deps: negotiator@0.4.9
- Fix error when media type has invalid parameter
1.1.1 / 2014-09-28
==================
* deps: mime-types@~2.0.2
- deps: mime-db@~1.1.0
* deps: negotiator@0.4.8
- Fix all negotiations to be case-insensitive
- Stable sort preferences of same quality according to client order
1.1.0 / 2014-09-02
==================
* update `mime-types`
1.0.7 / 2014-07-04
==================
* Fix wrong type returned from `type` when match after unknown extension
1.0.6 / 2014-06-24
==================
* deps: negotiator@0.4.7
1.0.5 / 2014-06-20
==================
* fix crash when unknown extension given
1.0.4 / 2014-06-19
==================
* use `mime-types`
1.0.3 / 2014-06-11
==================
* deps: negotiator@0.4.6
- Order by specificity when quality is the same
1.0.2 / 2014-05-29
==================
* Fix interpretation when header not in request
* deps: pin negotiator@0.4.5
1.0.1 / 2014-01-18
==================
* Identity encoding isn't always acceptable
* deps: negotiator@~0.4.0
1.0.0 / 2013-12-27
==================
* Genesis

View File

@@ -0,0 +1,23 @@
(The MIT License)
Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,140 @@
# accepts
[![NPM Version][npm-version-image]][npm-url]
[![NPM Downloads][npm-downloads-image]][npm-url]
[![Node.js Version][node-version-image]][node-version-url]
[![Build Status][github-actions-ci-image]][github-actions-ci-url]
[![Test Coverage][coveralls-image]][coveralls-url]
Higher level content negotiation based on [negotiator](https://www.npmjs.com/package/negotiator).
Extracted from [koa](https://www.npmjs.com/package/koa) for general use.
In addition to negotiator, it allows:
- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])`
as well as `('text/html', 'application/json')`.
- Allows type shorthands such as `json`.
- Returns `false` when no types match
- Treats non-existent headers as `*`
## Installation
This is a [Node.js](https://nodejs.org/en/) module available through the
[npm registry](https://www.npmjs.com/). Installation is done using the
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
```sh
$ npm install accepts
```
## API
```js
var accepts = require('accepts')
```
### accepts(req)
Create a new `Accepts` object for the given `req`.
#### .charset(charsets)
Return the first accepted charset. If nothing in `charsets` is accepted,
then `false` is returned.
#### .charsets()
Return the charsets that the request accepts, in the order of the client's
preference (most preferred first).
#### .encoding(encodings)
Return the first accepted encoding. If nothing in `encodings` is accepted,
then `false` is returned.
#### .encodings()
Return the encodings that the request accepts, in the order of the client's
preference (most preferred first).
#### .language(languages)
Return the first accepted language. If nothing in `languages` is accepted,
then `false` is returned.
#### .languages()
Return the languages that the request accepts, in the order of the client's
preference (most preferred first).
#### .type(types)
Return the first accepted type (and it is returned as the same text as what
appears in the `types` array). If nothing in `types` is accepted, then `false`
is returned.
The `types` array can contain full MIME types or file extensions. Any value
that is not a full MIME types is passed to `require('mime-types').lookup`.
#### .types()
Return the types that the request accepts, in the order of the client's
preference (most preferred first).
## Examples
### Simple type negotiation
This simple example shows how to use `accepts` to return a different typed
respond body based on what the client wants to accept. The server lists it's
preferences in order and will get back the best match between the client and
server.
```js
var accepts = require('accepts')
var http = require('http')
function app (req, res) {
var accept = accepts(req)
// the order of this list is significant; should be server preferred order
switch (accept.type(['json', 'html'])) {
case 'json':
res.setHeader('Content-Type', 'application/json')
res.write('{"hello":"world!"}')
break
case 'html':
res.setHeader('Content-Type', 'text/html')
res.write('<b>hello, world!</b>')
break
default:
// the fallback is text/plain, so no need to specify it above
res.setHeader('Content-Type', 'text/plain')
res.write('hello, world!')
break
}
res.end()
}
http.createServer(app).listen(3000)
```
You can test this out with the cURL program:
```sh
curl -I -H'Accept: text/html' http://localhost:3000/
```
## License
[MIT](LICENSE)
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/accepts/master
[coveralls-url]: https://coveralls.io/r/jshttp/accepts?branch=master
[github-actions-ci-image]: https://badgen.net/github/checks/jshttp/accepts/master?label=ci
[github-actions-ci-url]: https://github.com/jshttp/accepts/actions/workflows/ci.yml
[node-version-image]: https://badgen.net/npm/node/accepts
[node-version-url]: https://nodejs.org/en/download
[npm-downloads-image]: https://badgen.net/npm/dm/accepts
[npm-url]: https://npmjs.org/package/accepts
[npm-version-image]: https://badgen.net/npm/v/accepts

View File

@@ -0,0 +1,238 @@
/*!
* accepts
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/
'use strict'
/**
* Module dependencies.
* @private
*/
var Negotiator = require('negotiator')
var mime = require('mime-types')
/**
* Module exports.
* @public
*/
module.exports = Accepts
/**
* Create a new Accepts object for the given req.
*
* @param {object} req
* @public
*/
function Accepts (req) {
if (!(this instanceof Accepts)) {
return new Accepts(req)
}
this.headers = req.headers
this.negotiator = new Negotiator(req)
}
/**
* Check if the given `type(s)` is acceptable, returning
* the best match when true, otherwise `undefined`, in which
* case you should respond with 406 "Not Acceptable".
*
* The `type` value may be a single mime type string
* such as "application/json", the extension name
* such as "json" or an array `["json", "html", "text/plain"]`. When a list
* or array is given the _best_ match, if any is returned.
*
* Examples:
*
* // Accept: text/html
* this.types('html');
* // => "html"
*
* // Accept: text/*, application/json
* this.types('html');
* // => "html"
* this.types('text/html');
* // => "text/html"
* this.types('json', 'text');
* // => "json"
* this.types('application/json');
* // => "application/json"
*
* // Accept: text/*, application/json
* this.types('image/png');
* this.types('png');
* // => undefined
*
* // Accept: text/*;q=.5, application/json
* this.types(['html', 'json']);
* this.types('html', 'json');
* // => "json"
*
* @param {String|Array} types...
* @return {String|Array|Boolean}
* @public
*/
Accepts.prototype.type =
Accepts.prototype.types = function (types_) {
var types = types_
// support flattened arguments
if (types && !Array.isArray(types)) {
types = new Array(arguments.length)
for (var i = 0; i < types.length; i++) {
types[i] = arguments[i]
}
}
// no types, return all requested types
if (!types || types.length === 0) {
return this.negotiator.mediaTypes()
}
// no accept header, return first given type
if (!this.headers.accept) {
return types[0]
}
var mimes = types.map(extToMime)
var accepts = this.negotiator.mediaTypes(mimes.filter(validMime))
var first = accepts[0]
return first
? types[mimes.indexOf(first)]
: false
}
/**
* Return accepted encodings or best fit based on `encodings`.
*
* Given `Accept-Encoding: gzip, deflate`
* an array sorted by quality is returned:
*
* ['gzip', 'deflate']
*
* @param {String|Array} encodings...
* @return {String|Array}
* @public
*/
Accepts.prototype.encoding =
Accepts.prototype.encodings = function (encodings_) {
var encodings = encodings_
// support flattened arguments
if (encodings && !Array.isArray(encodings)) {
encodings = new Array(arguments.length)
for (var i = 0; i < encodings.length; i++) {
encodings[i] = arguments[i]
}
}
// no encodings, return all requested encodings
if (!encodings || encodings.length === 0) {
return this.negotiator.encodings()
}
return this.negotiator.encodings(encodings)[0] || false
}
/**
* Return accepted charsets or best fit based on `charsets`.
*
* Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5`
* an array sorted by quality is returned:
*
* ['utf-8', 'utf-7', 'iso-8859-1']
*
* @param {String|Array} charsets...
* @return {String|Array}
* @public
*/
Accepts.prototype.charset =
Accepts.prototype.charsets = function (charsets_) {
var charsets = charsets_
// support flattened arguments
if (charsets && !Array.isArray(charsets)) {
charsets = new Array(arguments.length)
for (var i = 0; i < charsets.length; i++) {
charsets[i] = arguments[i]
}
}
// no charsets, return all requested charsets
if (!charsets || charsets.length === 0) {
return this.negotiator.charsets()
}
return this.negotiator.charsets(charsets)[0] || false
}
/**
* Return accepted languages or best fit based on `langs`.
*
* Given `Accept-Language: en;q=0.8, es, pt`
* an array sorted by quality is returned:
*
* ['es', 'pt', 'en']
*
* @param {String|Array} langs...
* @return {Array|String}
* @public
*/
Accepts.prototype.lang =
Accepts.prototype.langs =
Accepts.prototype.language =
Accepts.prototype.languages = function (languages_) {
var languages = languages_
// support flattened arguments
if (languages && !Array.isArray(languages)) {
languages = new Array(arguments.length)
for (var i = 0; i < languages.length; i++) {
languages[i] = arguments[i]
}
}
// no languages, return all requested languages
if (!languages || languages.length === 0) {
return this.negotiator.languages()
}
return this.negotiator.languages(languages)[0] || false
}
/**
* Convert extnames to mime.
*
* @param {String} type
* @return {String}
* @private
*/
function extToMime (type) {
return type.indexOf('/') === -1
? mime.lookup(type)
: type
}
/**
* Check if mime is valid.
*
* @param {String} type
* @return {String}
* @private
*/
function validMime (type) {
return typeof type === 'string'
}

Some files were not shown because too many files have changed in this diff Show More