Changed around line 1
+ document.getElementById('familyForm').addEventListener('submit', function(event) {
+ event.preventDefault();
+ const familyName = document.getElementById('familyName').value;
+ const firstName = document.getElementById('firstName').value;
+
+ const familyMembers = generateFamilyTree(familyName, firstName);
+ displayFamilyTree(familyMembers);
+ });
+
+ function generateFamilyTree(familyName, firstName) {
+ const jobsParents = ["butcher", "blacksmith", "medic", "librarian", "trainer", "guard", "sweeper", "host", "merchant", "administration", "sewer", "lumberjack", "miner", "tailor"];
+ const jobsChildren = ["student at the academy", "training as a civilian"];
+
+ const familyMembers = [
+ { name: `Grandfather ${familyName}`, relationship: 'Grandfather', age: getRandomAge(60, 70), occupation: jobsParents[Math.floor(Math.random() * jobsParents.length)] },
+ { name: `Grandmother ${familyName}`, relationship: 'Grandmother', age: getRandomAge(60, 70), occupation: jobsParents[Math.floor(Math.random() * jobsParents.length)] },
+ { name: `Father ${familyName}`, relationship: 'Father', age: getRandomAge(30, 40), occupation: jobsParents[Math.floor(Math.random() * jobsParents.length)] },
+ { name: `Mother ${familyName}`, relationship: 'Mother', age: getRandomAge(30, 40), occupation: jobsParents[Math.floor(Math.random() * jobsParents.length)] },
+ { name: `Uncle ${familyName}`, relationship: 'Uncle', age: getRandomAge(30, 40), occupation: jobsParents[Math.floor(Math.random() * jobsParents.length)] },
+ { name: `Aunt ${familyName}`, relationship: 'Aunt', age: getRandomAge(30, 40), occupation: jobsParents[Math.floor(Math.random() * jobsParents.length)] },
+ { name: `${firstName} ${familyName}`, relationship: 'You', age: getRandomAge(10, 20), occupation: jobsChildren[Math.floor(Math.random() * jobsChildren.length)] },
+ { name: `Brother ${familyName}`, relationship: 'Brother', age: getRandomAge(10, 20), occupation: jobsChildren[Math.floor(Math.random() * jobsChildren.length)] },
+ { name: `Sister ${familyName}`, relationship: 'Sister', age: getRandomAge(10, 20), occupation: jobsChildren[Math.floor(Math.random() * jobsChildren.length)] },
+ { name: `Cousin ${familyName}`, relationship: 'Cousin', age: getRandomAge(10, 20), occupation: jobsChildren[Math.floor(Math.random() * jobsChildren.length)] }
+ ];
+
+ return familyMembers;
+ }
+
+ function displayFamilyTree(familyMembers) {
+ const treeContainer = document.getElementById('treeContainer');
+ const tree = document.getElementById('tree');
+ tree.innerHTML = '';
+
+ familyMembers.forEach(member => {
+ const memberDiv = document.createElement('div');
+ memberDiv.className = 'family-member';
+ memberDiv.innerHTML = `
+
${member.name}
+
Relationship: ${member.relationship}
+
Occupation: ${member.occupation}
+ `;
+ tree.appendChild(memberDiv);
+ });
+
+ treeContainer.classList.remove('hidden');
+ }
+
+ function getRandomAge(min, max) {
+ return Math.floor(Math.random() * (max - min + 1)) + min;
+ }