Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ const calculateButton = document.getElementById('calculate');
+ const resultsDiv = document.getElementById('results');
+
+ calculateButton.addEventListener('click', () => {
+ // Get PhD path inputs
+ const stipend = parseFloat(document.getElementById('stipend').value);
+ const yearsRemaining = parseFloat(document.getElementById('years-remaining').value);
+ const postPhdSalary = parseFloat(document.getElementById('post-phd-salary').value);
+
+ // Get creator path inputs
+ const expectedSubs = parseFloat(document.getElementById('expected-subs').value);
+ const subPrice = parseFloat(document.getElementById('sub-price').value);
+ const platformCut = parseFloat(document.getElementById('platform-cut').value) / 100;
+
+ // Calculate 5-year projections
+ const phdProjection = calculatePhdProjection(stipend, yearsRemaining, postPhdSalary);
+ const creatorProjection = calculateCreatorProjection(expectedSubs, subPrice, platformCut);
+
+ // Display results
+ displayResults(phdProjection, creatorProjection);
+ resultsDiv.classList.remove('hidden');
+ });
+
+ function calculatePhdProjection(stipend, yearsRemaining, postPhdSalary) {
+ let total = 0;
+ for (let year = 1; year <= 5; year++) {
+ if (year <= yearsRemaining) {
+ total += stipend;
+ } else {
+ total += postPhdSalary;
+ }
+ }
+ return total;
+ }
+
+ function calculateCreatorProjection(subs, price, platformCut) {
+ const monthlyRevenue = subs * price * (1 - platformCut);
+ const yearlyRevenue = monthlyRevenue * 12;
+ // Assume 20% subscriber growth each year
+ return Array(5).fill(0).reduce((total, _, index) => {
+ return total + yearlyRevenue * Math.pow(1.2, index);
+ }, 0);
+ }
+
+ function displayResults(phdTotal, creatorTotal) {
+ const phdDiv = document.getElementById('phd-projection');
+ const creatorDiv = document.getElementById('creator-projection');
+ const recommendationDiv = document.getElementById('recommendation');
+
+ phdDiv.innerHTML = `
+
PhD Path Total:
+
$${phdTotal.toLocaleString()}
+ `;
+
+ creatorDiv.innerHTML = `
+
Creator Path Total:
+
$${creatorTotal.toLocaleString()}
+ `;
+
+ const difference = creatorTotal - phdTotal;
+ const recommendation = difference > 0
+ ? 'Based purely on financial projections, the creator path shows higher earning potential.'
+ : 'Based purely on financial projections, completing your PhD shows higher earning potential.';
+
+ recommendationDiv.innerHTML = `
+
Remember to consider non-financial factors in your decision.
+ `;
+ }
+ });