Files
hsa/Html/apps/static/js/learning-path.js
2025-10-29 20:16:10 +08:00

30 lines
1.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 1. 点击学习阶段节点,显示对应课程面板
document.querySelectorAll('.step-node').forEach((node) => {
node.addEventListener('click', function () {
// 隐藏所有面板
document.querySelectorAll('.course-panel').forEach(panel => {
panel.classList.remove('active');
});
// 获取当前阶段名称匹配面板ID
const stepTitle = this.closest('.path-step').querySelector('.step-title').textContent;
const panelId = stepTitle.toLowerCase().replace(' ', '-') + '-panel';
const targetPanel = document.getElementById(panelId);
// 显示对应面板(若存在)
if (targetPanel) {
targetPanel.classList.add('active');
}
});
});
// 2. 关闭课程面板
document.querySelectorAll('.close-panel').forEach(button => {
button.addEventListener('click', function () {
this.closest('.course-panel').classList.remove('active');
});
});
// 3. 切换专业方向(可扩展为动态更新学习路径)
document.getElementById('majorSelect').addEventListener('change', function () {
const selectedMajor = this.options[this.selectedIndex].text;
// 实际项目中可替换为AJAX请求加载对应专业的学习路径
});