2024-10-08 11:04:28 +00:00
|
|
|
let randomszamok = [];
|
|
|
|
|
|
|
|
document.getElementById("gomb").addEventListener("click", function () {
|
|
|
|
let szam = document.getElementById("szam").value;
|
|
|
|
|
2024-10-09 16:51:49 +00:00
|
|
|
if (typecheck(szam)) {
|
2024-10-08 11:04:28 +00:00
|
|
|
szam = parseInt(szam);
|
2024-10-09 16:51:49 +00:00
|
|
|
promise_shit(szam);
|
|
|
|
} else {
|
2024-10-08 11:04:28 +00:00
|
|
|
hibasbemenet();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2024-10-09 16:51:49 +00:00
|
|
|
let hibasbemenet = () => {
|
2024-10-08 11:04:28 +00:00
|
|
|
alert("HIBÁS BEMENET");
|
|
|
|
}
|
|
|
|
|
2024-10-09 16:51:49 +00:00
|
|
|
let typecheck = (szam1) => {
|
|
|
|
if (szam1 == "") {
|
2024-10-08 11:04:28 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-10-09 16:51:49 +00:00
|
|
|
let randomszamokkiir = (karakterlanc) => {
|
|
|
|
document.getElementById("generaltszamok").innerHTML = karakterlanc;
|
|
|
|
}
|
|
|
|
|
|
|
|
function promise_shit(counter) {
|
|
|
|
let myPromise = new Promise((resolve, reject) => {
|
|
|
|
let success = true;
|
|
|
|
|
|
|
|
for (let index = 0; index < counter; index++) {
|
|
|
|
let randnum = parseInt(Math.random() * 100);
|
|
|
|
randomszamok.push(randnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
if (success) {
|
|
|
|
resolve(`A véletlen számok: ${randomszamok.join(', ')}`);
|
|
|
|
} else {
|
|
|
|
reject("Hiba történt.");
|
|
|
|
}
|
|
|
|
}, 2000);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
let eredmeny = myPromise
|
|
|
|
.then(result => {
|
|
|
|
console.log(result);
|
|
|
|
randomszamokkiir(result);
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
console.error(error);
|
|
|
|
});
|
|
|
|
//console.log(eredmeny);
|
|
|
|
}
|
|
|
|
|