Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ const calculateBtn = document.getElementById('calculate');
+ const results = document.getElementById('results');
+ const meterFill = document.getElementById('meterFill');
+ const recommendation = document.getElementById('recommendation');
+ const factors = document.getElementById('factors');
+
+ calculateBtn.addEventListener('click', () => {
+ // Get all input values
+ const stipend = parseFloat(document.getElementById('stipend').value) || 0;
+ const years = parseFloat(document.getElementById('years').value) || 0;
+ const satisfaction = parseFloat(document.getElementById('satisfaction').value) || 5;
+ const publications = parseFloat(document.getElementById('publications').value) || 0;
+ const followers = parseFloat(document.getElementById('followers').value) || 0;
+ const marketability = parseFloat(document.getElementById('marketability').value) || 5;
+ const comfort = parseFloat(document.getElementById('comfort').value) || 5;
+
+ // Calculate academic score
+ const academicScore = calculateAcademicScore(stipend, years, satisfaction, publications);
+
+ // Calculate alternative career score
+ const alternativeScore = calculateAlternativeScore(followers, marketability, comfort);
+
+ // Calculate final decision score (0-100)
+ const finalScore = Math.min(100, Math.max(0, alternativeScore));
+
+ // Display results
+ results.style.display = 'block';
+ meterFill.style.width = `${finalScore}%`;
+
+ // Generate recommendation
+ const recommendationText = generateRecommendation(finalScore, academicScore, alternativeScore);
+ recommendation.textContent = recommendationText;
+
+ // Show contributing factors
+ displayFactors(stipend, followers, satisfaction, comfort);
+ });
+ });
+
+ function calculateAcademicScore(stipend, years, satisfaction, publications) {
+ const stipendScore = Math.min(50, (stipend / 50000) * 50);
+ const yearsScore = Math.max(0, 50 - years * 10);
+ const satisfactionScore = satisfaction * 10;
+ const publicationsScore = Math.min(50, publications * 10);
+
+ return (stipendScore + yearsScore + satisfactionScore + publicationsScore) / 4;
+ }
+
+ function calculateAlternativeScore(followers, marketability, comfort) {
+ const followerScore = Math.min(50, (followers / 10000) * 50);
+ const marketabilityScore = marketability * 10;
+ const comfortScore = comfort * 10;
+
+ return (followerScore + marketabilityScore + comfortScore) / 3;
+ }
+
+ function generateRecommendation(score, academicScore, alternativeScore) {
+ if (score < 40) {
+ return "Consider staying in academia. Your current path shows promise.";
+ } else if (score < 60) {
+ return "The decision is balanced. Consider exploring both paths simultaneously.";
+ } else {
+ return "Alternative career path shows strong potential. Consider careful transition planning.";
+ }
+ }
+
+ function displayFactors(stipend, followers, satisfaction, comfort) {
+ const factorsList = [
+ `Current stipend: $${stipend.toLocaleString()} annually`,
+ `Social media following: ${followers.toLocaleString()} followers`,
+ `Academic satisfaction: ${satisfaction}/10`,
+ `Career change comfort: ${comfort}/10`
+ ];
+
+ factors.innerHTML = factorsList
+ .map(factor => `
• ${factor}
`)
+ .join('');
+ }