This commit is contained in:
2025-11-14 17:30:19 +01:00
parent 5b19b729c4
commit 9ff15dd9f7
26 changed files with 1044 additions and 0 deletions

26
ora7/roxfort.js Normal file
View File

@@ -0,0 +1,26 @@
function calculateYearsSince(dateString) {
const date = new Date(dateString);
const diff = Date.now() - date.getTime();
return new Date(diff).getUTCFullYear() - 1970;
}
console.log(calculate2("2001-09-01"));
const form = document.getElementById('hogwarts-form');
form.dateofbirth.addEventListener("input", function(event){
console.log(form.dateofbirth.value);
const age = calculateYearsSince(form.dateofbirth.value);
console.log(age);
if(age >= 11){
form.dateofbirth.setCustomValidity('');
}else{
form.dateofbirth.setCustomValidity('young');
}
})
form.house.addEventListener('change', function (event){
const houseColor = form.house.options[form.house.selectedIndex].dataset.colorPrimary;
console.log(houseColor);
document.body.style.backgroundColor = houseColor;
})