Otodik vizsga

This commit is contained in:
2024-11-28 16:33:27 +01:00
parent fedf227578
commit cfbc1bb80a
10 changed files with 130 additions and 0 deletions

View File

@ -0,0 +1,11 @@
console.log("Loaded");
function update(){
console.log("UPDATED!");
}
function NewLine() {
var newline = document.getElementById("inprow");
var clonedRow = newline.cloneNode(true); // Clone the row (true means deep clone, copying all children)
document.getElementById("maintable").appendChild(clonedRow); // Append the cloned row to the table
}

View File

Binary file not shown.

View File

@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Óraállások rögzítése</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>km-számlálók állásának rögzítése</h1>
<form action="" id="former">
<label for="plate">Rendszám: </label>
<input type="text" name="" id="plate" required pattern="[a-zA-Z]{3}[0-9]{3}" list="valaszlista" autocomplete="off">
<datalist id="valaszlista">
</datalist>
<br>
<label for="date">Leolvasás dátum: </label>
<input type="date" name="" id="date" required>
<br>
<label for="amount">Óraállás: </label>
<input type="number" name="" id="amount" required min="0">
<br>
<button type="submit" id="save">Mentés</button>
</form>
<div class="liststyle">
<h2>A jármű eddig rögzített km-óra állásai:</h2>
<ol id="korabbiallasok">
</ol>
</div>
<script src="./script.js"></script>
</body>
</html>

View File

@ -0,0 +1,68 @@
class auto {
constructor(rendszam) {
this.rendszam = rendszam;
this.amount = [];
this.date = [];
}
addkm(amount, date) {
this.amount.push(amount);
this.date.push(date);
}
getrendszam() {
return this.rendszam;
}
getamount() {
return this.amount;
}
}
var autok = [];
document.addEventListener("DOMContentLoaded", function () {
document.getElementById("former").addEventListener("submit", function (event) {
event.preventDefault();
const plate = document.getElementById("plate").value;
const date = document.getElementById("date").value;
const amount = document.getElementById("amount").value;
console.log("Plate:", plate);
console.log("Date:", date);
console.log("Amount:", amount);
let found = -1;
const valaszlista = document.getElementById("valaszlista");
valaszlista.innerHTML = "";
for (let i = 0; i < autok.length; i++) {
if (autok[i].getrendszam() === plate) {
found = i;
break;
}
valaszlista.innerHTML += `<option>${autok[i].getrendszam()}</option>`;
}
if (found === -1) {
const a = new auto(plate);
a.addkm(amount, date);
autok.push(a);
found = autok.length - 1;
} else {
autok[found].addkm(amount, date);
}
const korabbiallasok = document.getElementById("korabbiallasok");
korabbiallasok.innerHTML = "";
for (let i = 0; i < autok[found].getamount().length; i++) {
korabbiallasok.innerHTML += `<li>${autok[found].getamount()[i]}</li>`;
}
for (let i = 0; i < autok.length; i++) {
valaszlista.innerHTML += `<option>${autok[i].getrendszam()}</option>`;
}
});
});

View File

@ -0,0 +1,19 @@
h1{
font-family: Arial, Helvetica, sans-serif;
/* border-bottom: 1px solid;
width: fit-content; */
text-decoration:underline;
color: blue;
font-style: italic;
font-size: 24pt;
}
ol{
list-style-type:lower-roman;
}
.liststyle{
border: 5px dashed black;
padding: 0.5cm;
width: fit-content;
height: fit-content;
margin-top: 1cm;
}

Binary file not shown.