This commit is contained in:
molnarroland 2022-12-14 11:22:23 +01:00
commit 26d3bc5b12
3 changed files with 147 additions and 0 deletions

22
index.html Normal file
View File

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="hu">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Színházjegyek</title>
</head>
<body>
<div class="container">
<script src="script.js"></script>
</div>
</body>
</html>

69
script.js Normal file
View File

@ -0,0 +1,69 @@
hely = new Array()
for( i=1; i<=15; i++ )
{
if(i== 1) document.write("<span class='helyar'>7500.- Ft</span>")
if(i== 6) document.write("<span class='helyar'>5900.- Ft</span>")
if(i==11) document.write("<span class='helyar'>4500.- Ft</span>")
hely[i] = new Array()
document.write("<span class='sorszam'>" + i + ".</span>")
for( j=1; j<=24; j++ )
{
hely[i][j] = Math.floor( (1-Math.random()*Math.random())*2 )
if( hely[i][j]==1 )
{
document.write("<span class='szek foglalt' title='hely[" + i + "][" + j + "] = " + hely[i][j] + "'>" + j + "</span>")
}
else
{
document.write("<span class='szek szabad' title='hely[" + i + "][" + j + "] = " + hely[i][j] + "'>" + j + "</span>")
}
}
document.write("<br>")
if(i%5==0) document.write("<hr size=1 color=#880000>")
}
let hely1 = [
[1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
];
let szabadHelyek = 0;
let eladottJegyekSzazaleka = 0;
let jegyArbevetel = 0;
for (let i = 0; i < hely1.length; i++) {
for (let j = 0; j < hely1[i].length; j++) {
if (hely1[i][j] == 0) {
szabadHelyek++;
}
else {
eladottJegyekSzazaleka++;
if (i <= 4) {
jegyArbevetel += 1000;
}
else if (i > 4 && i <= 8) {
jegyArbevetel += 800;
}
else {
jegyArbevetel += 500;
}
}
}
}
document.write("Hány szabad hely van még? - " + szabadHelyek + "<br>");
document.write("A jegyek hány százaléka kelt már el? - " + (eladottJegyekSzazaleka / (hely1.length * hely1[0].length) * 100).toFixed(2) + "% <br>");
document.write("Mennyi az eddigi jegyárbevétel? - " + jegyArbevetel + "Ft <br>");

56
style.css Normal file
View File

@ -0,0 +1,56 @@
div#szinhazterem
{
max-width : 620px ;
margin : 0 auto ;
}
span.helyar
{
display : inline-block ;
float : right ;
margin : 40px -24px 0 0 ;
width : 128px ;
height : 60px ;
line-height : 60px ;
background-color : #AAF ;
text-align : center ;
font-size : 16px ;
font-weight : bold ;
transform : rotate(-90deg) ;
}
span.sorszam
{
display : inline-block ;
width : 24px ;
height : 14px ;
margin-right : 8px ;
text-align : right ;
}
span.szek
{
display : inline-block ;
margin : 6px 2px ;
width : 14px ;
height : 14px ;
border-radius : 2px ;
text-align : center ;
line-height : 14px ;
font-size : 9px ;
color : #333 ;
}
span.foglalt
{
border : solid 1px #844 ;
background-color : #FAA ;
color : #600 ;
}
span.szabad
{
border : solid 1px #484 ;
background-color : #8D8 ;
color : #040 ;
}