/* --- Global Styles & Variables (Adapted from HoNOSCA Style) --- */ :root { /* HoNOSCA's Color Palette - Renamed for MMSE context */ --scale-bg: #f0f7f7; /* Very light cyan background */ --scale-card-bg: #ffffff; --scale-text-primary: #2d3748; /* Dark grey */ --scale-text-secondary: #5a6a85; /* Medium grey */ --scale-accent-primary: #00a0b0; /* Teal */ --scale-accent-secondary: #4ecdc4; /* Lighter Teal/Mint */ --scale-highlight: #ff9f1c; /* Orange highlight (used for Reset button) */ --scale-border: #d8e2e2; --scale-shadow: 0 8px 25px rgba(0, 160, 176, 0.1); --scale-radius-main: 15px; /* HoNOSCA's main radius */ --scale-radius-small: 10px; /* Slightly smaller radius */ --scale-transition: all 0.3s ease-in-out; --scale-font: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif; /* HoNOSCA's Font Stack *//* Interpretation Colors from Original MMSE (Kept for clinical meaning, adjusted for light theme) */ /* Ensuring contrast on light backgrounds */ --int-no-impairment-bg: #4caf50; /* Green */ --int-no-impairment-text: #ffffff; --int-mild-bg: #ffc107; /* Amber */ --int-mild-text: #2d3748; /* Dark text for light yellow */ --int-moderate-bg: #ff9800; /* Orange */ --int-moderate-text: #2d3748; /* Dark text for orange */ --int-severe-bg: #f44336; /* Red */ --int-severe-text: #ffffff; --int-calculating-bg: #e6f5f7; /* Light teal bg from HoNOSCA */ --int-calculating-text: var(--scale-text-secondary); --scale-instruction-border: var(--scale-accent-primary); /* Use teal for instruction border */ }*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }/* Base Body Styling (Simulated if inside WP block) */ /* Apply these styles to the container holding the WP block if possible */ /* For demonstration, applying some base to the wrapper */ .mmse-scale-wrapper { font-family: var(--scale-font); background-color: var(--scale-bg); /* Use the light cyan page background */ color: var(--scale-text-primary); line-height: 1.6; padding: 30px; /* Generous padding */ border-radius: var(--scale-radius-main); /* Rounded corners for the whole container */ max-width: 950px; /* Keep original max-width */ width: 100%; margin: 30px auto; /* Centering */ box-shadow: var(--scale-shadow); border: 1px solid var(--scale-border); position: relative; }/* Header Styling (Adopted from HoNOSCA) */ .mmse-header { text-align: center; margin-bottom: 30px; /* Spacing */ padding-bottom: 15px; border-bottom: 2px solid var(--scale-accent-secondary); /* Light Teal border */ } .mmse-header h2 { font-size: clamp(1.8em, 5vw, 2.4em); font-weight: 600; margin: 0 0 8px 0; color: var(--scale-accent-primary); /* Teal title */ } .mmse-header p { font-size: clamp(0.95em, 2.5vw, 1.05em); color: var(--scale-text-secondary); /* Medium grey description */ max-width: 700px; margin: 0 auto; line-height: 1.6; }/* Patient Info Styling (Adopted from HoNOSCA input/card style) */ .mmse-patient-info { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; /* Spacing */ margin-bottom: 30px; padding: 20px; background: var(--scale-card-bg); /* White card background */ border-radius: var(--scale-radius-small); border: 1px solid var(--scale-border); box-shadow: 0 4px 15px rgba(0,0,0,0.05); /* Subtle shadow */ } .mmse-patient-info label { display: block; font-weight: 600; color: var(--scale-text-primary); margin-bottom: 8px; font-size: 0.9em; text-transform: uppercase; letter-spacing: 0.5px; } .mmse-patient-info input { width: 100%; padding: 10px 12px; border: 1px solid var(--scale-border); background-color: #ffffff; color: var(--scale-text-primary); border-radius: 8px; /* Slightly smaller radius for inputs */ font-size: 1em; font-family: inherit; transition: var(--scale-transition); box-shadow: inset 0 1px 2px rgba(0,0,0,0.05); } .mmse-patient-info input::placeholder { color: var(--scale-text-secondary); opacity: 0.8; } .mmse-patient-info input:focus { outline: none; border-color: var(--scale-accent-primary); /* Teal focus border */ box-shadow: 0 0 0 3px rgba(0, 160, 176, 0.2); /* Teal focus glow */ } .mmse-patient-info input[type="date"] { color: var(--scale-text-secondary); } .mmse-patient-info input[type="date"]:focus, .mmse-patient-info input[type="date"]:valid { color: var(--scale-text-primary); }/* Items Grid Layout */ .mmse-items-grid { display: grid; grid-template-columns: 1fr; gap: 20px; background: var(--scale-card-bg); /* Items section on white card */ padding: 25px; border-radius: var(--scale-radius-small); box-shadow: 0 4px 15px rgba(0,0,0,0.05); }/* Individual Item Styling (Adopted from HoNOSCA item style) */ .mmse-item { background-color: #f8fbfb; /* Slightly off-white item bg */ border: 1px solid var(--scale-border); border-radius: var(--scale-radius-small); padding: 15px 20px; /* Adjusted padding */ transition: var(--scale-transition); position: relative; overflow: hidden; } .mmse-item:hover { border-color: var(--scale-accent-secondary); box-shadow: 0 2px 8px rgba(0, 160, 176, 0.1); /* Subtle teal shadow */ }/* Item Header Styling */ .mmse-item-header { display: flex; align-items: flex-start; /* Align icon top */ gap: 15px; margin-bottom: 15px; } .mmse-item-icon { font-size: 1.7em; color: var(--scale-accent-primary); /* Teal icon */ margin-top: 2px; /* Align better with text */ flex-shrink: 0; width: 35px; text-align: center; } .mmse-item-title-container { flex-grow: 1; } .mmse-item-title { color: var(--scale-text-primary); font-size: clamp(1.15em, 4vw, 1.3em); /* Adjusted size */ font-weight: 600; margin: 0 0 5px 0; } .mmse-item-max-score { /* Style like a small tag/pill */ font-size: 0.75em; font-weight: 600; color: var(--scale-accent-primary); /* Teal text */ background-color: #e6f5f7; /* Light teal bg */ padding: 3px 10px; border-radius: 15px; /* Pill shape */ display: inline-block; margin-left: 10px; vertical-align: middle; border: 1px solid var(--scale-accent-secondary); }/* Instruction Styling (Adopted from HoNOSCA instruction style) */ .mmse-item-instruction { font-size: clamp(0.95em, 2.8vw, 1.0em); color: #005f6b; /* Darker teal text for contrast */ margin-bottom: 20px; padding: 12px 18px; background-color: #e6f5f7; /* Light teal bg */ border-radius: 8px; /* Consistent radius */ border-left: 4px solid var(--scale-instruction-border); /* Teal accent border */ line-height: 1.6; } .mmse-item-instruction strong { color: var(--scale-accent-primary); /* Teal for emphasis */ font-weight: 600; } .mmse-item-instruction code { background-color: rgba(0, 160, 176, 0.1); padding: 2px 6px; border-radius: 4px; font-family: 'Courier New', Courier, monospace; font-size: 0.95em; color: var(--scale-accent-primary); border: 1px solid var(--scale-accent-secondary); }/* Note Styling */ .mmse-item-note { font-size: 0.9em; color: var(--scale-text-secondary); margin-top: 15px; padding: 10px 15px; background-color: #f0f7f7; /* Very light cyan bg */ border-radius: 8px; border-left: 3px solid var(--scale-text-secondary); /* Grey border */ line-height: 1.5; font-style: italic; } .mmse-item-note input[type="number"] { /* Style inline inputs */ width: 60px; padding: 5px 8px; font-size: 0.95em; border: 1px solid var(--scale-border); border-radius: 4px; margin-left: 8px; text-align: center; background-color: #ffffff; color: var(--scale-text-primary); transition: var(--scale-transition); } .mmse-item-note input[type="number"]:focus { border-color: var(--scale-accent-primary); outline: none; box-shadow: 0 0 0 2px rgba(0, 160, 176, 0.2); }/* Score Options Container */ .mmse-score-options { display: flex; flex-wrap: wrap; gap: 12px; /* Spacing between options */ margin-top: 20px; padding: 10px; background-color: #e6f5f7; /* Light teal background for options area, similar to HoNOSCA */ border-radius: 8px; } .mmse-score-options > label { /* Label for number/recall options */ width: 100%; font-size: 0.85em; font-weight: 600; color: var(--scale-text-primary); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.5px; padding-left: 5px; /* Align with options */ }/* Base style for all option buttons (Inspired by HoNOSCA radios/controls) */ .mmse-point-option, .mmse-binary-option, .mmse-number-option { background: var(--scale-card-bg); /* White base */ border: 2px solid var(--scale-accent-secondary); /* Light teal border */ border-radius: 8px; cursor: pointer; transition: var(--scale-transition); color: var(--scale-text-primary); font-weight: 500; box-shadow: 0 1px 3px rgba(0,0,0,0.05); text-align: center; position: relative; /* For pseudo-elements if needed */ padding: 8px 12px; font-size: 0.95em; } .mmse-point-option:hover, .mmse-binary-option:hover, .mmse-number-option:hover { border-color: var(--scale-accent-primary); /* Teal border on hover */ background-color: #f8fbfb; /* Slightly off-white hover */ color: var(--scale-accent-primary); transform: translateY(-1px); box-shadow: 0 2px 5px rgba(0,0,0,0.1); } /* Selected state mimics HoNOSCA checked radio */ .mmse-point-option.selected, .mmse-binary-option.selected, .mmse-number-option.selected { background: var(--scale-accent-primary); /* Teal background */ border-color: var(--scale-accent-primary); color: #ffffff; font-weight: 600; box-shadow: 0 2px 6px rgba(0, 160, 176, 0.3); transform: translateY(0px); }/* Specific option styles */ .mmse-point-option { /* Multi-select toggle */ display: inline-flex; align-items: center; gap: 8px; flex-grow: 1; justify-content: center; min-width: 90px; } /* Adding a visual indicator like HoNOSCA radios */ .mmse-point-option::before { content: ''; width: 14px; height: 14px; border: 2px solid var(--scale-accent-secondary); border-radius: 50%; display: inline-block; margin-right: 8px; transition: var(--scale-transition); background-color: transparent; flex-shrink: 0; } .mmse-point-option:hover::before { border-color: var(--scale-accent-primary); } .mmse-point-option.selected::before { background-color: #ffffff; /* White fill when selected */ border-color: var(--scale-accent-primary); /* Keep outer border teal */ } /* Hide default text decoration */ .mmse-point-option span { z-index: 1; position: relative; }.mmse-binary-option { /* Yes/No style options */ flex-grow: 1; flex-basis: 140px; /* Allow side-by-side */ display: flex; align-items: center; justify-content: center; gap: 8px; } .mmse-binary-option .score-value { /* Style the score number */ font-weight: bold; background: rgba(45, 55, 72, 0.1); color: var(--scale-text-primary); padding: 2px 6px; border-radius: 4px; font-size: 0.9em; transition: var(--scale-transition); border: 1px solid transparent; } .mmse-binary-option.selected .score-value { background: rgba(255, 255, 255, 0.2); color: #ffffff; border: 1px solid rgba(255, 255, 255, 0.3); }.mmse-number-option { /* Circular number options */ border-radius: 50%; /* Make it circular */ width: 42px; height: 42px; display: flex; align-items: center; justify-content: center; font-size: 1.05em; font-weight: 600; flex-shrink: 0; padding: 0; /* Override padding */ } .mmse-number-option:hover { transform: scale(1.05) translateY(-1px); } .mmse-number-option.selected { transform: scale(1.1); /* Pop effect */ }/* Results Section Styling (Adopted from HoNOSCA results section) */ .mmse-results { margin-top: 35px; padding: 25px 30px; background: var(--scale-card-bg); /* White card background */ border-radius: var(--scale-radius-main); box-shadow: 0 4px 15px rgba(0,0,0,0.05); border: 1px solid var(--scale-border); text-align: center; border-top: 4px solid var(--scale-accent-primary); /* Teal top border */ } .mmse-results h3 { color: var(--scale-accent-primary); margin-bottom: 20px; font-size: clamp(1.4em, 4.5vw, 1.6em); font-weight: 600; text-transform: uppercase; letter-spacing: 1px; } /* Total Score Display (Inspired by HoNOSCA prominent score) */ .mmse-total-score-display { font-size: clamp(3.2em, 10vw, 4.5em); /* Large size */ font-weight: 700; margin-bottom: 10px; line-height: 1; color: var(--scale-accent-primary); /* Teal score */ display: inline-block; background-color: #e6f5f7; /* Light teal bg for emphasis */ padding: 10px 25px; border-radius: var(--scale-radius-small); box-shadow: 0 2px 8px rgba(0, 160, 176, 0.15); position: relative; /* For ::after */ } .mmse-total-score-display::after { /* Keep the /30, styled subtly */ content: "/ 30"; font-size: 0.35em; /* Relative to main score size */ font-weight: 500; color: var(--scale-text-secondary); position: absolute; bottom: 10px; /* Adjust vertical position */ right: -30px; /* Position to the right */ }/* Interpretation Display (Pill style, using ORIGINAL clinical colors) */ .mmse-interpretation-display { font-size: clamp(1.1em, 3.5vw, 1.2em); font-weight: 600; min-height: 28px; transition: all 0.4s ease; margin-bottom: 15px; padding: 8px 20px; border-radius: 30px; /* Pill shape */ display: inline-block; border: 1px solid transparent; box-shadow: 0 2px 5px rgba(0,0,0,0.1); } /* Interpretation color classes (Using adjusted vars) */ .interp-no-impairment { color: var(--int-no-impairment-text); background-color: var(--int-no-impairment-bg); border-color: var(--int-no-impairment-bg); } .interp-mild { color: var(--int-mild-text); background-color: var(--int-mild-bg); border-color: var(--int-mild-bg); } .interp-moderate { color: var(--int-moderate-text); background-color: var(--int-moderate-bg); border-color: var(--int-moderate-bg); } .interp-severe { color: var(--int-severe-text); background-color: var(--int-severe-bg); border-color: var(--int-severe-bg); } .interp-calculating { color: var(--int-calculating-text); background-color: var(--int-calculating-bg); border-color: var(--scale-border); }/* Interpretation Details */ .mmse-interpretation-details { font-size: 0.9em; color: var(--scale-text-secondary); margin-top: 5px; margin-bottom: 25px; line-height: 1.5; max-width: 600px; margin-left: auto; margin-right: auto; background-color: #f8fbfb; /* Subtle bg for details */ padding: 10px 15px; border-radius: 8px; }/* Reset Button Styling (Adopted from HoNOSCA reset button) */ .mmse-reset-button { background-color: var(--scale-highlight); /* Orange background */ color: white; border: none; padding: 12px 25px; border-radius: 8px; /* Consistent radius */ font-size: 1em; font-weight: 600; font-family: inherit; cursor: pointer; transition: var(--scale-transition); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); display: inline-flex; align-items: center; gap: 8px; } .mmse-reset-button:hover { background-color: #e68a00; /* Darker orange on hover */ box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15); transform: translateY(-2px); /* Lift effect */ } .mmse-reset-button:active { transform: translateY(0px) scale(0.98); box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); } .mmse-reset-button i { margin-right: 5px; /* Space icon and text */ }/* --- Responsive Adjustments (Adapted from HoNOSCA) --- */ @media (max-width: 768px) { .mmse-scale-wrapper { padding: 20px; } .mmse-header h2 { font-size: 1.8em; } .mmse-header p { font-size: 0.95em; } .mmse-patient-info { padding: 15px; gap: 15px; } .mmse-items-grid { padding: 20px; } .mmse-item { padding: 15px; } .mmse-item-title { font-size: 1.1em; } .mmse-item-icon { font-size: 1.6em; } .mmse-item-instruction { padding: 10px 15px; font-size: 0.95em; } .mmse-score-options { gap: 10px; padding: 8px; } .mmse-point-option, .mmse-binary-option { padding: 8px 10px; font-size: 0.9em; } .mmse-number-option { width: 40px; height: 40px; font-size: 1em; } .mmse-results { padding: 20px 25px; } .mmse-total-score-display { font-size: 3.5em; padding: 8px 20px; } .mmse-total-score-display::after { right: -25px; bottom: 8px;} .mmse-interpretation-display { padding: 6px 18px; } .mmse-reset-button { font-size: 0.95em; padding: 10px 20px; } }@media (max-width: 480px) { .mmse-scale-wrapper { padding: 15px; } .mmse-header { margin-bottom: 20px; padding-bottom: 10px; } .mmse-patient-info { padding: 15px; gap: 15px; grid-template-columns: 1fr; } /* Stack patient info */ .mmse-items-grid { padding: 15px; } .mmse-item { padding: 12px; } .mmse-item-header { gap: 10px; margin-bottom: 10px; } .mmse-item-icon { font-size: 1.5em; width: 30px; } .mmse-item-max-score { font-size: 0.7em; padding: 3px 8px; margin-left: 8px; } .mmse-item-instruction { padding: 10px 12px; font-size: 0.9em; } .mmse-item-note { font-size: 0.85em; } .mmse-score-options { gap: 8px; padding: 5px; } .mmse-point-option { flex-grow: 1; width: 100%; justify-content: flex-start; text-align: left; min-width: unset; flex-basis: auto; padding: 8px; font-size: 0.85em;} /* Stack point options */ .mmse-point-option::before { margin-right: 10px; } .mmse-binary-option { font-size: 0.85em; padding: 8px 10px; flex-basis: 48%; } /* Allow two side-by-side */ .mmse-number-option { width: 38px; height: 38px; font-size: 0.95em; } .mmse-results { padding: 20px 15px; } .mmse-total-score-display { font-size: 3em; padding: 5px 15px; } .mmse-total-score-display::after { font-size: 0.3em; right: -20px; bottom: 5px; } .mmse-interpretation-details { font-size: 0.85em; padding: 8px 10px;} .mmse-reset-button { font-size: 0.9em; padding: 10px 15px; width: 100%; justify-content: center; } }
Mini-Mental State Examination (MMSE) | Score 1pt per correct response within items unless noted.
WORLD backward (D-L-R-O-W). Score 1 point for each letter in correct position. Use only ONE method.// --- JavaScript should be exactly the same as the previous working version --- document.addEventListener('DOMContentLoaded', function() { // Safety check: Log if the script starts console.log("MMSE script initializing...");const scaleWrapper = document.querySelector('.mmse-scale-wrapper'); // Critical Check: Ensure the main wrapper element is found if (!scaleWrapper) { console.error("CRITICAL ERROR: '.mmse-scale-wrapper' element not found. Aborting script."); // Optionally display an error to the user on the page itself // document.body.innerHTML = '
Error: Could not load assessment interface. Element missing.
'; return; // Stop script execution if wrapper is missing } console.log("Found '.mmse-scale-wrapper'. Proceeding...");// Continue with selecting other elements, wrapped in checks just in case const totalScoreDisplay = scaleWrapper.querySelector('#mmse-total-score'); const interpretationDisplay = scaleWrapper.querySelector('#mmse-interpretation'); const interpretationDetails = scaleWrapper.querySelector('#mmse-interpretation-details'); const resetButton = scaleWrapper.querySelector('#mmse-reset-btn'); const allItems = scaleWrapper.querySelectorAll('.mmse-item');// Check if essential result elements were found if (!totalScoreDisplay || !interpretationDisplay || !interpretationDetails || !resetButton) { console.error("Error: One or more result display elements not found within the wrapper."); // You might still allow the script to run for scoring, but results won't show }let itemScores = { orientation_time: 0, orientation_place: 0, registration: 0, attention_calculation: 0, recall: 0, naming: 0, repetition: 0, command_3_stage: 0, reading: 0, writing: 0, copying: 0 };function getInterpretation(score) { let interpText = ''; let interpClass = 'interp-calculating'; let detailsParts = [];// Using standard MMSE cutoffs if (score >= 24 && score = 18 && score = 11 && score = 0 && score <= 10) { interpText = 'Severe Cognitive Impairment'; interpClass = 'interp-severe'; } else { // Handle potential edge cases or invalid scores if necessary interpText = 'Calculating...'; // Or 'Score out of range' interpClass = 'interp-calculating'; }// Construct details text based on score ranges (optional, can customize) if (score < 24) { detailsParts.push('Score < 24 often considered the general cutoff for impairment.'); } else { detailsParts.push('Score ≥ 24 generally suggests no significant impairment.'); } if (score < 21) { detailsParts.push('Scores 25) { detailsParts.push('Scores > 25 associated with decreased odds of dementia.'); } detailsParts.push('Consider clinical picture & adjust interpretation for education level (e.g., lower cutoffs for less education). This is a screening tool, not diagnostic.'); const detailsText = detailsParts.join(' ');return { text: interpText, className: interpClass.trim(), details: detailsText }; }function updateScoreAndInterpretation() { let totalScore = 0; for (const itemKey in itemScores) { // Ensure score is a number, default to 0 if not totalScore += Number(itemScores[itemKey]) || 0; } totalScore = Math.max(0, Math.min(30, totalScore)); // Clamp score to 0-30 range// Update displays only if elements exist if (totalScoreDisplay) { totalScoreDisplay.textContent = totalScore; // Just the number } else { console.warn("Cannot update total score display: Element not found."); }const interpretation = getInterpretation(totalScore);if (interpretationDisplay) { interpretationDisplay.textContent = interpretation.text || 'Calculating...'; // Ensure className is properly formed before setting interpretationDisplay.className = 'mmse-interpretation-display ' + (interpretation.className || 'interp-calculating'); } else { console.warn("Cannot update interpretation display: Element not found."); }if (interpretationDetails) { interpretationDetails.textContent = interpretation.details; } else { console.warn("Cannot update interpretation details: Element not found."); } }// --- Event Listener Setup --- if(allItems.length === 0) { console.warn("No elements with class '.mmse-item' found. Scoring will not work."); }allItems.forEach((item, index) => { const itemKey = item.dataset.item; if (!itemKey) { console.warn(`Item at index ${index} is missing 'data-item' attribute.`); return; // Skip this item if key is missing } // Ensure this item key exists in our scores object if (!(itemKey in itemScores)) { console.warn(`Item key "${itemKey}" not found in initial itemScores object.`); itemScores[itemKey] = 0; // Initialize if missing, though it should be there }const pointOptions = item.querySelectorAll('.mmse-point-option'); const binaryOptions = item.querySelectorAll('.mmse-binary-option'); const numberOptions = item.querySelectorAll('.mmse-number-option');// Multi-point toggle (.mmse-point-option) if (pointOptions.length > 0) { pointOptions.forEach(option => { // Ensure options are buttons for accessibility option.setAttribute('role', 'checkbox'); option.setAttribute('aria-checked', 'false'); option.setAttribute('tabindex', '0'); // Make focusableoption.addEventListener('click', function() { this.classList.toggle('selected'); const isSelected = this.classList.contains('selected'); this.setAttribute('aria-checked', isSelected ? 'true' : 'false'); // Update ARIA statelet currentItemScore = 0; // Recalculate score for THIS item based on selected point options item.querySelectorAll('.mmse-point-option.selected').forEach(selected => { currentItemScore += parseInt(selected.dataset.score || 0, 10); // Use radix 10 }); itemScores[itemKey] = currentItemScore; // Update the score for this specific item updateScoreAndInterpretation(); // Update the total score and interpretation });// Add keyboard support (Space/Enter to toggle) option.addEventListener('keydown', function(event) { if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); // Prevent default space scroll / enter form submit this.click(); // Trigger the click handler } }); }); } // Binary choice (.mmse-binary-option) - Acts like radio buttons else if (binaryOptions.length > 0) { // Assign radio role and manage tabindex/checked state for the group const groupName = `mmse-binary-${itemKey}`; binaryOptions.forEach((option, idx) => { option.setAttribute('role', 'radio'); option.setAttribute('aria-checked', 'false'); option.setAttribute('name', groupName); // Group them semantically option.setAttribute('tabindex', idx === 0 ? '0' : '-1'); // Only first is tabbable initiallyoption.addEventListener('click', function() { const scoreValue = parseInt(this.dataset.score || 0, 10); // Use radix 10if (!this.classList.contains('selected')) { // Deselect siblings first binaryOptions.forEach(sib => { sib.classList.remove('selected'); sib.setAttribute('aria-checked', 'false'); sib.setAttribute('tabindex', '-1'); // Make non-selected not tabbable directly }); // Select this one this.classList.add('selected'); this.setAttribute('aria-checked', 'true'); this.setAttribute('tabindex', '0'); // Make selected tabbable itemScores[itemKey] = scoreValue; } // Optional: Allow deselecting by clicking again (if desired, uncomment) // else { // this.classList.remove('selected'); // this.setAttribute('aria-checked', 'false'); // // Logic to reset tabindex if needed (e.g., back to first option) // itemScores[itemKey] = 0; // } updateScoreAndInterpretation(); });// Keyboard navigation for radio group option.addEventListener('keydown', function(event) { if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); this.click(); } else if (event.key === 'ArrowRight' || event.key === 'ArrowDown') { event.preventDefault(); const nextOption = this.nextElementSibling && this.nextElementSibling.matches('.mmse-binary-option') ? this.nextElementSibling : binaryOptions[0]; nextOption.focus(); // Optional: automatically select on arrow key navigation // nextOption.click(); } else if (event.key === 'ArrowLeft' || event.key === 'ArrowUp') { event.preventDefault(); const prevOption = this.previousElementSibling && this.previousElementSibling.matches('.mmse-binary-option') ? this.previousElementSibling : binaryOptions[binaryOptions.length - 1]; prevOption.focus(); // Optional: automatically select on arrow key navigation // prevOption.click(); } }); }); } // Number choice (.mmse-number-option) - Acts like radio buttons else if (numberOptions.length > 0) { // Similar ARIA and keyboard handling as binary options const groupName = `mmse-number-${itemKey}`; numberOptions.forEach((option, idx) => { option.setAttribute('role', 'radio'); option.setAttribute('aria-checked', 'false'); option.setAttribute('name', groupName); option.setAttribute('tabindex', idx === 0 ? '0' : '-1');option.addEventListener('click', function() { const scoreValue = parseInt(this.dataset.score || 0, 10); // Use radix 10 // Radio button logic: select this, deselect others if (!this.classList.contains('selected')) { numberOptions.forEach(sib => { sib.classList.remove('selected'); sib.setAttribute('aria-checked', 'false'); sib.setAttribute('tabindex', '-1'); }); this.classList.add('selected'); this.setAttribute('aria-checked', 'true'); this.setAttribute('tabindex', '0'); itemScores[itemKey] = scoreValue; } // Optional: allow deselect by clicking again // else { // this.classList.remove('selected'); // this.setAttribute('aria-checked', 'false'); // // Logic to reset tabindex if needed // itemScores[itemKey] = 0; // } updateScoreAndInterpretation(); });// Keyboard navigation option.addEventListener('keydown', function(event) { if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); this.click(); } else if (event.key === 'ArrowRight' || event.key === 'ArrowDown') { event.preventDefault(); const nextOption = this.nextElementSibling && this.nextElementSibling.matches('.mmse-number-option') ? this.nextElementSibling : numberOptions[0]; nextOption.focus(); } else if (event.key === 'ArrowLeft' || event.key === 'ArrowUp') { event.preventDefault(); const prevOption = this.previousElementSibling && this.previousElementSibling.matches('.mmse-number-option') ? this.previousElementSibling : numberOptions[numberOptions.length - 1]; prevOption.focus(); } }); }); } });// Reset Button Logic if (resetButton) { resetButton.addEventListener('click', function() { console.log("Reset button clicked."); // Reset scores object for (const key in itemScores) { itemScores[key] = 0; }// Remove 'selected' class and reset ARIA states for all options scaleWrapper.querySelectorAll('.mmse-point-option, .mmse-binary-option, .mmse-number-option').forEach((el, idx, arr) => { el.classList.remove('selected'); if(el.getAttribute('role') === 'checkbox' || el.getAttribute('role') === 'radio') { el.setAttribute('aria-checked', 'false'); } // Reset tabindex for radio groups (only first element should be 0) if(el.getAttribute('role') === 'radio') { // Check if it's the first in its specific group (assumes options are siblings or within the same parent) const firstInGroup = el.parentElement.querySelector('[role="radio"]'); el.setAttribute('tabindex', el === firstInGroup ? '0' : '-1'); } else if (el.getAttribute('role') === 'checkbox') { el.setAttribute('tabindex', '0'); // Checkboxes are always tabbable } });// Clear input fields const patientNameInput = scaleWrapper.querySelector('#mmsePatientName'); const assessmentDateInput = scaleWrapper.querySelector('#mmseAssessmentDate'); const trialsInput = scaleWrapper.querySelector('#registrationTrials'); if (patientNameInput) patientNameInput.value = ''; if (assessmentDateInput) assessmentDateInput.value = ''; if (trialsInput) trialsInput.value = '';// Update the display updateScoreAndInterpretation(); // Scroll to top smoothly after reset if (scaleWrapper.scrollIntoView) { scaleWrapper.scrollIntoView({ behavior: 'smooth', block: 'start' }); } else { window.scrollTo({ top: scaleWrapper.offsetTop, behavior: 'smooth' }); } }); } else { console.warn("Reset button not found. Reset functionality unavailable."); }// Initial calculation on load to set default state (Score 0, Calculating...) console.log("Performing initial score calculation..."); updateScoreAndInterpretation(); console.log("MMSE script initialization complete.");}); // End DOMContentLoaded/* --- EduLab 'All Scales' Button Styles (Refined Pathway) --- */ .edulab-button-container { /* Centers the button horizontally */ text-align: center; padding: 25px 0; /* Adds space above/below the button */ }.edulab-button.refined-pathway { /* --- Fallback colors if CSS variables aren't available --- */ --accent-teal-bright-fb: #00f2ea; --accent-lavender-soft-fb: #c8bfff; --bg-deep-space-fb: #0a0f2e; /* Darkest background */ --bg-nebula-start-fb: #1a1f4b; /* Slightly lighter dark */ --text-primary-fb: #f0f0f5; --font-main-fb: 'Poppins', sans-serif; /* Ensure this font is loaded on your site *//* --- Base Button Styling --- */ display: inline-block; /* Needed for centering via text-align */ position: relative; padding: 15px 35px; /* Generous padding for visual presence */ margin: 10px 5px; text-decoration: none; font-family: var(--font-main, var(--font-main-fb)); font-weight: 600; font-size: 1.1rem; /* Slightly larger font */ letter-spacing: 0.5px; color: var(--accent-teal-bright, var(--accent-teal-bright-fb)); /* Bright teal text */ background-color: var(--bg-nebula-start, var(--bg-nebula-start-fb)); /* Dark base for contrast */ border: 2px solid var(--accent-teal-bright, var(--accent-teal-bright-fb)); border-radius: 10px; /* Softened corners */ overflow: hidden; /* Contains pseudo-elements */ cursor: pointer; z-index: 1; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), /* Base shadow */ inset 0 0 8px rgba(0, 242, 234, 0.15); /* Subtle inner teal glow *//* --- Transitions --- */ transition: color 0.4s ease, background-color 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease, transform 0.3s ease; -webkit-backface-visibility: hidden; /* Smoother animations */ backface-visibility: hidden; }/* --- Text Span --- */ .edulab-button.refined-pathway span { position: relative; z-index: 3; /* Always on top */ display: inline-block; }/* --- Streaking Lines (Pseudo-elements) --- */ .edulab-button.refined-pathway::before, .edulab-button.refined-pathway::after { content: ''; position: absolute; top: 0; left: 0; /* Start from left edge */ width: 100%; height: 100%; background: linear-gradient(90deg, transparent, var(--accent-teal-bright, var(--accent-teal-bright-fb)), transparent); opacity: 0; /* Start hidden */ z-index: 2; /* Below text, above base background */ transform: skewX(-25deg) translateX(-150%); /* Start way off-screen */ transition: transform 0.6s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.4s ease; }.edulab-button.refined-pathway::after { background: linear-gradient(90deg, transparent, var(--accent-lavender-soft, var(--accent-lavender-soft-fb)), transparent); transition-delay: 0.08s; /* Slightly adjusted stagger */ }/* --- Hover Effects --- */ .edulab-button.refined-pathway:hover { color: var(--bg-deep-space, var(--bg-deep-space-fb)); /* Switch to dark text for HIGH CONTRAST */ background-color: var(--accent-teal-bright, var(--accent-teal-bright-fb)); /* Fill background with teal */ border-color: var(--accent-teal-bright, var(--accent-teal-bright-fb)); /* Border merges */ box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25), /* Lifted shadow */ 0 0 30px rgba(0, 242, 234, 0.75); /* Stronger teal glow */ transform: translateY(-3px); /* Slight lift */ }.edulab-button.refined-pathway:hover::before, .edulab-button.refined-pathway:hover::after { transform: skewX(-25deg) translateX(150%); /* Sweep across */ opacity: 0.6; /* Make streaks visible */ } .edulab-button.refined-pathway:hover::after { opacity: 0.4; /* Lavender streak slightly fainter */ }/* --- Active (Click) Effects --- */ .edulab-button.refined-pathway:active { transform: translateY(-1px) scale(0.98); /* Push down effect */ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2), /* Reduced shadow */ 0 0 20px rgba(0, 242, 234, 0.6); /* Slightly reduced glow */ }