RattenheimRechner/src/index.html

86 lines
2.4 KiB
HTML
Raw Normal View History

2024-07-18 17:51:24 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Knastrechner</title>
<link rel="stylesheet" href="assets/css/style.css">
<script src="assets/calculator.js"></script>
</head>
<body>
2024-07-18 18:00:58 +00:00
<h1>Käfigrechner</h1>
2024-07-18 17:51:24 +00:00
<div class="slidecontainer">
<input type="range" min="1" max="20" value="4" class="slider" id="numRats">
<label for="numRats">Anzahl an Ratten
<div id="outputNumRats"></div>
</label>
<div class="ncontainer">
<div class="input-group">
<button onclick="decreaseFloorNum()">-</button>
<input type="text" id="numFullFloors" value="3" readonly>
<button onclick="increaseFloorNum()">+</button>
</div>
</div>
<label for="numFullFloors">Vollebenen</label>
2024-07-18 17:51:24 +00:00
<div class="container" id="resultsDiv">
</div>
</div>
<script>
var outputFailedChecks = document.getElementById("failedChecks");
var ratSlider = document.getElementById("numRats");
var outputNumRats = document.getElementById("outputNumRats");
outputNumRats.innerHTML = ratSlider.value;
ratSlider.oninput = function () {
outputNumRats.innerHTML = this.value;
update();
}
// Full floor functions
var fullFloorNum = document.getElementById("numFullFloors");
2024-07-18 17:51:24 +00:00
var savicSuiteRoyaleDim = new Dimensions(1, 0.5, 1);
function update() {
var failed_checks = cageCheck(savicSuiteRoyaleDim, ratSlider.value, fullFloorNum.value);
2024-07-18 17:51:24 +00:00
var resultsDiv = document.getElementById("resultsDiv");
resultsDiv.innerHTML = `<strong>Werte</strong>: ${savicSuiteRoyaleDim.toString()} n(rats): ${ratSlider.value}, n(floors): ${fullFloorNum.value}`;
2024-07-18 17:51:24 +00:00
const ul = document.createElement('ul');
for (const key in failed_checks) {
const li = document.createElement('li');
li.textContent = failed_checks[key];
ul.appendChild(li);
}
resultsDiv.appendChild(ul);
outputFailedChecks.innerHTML = failed_checks;
}
function decreaseFloorNum() {
var input = document.getElementById('numFullFloors');
var value = parseInt(input.value);
if (value > 0) {
input.value = value - 1;
}
update();
}
function increaseFloorNum() {
var input = document.getElementById('numFullFloors');
var value = parseInt(input.value);
input.value = value + 1;
update();
}
2024-07-18 17:51:24 +00:00
</script>
</body>
</html>