Shoulder Companion – Hỗ trợ Phục hồi Chức năng Vai
Shoulder Companion
Tự theo dõi và Hỗ trợ phục hồi chức năng Vai
' + content.innerHTML + '');
printWindow.document.close();
printWindow.onload = () => { printWindow.focus(); printWindow.print(); printWindow.close(); };
}
// --- APP INITIALIZATION ---
document.addEventListener('DOMContentLoaded', () => {
if (window.sfsAppInitialized) return;
window.sfsAppInitialized = true;
initializeFirebase();
loadUserFromLocal();
UI.updateProgressBar(0);
document.getElementById('appContainer').addEventListener('click', (e) => {
if (e.target.matches('button[data-step]')) {
const targetStep = parseInt(e.target.getAttribute('data-step'));
if (targetStep > App.currentStep && !validateStep(App.currentStep)) {
UI.showValidationModal("Vui lòng trả lời các câu hỏi bắt buộc ở bước này.");
return;
}
navigateStep(targetStep);
}
});
document.getElementById('nextFromInfoBtn').addEventListener('click', async () => {
if (!validateStep(1)) {
UI.showValidationModal("Vui lòng điền đầy đủ thông tin bắt buộc.");
return;
}
saveUserToLocal(document.getElementById('nickname').value);
const canProceed = await checkAssessmentFrequency();
if (canProceed) navigateStep(2);
});
document.getElementById('calculateBtn').addEventListener('click', calculateAndShowResults);
document.getElementById('finishBtn').addEventListener('click', resetApp);
document.getElementById('printBtn').addEventListener('click', printResults);
document.getElementById('validationModalCloseBtn').addEventListener('click', UI.closeValidationModal);
document.getElementById('frequencyLimitModalCloseBtn').addEventListener('click', UI.closeFrequencyLimitModal);
const radioContainers = ['icf1_container', 'icf2_container', 'icf3_container', 'painLevel_container'];
radioContainers.forEach(id => {
const container = document.getElementById(id);
if (container) {
const radioName = container.querySelector('input[type=radio]').name;
const detailId = id.replace('_container', '_details');
container.addEventListener('change', () => toggleDetail(radioName, detailId));
}
});
});