var elapsed_seconds = 0;
setInterval(function() {
elapsed_seconds = elapsed_seconds + 1;
$('#timer').text(get_elapsed_time_string(elapsed_seconds));
if (elapsed_seconds % 600 === 0) {
// 將畫面退出全螢幕,並暫停播放
player.exitFullscreen();
player.pause();
// 彈出視窗,顯示已經靜置 10 分鐘了,點擊確認繼續觀看
var timerInterval;
Swal.fire({
title: '已閒置 10 分鐘',
text: "10 秒未確認將自動登出,並取消進度",
type: 'warning',
showCancelButton: false,
confirmButtonColor: '#6658dd',
confirmButtonText: '確認',
timer: 10000,
allowOutsideClick: false,
}).then((result) => {
// 點確認則寫入資料庫 if (data.success === 'success') {
// 跳轉到習題頁面
var timerInterval;
Swal.fire({
title: '你已完成課程!',
html: '準備習題中...(倒數 <b></b> 秒)',
timer: 3000,
timerProgressBar: true,
allowOutsideClick: false,
onBeforeOpen: () => {
Swal.showLoading();
timerInterval = setInterval(() => {
swal.getContent().querySelector('b')
.textContent = Math.ceil(swal.getTimerLeft() / 1000)
}, 100)
},