Skip to content

Commit

Permalink
let's see if this works
Browse files Browse the repository at this point in the history
  • Loading branch information
tris committed Mar 11, 2024
1 parent 1767055 commit efd6648
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 1 deletion.
1 change: 0 additions & 1 deletion README.md

This file was deleted.

48 changes: 48 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Membership Fee Calculator</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Calculate Your Membership Fee</h1>
<form id="membershipForm">
<fieldset>
<legend>Membership Details</legend>
<label for="attendingLeague">Attending League:
<select name="attendingLeague" id="attendingLeague">
<option value="Sprint">Sprint</option>
<option value="XC">XC</option>
<option value="Both">Both</option>
</select>
</label>
<br>
<label for="sprintFlown">
<input type="checkbox" name="sprintFlown" id="sprintFlown">
Flown Sprint before?
</label>
<br>
<label for="xcFlown">
<input type="checkbox" name="xcFlown" id="xcFlown">
Flown XC before?
</label>
<br>
<label for="firstSprint">
<input type="checkbox" name="firstSprint" id="firstSprint">
Signing up before first Sprint?
</label>
<br>
<label for="firstXc">
<input type="checkbox" name="firstXc" id="firstXc">
Signing before first XC?
</label>
</fieldset>
<p id="membershipFee">
</p>
</form>
<script src="script.js"></script>
</body>
</html>
58 changes: 58 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
function calculateFee() {
const attendingLeague = document.getElementById("attendingLeague").value;
const sprintFlown = document.getElementById("sprintFlown").checked;
const xcFlown = document.getElementById("xcFlown").checked;
const firstSprint = document.getElementById("firstSprint").checked;
const firstXc = document.getElementById("firstXc").checked;

const membershipFee = getMembershipFee(
attendingLeague,
sprintFlown,
xcFlown,
firstSprint,
firstXc
);
document.getElementById(
"membershipFee"
).textContent = `Your membership fee is: $${membershipFee}`;
}

function getMembershipFee(attendingLeague, sprintFlown, xcFlown, firstSprint = true, firstXc = true) {
// First-time Sprint is free
if (attendingLeague === "Sprint" && !sprintFlown) {
return 0;
}

// First-time XC without Sprint is $25
if (attendingLeague === "XC" && !xcFlown && !sprintFlown) {
return 25;
}

// Sprint only or Both leagues with Sprint flown but not XC
if ((attendingLeague === "Sprint" || (attendingLeague === "Both" && sprintFlown && !xcFlown)) && firstSprint) {
return 25;
}

// XC only or Both leagues with both flown before
if (attendingLeague === "XC" || (attendingLeague === "Both" && sprintFlown && xcFlown)) {
return 50;
}

// Late Sprint renewal is $40
if (attendingLeague === "Sprint" && !firstSprint) {
return 40;
}

// Late XC renewal is $75
if (attendingLeague === "XC" && !firstXc) {
return 75;
}

// Default case, if none of the above conditions are met
return 50;
}


document.getElementById('membershipForm').addEventListener('change', calculateFee);

calculateFee();
25 changes: 25 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
body {
font-family: sans-serif;
margin: 40px;
}

fieldset {
border: 1px solid #ccc;
padding: 15px;
margin-bottom: 20px;
}

legend {
font-weight: bold;
padding: 5px;
}

label {
display: block;
margin-bottom: 5px;
}

#membershipFee {
font-weight: bold;
margin-top: 15px;
}

0 comments on commit efd6648

Please sign in to comment.