Skip to content

Commit

Permalink
add: Task
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinSchneidder committed Nov 22, 2023
1 parent d6867f0 commit 65d123b
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
27 changes: 27 additions & 0 deletions 2of3/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css" />
<title>Document</title>
</head>

<body class="center" >
<div>
<div >
<input type="checkbox" id="fast" ></input><label for="fast">Fast</label>
</div>
<div >
<input type="checkbox" id="cheap"></input><label for="cheap">Cheap</label>
</div>
<div >
<input type="checkbox" id="good"></input><label for="good">Good</label>
</div>
</div>



<script src="script.js"></script>
</body>
</html>
39 changes: 39 additions & 0 deletions 2of3/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const checkFast = document.getElementById("fast");
const checkCheap = document.getElementById("cheap");
const checkGood = document.getElementById("good");
let lastTouched;

checkFast.addEventListener("change", function () {
if (numChecked() > 2) {
lastTouched.checked = false;
}
lastTouched = checkFast;
});

checkCheap.addEventListener("change", function () {
if (numChecked() > 2) {
lastTouched.checked = false;
}
lastTouched = checkCheap;
});

checkGood.addEventListener("change", function () {
if (numChecked() > 2) {
lastTouched.checked = false;
}
lastTouched = checkGood;
});

function numChecked() {
let res = 0;
if (checkFast.checked) {
res += 1;
}
if (checkCheap.checked) {
res += 1;
}
if (checkGood.checked) {
res += 1;
}
return res;
}
14 changes: 14 additions & 0 deletions 2of3/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.center {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
height: 100vh;

font-size: 2rem;
}

input {
margin: 2rem;
transform: translateY(-0.2rem) scale(2);
}

0 comments on commit 65d123b

Please sign in to comment.