var renderer = new marked.Renderer();
renderer.code = function (code, language) {
if (language == "mermaid") return '
' + code + "
";
else return "
" + code + "
";
};
function lesson_show(id) {
$.get(
"../course/lesson_get.php",
{
id: id,
},
function (data, status) {
let arrLesson = JSON.parse(data);
let html = "";
for (const lesson of arrLesson) {
html += '
';
html += '
';
html += '
';
html +=
'
' +
lesson["title"] +
"
";
html += '
';
let summary = "";
try {
summary = marked(lesson["summary"], { renderer: renderer });
} catch {}
html += '
' + summary + "
";
let live = "";
try {
live = marked(lesson["live"], { renderer: renderer });
} catch {}
html += '
' + live + "
";
let replay = "";
try {
replay = marked(lesson["replay"], { renderer: renderer });
} catch {}
html += '
' + replay + "
";
let attachment = "";
try {
attachment = marked(lesson["attachment"], { renderer: renderer });
} catch {}
html += '
' + attachment + "
";
html += "
";
html += "
";
html += "
";
html += '
';
let d = new Date();
d.setTime(lesson["date"]);
let strData = d.toLocaleDateString();
let strTime = d.toLocaleTimeString();
html += "
" + gLocal.gui.date + ":" + strData + "
";
html += "
" + gLocal.gui.time + ":" + strTime + "
";
let dt = lesson["duration"] / 60;
let sdt = "";
if (dt > 59) {
sdt += Math.floor(dt / 60) + gLocal.gui.h;
}
let m = dt % 60;
if (m > 0) {
sdt += (dt % 60) + gLocal.gui.mins;
}
html += "
" + gLocal.gui.duration + ":" + sdt + "
";
let now = new Date();
let lesson_time = "";
if (now < lesson["date"]) {
lesson_time = gLocal.gui.not_started;
} else if (now > lesson["date"] && now < lesson["date"] + dt * 1000) {
lesson_time = gLocal.gui.in_progress;
} else {
lesson_time = gLocal.gui.already_over;
}
html += '
' + lesson_time + "
";
html += "
";
html += "
";
}
$("#lesson_list").html(html);
mermaid.initialize();
}
);
}
function lesson_load(lesson_id) {
$.get(
"../course/lesson_get.php",
{
id: lesson_id,
},
function (data, status) {
let html = "";
let lesson_info = JSON.parse(data);
if (lesson_info) {
//head
html += "
";
html += "
";
html += "
" + lesson_info.title + "
";
html += "
" + lesson_info.subtitle + "
";
html += "
";
html += "
";
//end of head
let d = new Date();
d.setTime(lesson_info.date);
let strData = d.toLocaleDateString();
let strTime = d.toLocaleTimeString();
let dt = lesson_info["duration"] / 60;
let strDuration = "";
if (dt > 59) {
strDuration += Math.floor(dt / 60) + "小时";
}
let m = dt % 60;
if (m > 0) {
strDuration += (dt % 60) + "分钟";
}
html += "
";
// end of course_info_head_2
//live
if (lesson_info.live && lesson_info.live.length > 0) {
html += "
";
html += "
" + gLocal.gui.notice_live + "
";
try {
html += marked(lesson_info.live);
} catch (e) {
html += e.message;
}
html += "
";
}
//end of live
//replay
if (lesson_info.replay && lesson_info.replay.length > 0) {
html += "
";
html += "
" + gLocal.gui.record_replay + "
";
try {
html += marked(lesson_info.replay);
} catch (e) {
html += e.message;
}
html += "
";
}
//end of replay
//attachment
if (lesson_info.attachment && lesson_info.attachment.length > 0) {
html += "
";
html += "
" + gLocal.gui.attachment + "
";
try {
html += "
";
html += note_init(lesson_info.attachment);
html += "
";
} catch (e) {
html += e.message;
}
html += "
";
}
//end of attachment
//content
if (lesson_info.content && lesson_info.content.length > 0) {
html += "
";
html += "
" + gLocal.gui.detaile + "
";
try {
html += marked(lesson_info.content);
} catch (e) {
html += e.message;
}
html += "
";
}
//end of attachment
$("#lesson_info").html(html);
note_refresh_new();
render_course_info(lesson_info.course_id);
render_lesson_list(lesson_info.course_id, lesson_info.id);
}
}
);
}
function render_course_info(course_id) {
$.get(
"../course/course_get.php",
{
id: course_id,
},
function (data, status) {
let html = "";
let course_info = JSON.parse(data);
if (course_info) {
let html = "";
html += "