Ethhhnbv's picture
Design a modern, intuitive teacher-facing web app called Typed Lesson Assist, used by a Chinese language teacher to create and present lessons that are easy for students to read.
afc1235 verified
class LessonManager {
constructor() {
this.lessons = JSON.parse(localStorage.getItem('lessons')) || [];
this.currentLessonIndex = 0;
this.currentSlideIndex = 0;
}
saveLessons() {
localStorage.setItem('lessons', JSON.stringify(this.lessons));
}
addLesson(title) {
const newLesson = {
id: Date.now(),
title: title || `New Lesson ${this.lessons.length + 1}`,
slides: [this.createNewSlide()]
};
this.lessons.push(newLesson);
this.saveLessons();
return newLesson;
}
createNewSlide() {
return {
id: Date.now(),
title: 'New Slide',
content: '',
notes: '',
pinyin: '',
translation: '',
characters: ''
};
}
addSlide(lessonIndex) {
const newSlide = this.createNewSlide();
this.lessons[lessonIndex].slides.push(newSlide);
this.saveLessons();
return newSlide;
}
updateSlide(lessonIndex, slideIndex, data) {
const slide = this.lessons[lessonIndex].slides[slideIndex];
Object.assign(slide, data);
this.saveLessons();
}
deleteSlide(lessonIndex, slideIndex) {
this.lessons[lessonIndex].slides.splice(slideIndex, 1);
this.saveLessons();
}
deleteLesson(lessonIndex) {
this.lessons.splice(lessonIndex, 1);
this.saveLessons();
}
}
// Initialize speech recognition
function initSpeechRecognition(lang = 'cmn-Hans-CN') {
const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
recognition.lang = lang;
recognition.interimResults = true;
return recognition;
}
// Fullscreen slide functionality
function toggleFullscreenSlide(slideElement) {
if (!document.fullscreenElement) {
slideElement.classList.add('fullscreen-slide');
slideElement.requestFullscreen().catch(err => {
console.error(`Error attempting to enable fullscreen: ${err.message}`);
});
} else {
document.exitFullscreen();
slideElement.classList.remove('fullscreen-slide');
}
}
// Initialize the app
document.addEventListener('DOMContentLoaded', () => {
const lessonManager = new LessonManager();
window.lessonManager = lessonManager; // Make it globally available
// Event listeners will be handled by the web components
});