Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ const calculateBtn = document.getElementById('calculateBtn');
+ const result = document.getElementById('result');
+ const meterFill = document.getElementById('meterFill');
+ const resultText = document.getElementById('resultText');
+ const adviceText = document.getElementById('advice');
+
+ calculateBtn.addEventListener('click', () => {
+ const redFlags = parseInt(document.getElementById('redFlags').value);
+ const communication = parseInt(document.getElementById('communication').value);
+ const trust = parseInt(document.getElementById('trustLevel').value);
+ const desires = parseInt(document.getElementById('desireAlignment').value);
+
+ // Calculate compatibility score (0-100)
+ let score = Math.round(
+ ((10 - redFlags) * 2.5 +
+ communication * 3 +
+ trust * 3 +
+ desires * 5) / 2
+ );
+
+ // Ensure score stays within bounds
+ score = Math.max(0, Math.min(100, score));
+
+ // Show result with animation
+ result.classList.remove('hidden');
+ meterFill.style.width = `${score}%`;
+
+ // Generate result text
+ let resultMessage, advice;
+ if (score >= 80) {
+ resultMessage = `¡Muy bien! ${score}% compatibility score suggests strong potential!`;
+ advice = "Consider taking this relationship to the next level, but maintain healthy boundaries.";
+ } else if (score >= 60) {
+ resultMessage = `${score}% compatibility - There's promise, but proceed with caution.`;
+ advice = "Focus on improving communication and building trust gradually.";
+ } else if (score >= 40) {
+ resultMessage = `${score}% compatibility - Some significant concerns detected.`;
+ advice = "Carefully evaluate if the challenges can be overcome. Consider discussing your concerns openly.";
+ } else {
+ resultMessage = `${score}% compatibility - Major red flags detected.`;
+ advice = "It might be wise to reconsider this relationship or seek relationship counseling.";
+ }
+
+ resultText.textContent = resultMessage;
+ adviceText.textContent = advice;
+
+ // Smooth scroll to result
+ result.scrollIntoView({ behavior: 'smooth' });
+ });
+
+ // Add input validation
+ document.getElementById('redFlags').addEventListener('input', (e) => {
+ e.target.value = Math.max(0, Math.min(10, e.target.value));
+ });
+ });