Compare commits

..

No commits in common. "4d690e2a2a52f692a34835c8beb4fc3031416227" and "3b4cbd8ae1a613e34072df89a7cf63eedf161fd4" have entirely different histories.

3 changed files with 59 additions and 68 deletions

View File

@ -19,19 +19,19 @@ const FAIL_CRITERIA = {
}; };
class Dimensions { class Dimensions {
constructor(width, depth, height) { constructor(length, width, height) {
this.length = length;
this.width = width; this.width = width;
this.depth = depth;
this.height = height; this.height = height;
} }
toString() { toString() {
return `${this.width}x${this.depth}x${this.height}`; return `${this.length}x${this.width}x${this.height}`;
} }
static fromDict(data) { static fromDict(data) {
const { width, depth, height } = data; const { length, width, height } = data;
return new Dimensions(width, depth, height); return new Dimensions(length, width, height);
} }
} }

View File

@ -152,15 +152,6 @@ label {
cursor: pointer; cursor: pointer;
} }
.card-photo label {
color: var(--text-one);
padding: 10px;
}
.measurement {
width: 100px;
}
.cage-selector { .cage-selector {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;

View File

@ -46,9 +46,8 @@
<div class="card"> <div class="card">
<div class="card-photo"> <div class="card-photo">
<input type="checkbox" id="tiaki"/>
<label for="form-cage-measurements">Käfigmaße</label> <form class="form-measurements">
<form id="form-cage-measurements" class="form-measurements">
<div class="input-measurement"> <div class="input-measurement">
<label for="width">Breite</label> <label for="width">Breite</label>
<input class="measurement" type="number" id="width"> <input class="measurement" type="number" id="width">
@ -63,6 +62,7 @@
</div> </div>
</form> </form>
</div> </div>
<label>Käfigmaße</label>
</div> </div>
</div> </div>
@ -86,73 +86,73 @@
<div class="container output-element" id="resultsDiv"> <div class="container output-element" id="resultsDiv">
</div> </div>
</div> </div>
</div>
<script>
var labelNumRats = document.getElementById("labelNumRats"); <script>
var ratSlider = document.getElementById("numRats"); var labelNumRats = document.getElementById("labelNumRats");
labelNumRats.innerHTML = `Anzahl an Ratten: ` + ratSlider.value; var ratSlider = document.getElementById("numRats");
ratSlider.oninput = function () { labelNumRats.innerHTML = `Anzahl an Ratten: ` + ratSlider.value;
labelNumRats.innerHTML = `Anzahl an Ratten: ` + this.value;
update();
}
// Full floor functions ratSlider.oninput = function () {
var fullFloorNum = document.getElementById("numFullFloors"); labelNumRats.innerHTML = `Anzahl an Ratten: ` + this.value;
update();
}
// Full floor functions
var fullFloorNum = document.getElementById("numFullFloors");
var savicSuiteRoyaleDim = new Dimensions(1, 0.5, 1); var savicSuiteRoyaleDim = new Dimensions(1, 0.5, 1);
function getResultFromChecks(checks) { function getResultFromChecks(checks) {
console.log(checks.length) console.log(checks.length)
if (Object.keys(checks).length > 0) { if (Object.keys(checks).length > 0) {
const ul = document.createElement('ul'); const ul = document.createElement('ul');
for (const key in checks) { for (const key in checks) {
const li = document.createElement('li'); const li = document.createElement('li');
li.textContent = `❌` + checks[key]; li.textContent = `❌` + checks[key];
ul.appendChild(li); ul.appendChild(li);
}
return ul;
} else {
const p = document.createElement('p');
p.innerHTML = "✅ Der Käfig erfüllt alle Kriterien!"
return p;
} }
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>`;
function update() { const result = getResultFromChecks(failed_checks);
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);
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 decreaseFloorNum() {
</script> 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();
</script>
</body> </body>
</html> </html>