Compare commits

...

2 Commits

Author SHA1 Message Date
7167d275b6 feat: put out descriptive message if everything okay
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2024-07-18 23:59:08 +02:00
c8ecd4a809 fix: various styling/syntax 2024-07-18 23:58:42 +02:00
2 changed files with 69 additions and 52 deletions

View File

@ -41,6 +41,10 @@ h1, h2 {
margin: 20px; margin: 20px;
} }
.output-element {
margin: 20px;
}
label { label {
font-weight: bold; font-weight: bold;

View File

@ -16,75 +16,88 @@
<label for="numRats" id="labelNumRats">Anzahl an Ratten ?</label> <label for="numRats" id="labelNumRats">Anzahl an Ratten ?</label>
<input type="range" min="1" max="20" value="4" class="slider" id="numRats"> <input type="range" min="1" max="20" value="4" class="slider" id="numRats">
</div> </div>
</div>
<div class="input-element"> <div class="input-element">
<label for="numFullFloors">Vollebenen</label> <label for="numFullFloors">Vollebenen</label>
<div class="ncontainer"> <div class="ncontainer">
<div class="input-group"> <div class="input-group">
<button onclick="decreaseFloorNum()">-</button> <button onclick="decreaseFloorNum()">-</button>
<input type="text" id="numFullFloors" value="3" readonly> <input type="text" id="numFullFloors" value="3" readonly>
<button onclick="increaseFloorNum()">+</button> <button onclick="increaseFloorNum()">+</button>
</div>
</div> </div>
</div> </div>
<div class="container" id="resultsDiv"> </div>
</div> <div class="container output-element" id="resultsDiv">
</div> </div>
</div> </div>
</div>
<script> <script>
var labelNumRats = document.getElementById("labelNumRats"); var labelNumRats = document.getElementById("labelNumRats");
var ratSlider = document.getElementById("numRats"); var ratSlider = document.getElementById("numRats");
labelNumRats.innerHTML = `Anzahl an Ratten: ` + ratSlider.value; labelNumRats.innerHTML = `Anzahl an Ratten: ` + ratSlider.value;
ratSlider.oninput = function () { ratSlider.oninput = function () {
labelNumRats.innerHTML = `Anzahl an Ratten: ` + this.value; labelNumRats.innerHTML = `Anzahl an Ratten: ` + this.value;
update(); update();
}
// Full floor functions
var fullFloorNum = document.getElementById("numFullFloors");
var savicSuiteRoyaleDim = new Dimensions(1, 0.5, 1);
function update() {
var failed_checks = cageCheck(savicSuiteRoyaleDim, ratSlider.value, fullFloorNum.value);
var resultsDiv = document.getElementById("resultsDiv");
resultsDiv.innerHTML = `<strong>Ergebnis</strong>`;
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); // Full floor functions
} var fullFloorNum = document.getElementById("numFullFloors");
function decreaseFloorNum() { var savicSuiteRoyaleDim = new Dimensions(1, 0.5, 1);
var input = document.getElementById('numFullFloors');
var value = parseInt(input.value); function getResultFromChecks(checks) {
if (value > 0) { console.log(checks.length)
input.value = value - 1; if (Object.keys(checks).length > 0) {
const ul = document.createElement('ul');
for (const key in checks) {
const li = document.createElement('li');
li.textContent = `❌` + checks[key];
ul.appendChild(li);
}
return ul;
} else {
const p = document.createElement('p');
p.innerHTML = "✅ Der Käfig erfüllt alle Kriterien!"
return p;
}
}
function update() {
var failed_checks = cageCheck(savicSuiteRoyaleDim, ratSlider.value, fullFloorNum.value);
var resultsDiv = document.getElementById("resultsDiv");
resultsDiv.innerHTML = `<strong>Ergebnis</strong>`;
const result = getResultFromChecks(failed_checks);
resultsDiv.appendChild(result);
}
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();
} }
update();
}
function increaseFloorNum() {
var input = document.getElementById('numFullFloors');
var value = parseInt(input.value);
input.value = value + 1;
update(); update();
} </script>
update();
</script>
</body> </body>
</html> </html>