const inputDecreaseFloorNum = document.getElementById("decreaseFloorNum"); inputDecreaseFloorNum.onclick = decreaseFloorNum; const inputIncreaseFloorNum = document.getElementById("increaseFloorNum"); inputIncreaseFloorNum.onclick = increaseFloorNum; const inputWidth = document.getElementById("width"); inputWidth.onchange = updateViaManualMeasurements; const inputDepth = document.getElementById("depth"); inputDepth.onchange = updateViaManualMeasurements; const inputHeight = document.getElementById("height"); inputHeight.onchange = updateViaManualMeasurements; const selectSavicSuiteRoyaleXL = document.getElementById("SavicSuiteRoyaleXL"); const selectSavicSuiteRoyale95Double = document.getElementById("SavicSuiteRoyale95Double"); const selectTiakiKleintierkäfigEtagere = document.getElementById("TiakiKleintierkäfigEtagere"); const cardSavicSuiteRoyaleXL = document.getElementById("card-SavicSuiteRoyaleXL"); const cardSavicSuiteRoyale95Double = document.getElementById("card-SavicSuiteRoyale95Double"); const cardTiakiKleintierkäfigEtagere = document.getElementById("card-TiakiKleintierkäfigEtagere"); function markActiveCage(cageName) { cardSavicSuiteRoyaleXL.classList.remove("card-active"); cardSavicSuiteRoyale95Double.classList.remove("card-active"); cardTiakiKleintierkäfigEtagere.classList.remove("card-active"); if (cageName != "") { const activeCage = document.getElementById("card-" + cageName); activeCage.classList.add("card-active") } } function updateCage(event) { selectSavicSuiteRoyaleXL.checked = false; selectSavicSuiteRoyale95Double.checked = false; selectTiakiKleintierkäfigEtagere.checked = false; const selectedCage = event.currentTarget selectedCage.checked = true; const cageName = selectedCage.id; console.log(cageName); var dim = getCageDimensions(cageName); inputWidth.value = dim.width; inputDepth.value = dim.depth; inputHeight.value = dim.height; markActiveCage(cageName); update(); } selectSavicSuiteRoyaleXL.onchange = updateCage; selectSavicSuiteRoyale95Double.onchange = updateCage; selectTiakiKleintierkäfigEtagere.onchange = updateCage; var labelNumRats = document.getElementById("labelNumRats"); var ratSlider = document.getElementById("numRats"); labelNumRats.innerHTML = `Anzahl an Ratten: ` + ratSlider.value; ratSlider.oninput = function () { labelNumRats.innerHTML = `Anzahl an Ratten: ` + this.value; update(); } // Full floor functions var fullFloorNum = document.getElementById("numFullFloors"); function getCageDimensions(cageName) { console.log(cageName); if (cageName == "SavicSuiteRoyaleXL") { return new Dimensions(115, 67.5, 153); } if (cageName == "SavicSuiteRoyale95Double") { return new Dimensions(95, 63, 120); } if (cageName == "TiakiKleintierkäfigEtagere") { return new Dimensions(93.5, 63, 141.2); } } function getResultFromChecks(checks) { console.log(checks.length) 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 updateViaManualMeasurements() { markActiveCage("ManualMeasurements"); update(); } function update() { const width = inputWidth.value const depth = inputDepth.value const height = inputHeight.value const dimensions = new Dimensions(width / 100, depth / 100, height / 100); const failed_checks = cageCheck(dimensions, ratSlider.value, fullFloorNum.value); console.log(failed_checks); let resultsDiv = document.getElementById("resultsDiv"); resultsDiv.innerHTML = `Ergebnis`; 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(); import i18next from "i18next"; import LanguageDetector from "i18next-browser-languagedetector"; import HttpApi from "i18next-http-backend"; async function initI18next() { // We use() the backend and await it to load // the translations from the network await i18next .use(HttpApi) .use(LanguageDetector) .init({ lng: "en", supportedLngs: ["en", "de"], nonExplicitSupportedLngs: true, fallbackLng: "en", debug: true, backend: { loadPath: "/lang/{{lng}}.json", }, }); } function translatePageElements() { const translatableElements = document.querySelectorAll( "[data-i18n-key]", ); translatableElements.forEach((el) => { const key = el.getAttribute("data-i18n-key"); el.innerHTML = i18next.t(key); }); } // ... function bindLocaleSwitcher(initialValue) { const switcher = document.querySelector( "[data-i18n-switcher]", ); switcher.value = initialValue; switcher.onchange = (e) => { i18next .changeLanguage(e.target.value) .then(translatePageElements); }; } (async function () { await initI18next(); translatePageElements(); bindLocaleSwitcher(i18next.resolvedLanguage); })();