// รายการบทเรียนและไฟล์ที่สอดคล้องกัน const lessons = [ {id: 'intro', title: 'บทนำ', file: 'lessons/00-intro.html'}, {id: 'html', title: 'HTML', file: 'lessons/01-html.html'}, {id: 'css', title: 'CSS', file: 'lessons/02-css.html'}, {id: 'javascript', title: 'JavaScript', file: 'lessons/03-javascript.html'}, {id: 'tools', title: 'Tools', file: 'lessons/04-tools.html'}, {id: 'database', title: 'ฐานข้อมูล', file: 'lessons/05-database.html'}, {id: 'responsive', title: 'Responsive Design', file: 'lessons/06-responsive.html'}, {id: 'next-steps', title: 'ก้าวต่อไป', file: 'lessons/07-next-steps.html'}, {id: 'api-fetch', title: 'API & Fetch', file: 'lessons/13-api-fetch.html'}, {id: 'accessibility', title: 'Accessibility', file: 'lessons/14-accessibility.html'} ]; // ฟังก์ชันสำหรับโหลดเนื้อหา /* eslint-env browser */ /* global SyntaxHighlighterComponent, QuizEngine */ async function loadLesson(sectionId) { const lesson = lessons.find(l => l.id === sectionId); if (!lesson) { console.error('ไม่พบบทเรียน:', sectionId); return; } try { const response = await fetch(lesson.file); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const content = await response.text(); // โหลดเนื้อหา const contentLoader = document.getElementById('content-loader'); contentLoader.innerHTML = content; // store the lesson file as base for resolving relative URLs inside the lesson contentLoader.dataset.lessonFile = lesson.file || ''; // Playground: extract any