Initial commit: 교육 프로젝트 배포

This commit is contained in:
송대일
2026-07-01 18:32:42 +09:00
commit be6dccd120
1483 changed files with 5082202 additions and 0 deletions
+106
View File
@@ -0,0 +1,106 @@
(function () {
const onboardingBridgeState = {
chapters: null,
pending: null,
};
function getPuzzleModalManagerClass() {
if (typeof PuzzleModalManager !== 'undefined') {
return PuzzleModalManager;
}
if (typeof window.PuzzleModalManager !== 'undefined') {
return window.PuzzleModalManager;
}
return null;
}
function ensureDependencies() {
if (!getPuzzleModalManagerClass()) {
throw new Error('PuzzleModalManager is not loaded');
}
}
async function loadOnboardingChapters() {
if (Array.isArray(onboardingBridgeState.chapters)) {
return onboardingBridgeState.chapters;
}
if (onboardingBridgeState.pending) {
return onboardingBridgeState.pending;
}
onboardingBridgeState.pending = fetch('/bbs/api/get_onboarding_chapters.php', {
credentials: 'same-origin',
})
.then(async function (response) {
const payload = await response.json();
if (!response.ok || !payload || payload.success !== true || !Array.isArray(payload.chapters)) {
throw new Error(payload?.message || 'failed_to_load_onboarding_chapters');
}
onboardingBridgeState.chapters = payload.chapters;
window.puzzleChapterData = payload.chapters;
return payload.chapters;
})
.finally(function () {
onboardingBridgeState.pending = null;
});
return onboardingBridgeState.pending;
}
function cloneChapter(chapter) {
return JSON.parse(JSON.stringify(chapter || {}));
}
function findChapterIndexByContentId(chapters, contentId) {
const id = String(contentId || '');
if (id === '') {
return -1;
}
return chapters.findIndex(function (chapter) {
const lessons = Array.isArray(chapter?.lessons) ? chapter.lessons : [];
return lessons.some(function (lesson) {
return String(lesson?.content_id || '') === id;
});
});
}
function applyBridgeOverrides(chapter, info) {
const contentId = String(info?.contentId || '');
if (!contentId || !Array.isArray(chapter?.lessons)) {
return chapter;
}
chapter.lessons = chapter.lessons.map(function (lesson) {
if (String(lesson?.content_id || '') !== contentId) {
return lesson;
}
return {
...lesson,
watch_tm: Math.max(Number(lesson?.watch_tm || 0), Number(info?.watchTm || 0)),
content_tm: Math.max(Number(lesson?.content_tm || 0), Number(info?.contentTm || 0)),
is_bookmarked: info?.bookmark === true ? true : lesson?.is_bookmarked === true,
};
});
return chapter;
}
window._onboardingOpenModal = async function (info) {
ensureDependencies();
const PuzzleModalManagerClass = getPuzzleModalManagerClass();
const chapters = await loadOnboardingChapters();
const chapterIndex = findChapterIndexByContentId(chapters, info?.contentId);
if (chapterIndex < 0) {
throw new Error('onboarding chapter not found');
}
const chapter = applyBridgeOverrides(cloneChapter(chapters[chapterIndex]), info);
await PuzzleModalManagerClass.openChapterModal(chapterIndex, chapter);
};
})();