Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
Added new contact form 
Changed readiness score to percentages
  • Loading branch information
mpgdd authored Aug 6, 2024
1 parent 935bac9 commit 3288e99
Showing 1 changed file with 51 additions and 36 deletions.
87 changes: 51 additions & 36 deletions calculators/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -445,15 +445,13 @@ <h3 class="text-xl font-bold mb-4">Learn more about my results</h3>
<div id="section-scores" class="space-y-4"></div>
</div>

<!-- Email Collection Section -->
<!-- Google Sheets Contact Form -->
<div class="mt-12 border-t pt-8">
<h3 class="text-xl font-bold mb-4">Feedback Opportunity</h3>
<p class="mb-4">We are excited for you to try out the Exit to Community Calculator! As this is an ongoing research project, we would be thrilled to get in touch to get your feedback on the tool. If you do not want to give feedback then no further data from you will be stored by this website.</p>

<form id="email-form">
<input type="email" id="email-input" required placeholder="Enter your email address" class="p-2 border rounded">
<button type="submit" class="bg-blue-500 text-white p-2 rounded">Submit</button>
</form>
<div class="w-full overflow-hidden">
<iframe src="https://docs.google.com/forms/d/e/1FAIpQLSdCIyjS7G0BsQY6yFw4_9UnolrBzZoq-Dufv_SDF-R_1QwRvg/viewform?embedded=true" width="100%" height="812" frameborder="0" marginheight="0" marginwidth="0">Wird geladen…</iframe>
</div>
</div>
</div>

Expand Down Expand Up @@ -663,23 +661,61 @@ <h3 class="text-xl font-bold mb-4">Feedback Opportunity</h3>
function updateLearnMoreContent() {
const sectionScores = document.getElementById('section-scores');

const sectionTotals = {
'Strategy & Planning': 439,
'Governance': 159,
'Internal Systems': 103,
'Leadership': 277,
'Participatory Culture': 356,
'Legal and Regulatory Requirements': 80
};

let scoresHtml = '';
radarData.labels.forEach((section, index) => {
const score = radarData.datasets[0].data[index].toFixed(2);
Object.entries(sectionTotals).forEach(([section, totalScore]) => {
let actualScore = 0;
let questionRange;

switch(section) {
case 'Strategy & Planning':
questionRange = Array.from({length: 8}, (_, i) => i + 1);
break;
case 'Governance':
questionRange = Array.from({length: 3}, (_, i) => i + 9);
break;
case 'Internal Systems':
questionRange = Array.from({length: 5}, (_, i) => i + 12);
break;
case 'Leadership':
questionRange = Array.from({length: 4}, (_, i) => i + 17);
break;
case 'Participatory Culture':
questionRange = Array.from({length: 6}, (_, i) => i + 21);
break;
case 'Legal and Regulatory Requirements':
questionRange = Array.from({length: 2}, (_, i) => i + 27);
break;
}

questionRange.forEach(q => {
if (answers[q] === 'yes') {
actualScore += questionValues[q];
}
});

const percentage = ((actualScore / totalScore) * 100).toFixed(2);

scoresHtml += `
<div class="bg-gray-100 p-4 rounded-lg">
<h4 class="font-bold text-lg mb-2">${section}: ${score}</h4>
<p>${getScoreDescription(section, score)}</p>
<h4 class="font-bold text-lg mb-2">${section}: ${percentage}%</h4>
<p>${getScoreDescription(percentage)}</p>
</div>
`;
});
sectionScores.innerHTML = scoresHtml;
}

function getScoreDescription(section, score) {
const maxScore = sectionTotals[Object.keys(sectionTotals)[radarData.labels.indexOf(section)]];
const percentage = (score / maxScore) * 100;

function getScoreDescription(percentage) {
percentage = parseFloat(percentage);
if (percentage >= 80) {
return "Excellent! You're well-prepared in this area.";
} else if (percentage >= 60) {
Expand All @@ -690,28 +726,7 @@ <h4 class="font-bold text-lg mb-2">${section}: ${score}</h4>
return "This area needs substantial attention before considering an exit to community.";
}
}

document.getElementById('email-form').addEventListener('submit', function(e) {
e.preventDefault();
const email = document.getElementById('email-input').value;
fetch('/submit-email', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ email: email }),
})
.then(response => response.text())
.then(data => {
alert('Thank you for your interest! We will be in touch soon.');
document.getElementById('email-input').value = '';
})
.catch((error) => {
console.error('Error:', error);
alert('An error occurred. Please try again.');
});
});
</script>
</body>

</html>
</html>

0 comments on commit 3288e99

Please sign in to comment.