YNICTE/FO/Views/CDMS/Contents.cshtml

661 lines
27 KiB
Plaintext
Raw Normal View History

2020-10-12 14:39:23 +09:00
@model NP.Model.VMCRoom
@{
var hasurlmp4 = Model.CMInning.ctype == 3 && Model.Pages.Where(w => w.srcm.ToUpper().EndsWith(".MP4")).Count() > 0;
}
<div id="player">
<div class="plyTop">
2021-09-02 12:51:06 +09:00
<h1 style="text-align:center;">※ 반드시 학습종료 버튼을 눌러 종료해주세요. ※</h1>
2021-08-23 15:10:15 +09:00
<a href="#" onclick="closestudy()">닫기</a>
2020-10-12 14:39:23 +09:00
</div>
<div class="plyTitle">
<h3>@(Model.CMInning.iseq)회. @Model.CMInning.ititle</h3>
@if (Model.Pages.Count() > 1 && Model.CMInning.ismenu == 1)
{
<div id="plyHbg"><span>메뉴</span></div>
}
<a href="#" onclick="closestudy()">학습종료</a>
</div>
<div class="plyCont">
<div class="plyMenu">
<h5 style="@(Model.Pages.Count() > 1 && Model.CMInning.ismenu == 1?"":"display:none")">페이지 목차</h5>
<span id="plymClose">닫기</span>
@if (Model.Pages.Count() > 1 && Model.CMInning.ismenu == 1)
{
<ul id="cplist">
@foreach (var d in Model.Pages)
{
<li><a href="#" onclick="gopage(@d.pseq)" class="@(Model.pseq == d.pseq ? "current" : "")">@d.pseq.ToString("00"). @d.cpname</a></li>
}
</ul>
}
</div>
<div class="plyWrap" style="padding: 0;">
<div class="plyFrame" style="" id="playerbox">
@if (Model.CMInning.ctype == 0)
{
<video id="video1" controls preload="auto" oncontextmenu="return false" controlslist="nodownload" webkit-playsinline></video>
}
else if (Model.CMInning.ctype == 1 || Model.CMInning.ctype == 3)
{
//if (hasurlmp4)
//{
<video id="video1" controls preload="auto" oncontextmenu="return false" controlslist="nodownload" webkit-playsinline style="display:none"></video>
//}
2020-12-08 10:18:12 +09:00
<iframe id="ifr1" class="staticframe" style="@(Model.ismobile == 1 ? "" : "width: 100%; height: 820px;")"></iframe>
2020-10-12 14:39:23 +09:00
}
else if (Model.CMInning.ctype == 2)
{
2020-10-12 14:39:23 +09:00
<div id="html1">
@Html.Raw((Model.ismobile == 1 ? (string.IsNullOrEmpty(Model.Page.srcm) ? Model.Page.srcp : Model.Page.srcm) : Model.Page.srcp).Replace("http:", "https:"))
2020-10-12 14:39:23 +09:00
</div>
}
</div>
</div>
@if (Model.Pages.Count() > 1 && Model.CMInning.ismenu == 1)
{
<ul class="plyNav" id="prenextbox">
<li id="btnpre" style="@(Model.pseq < 2 ? "display:none;":"")"><a onclick="gopage(_pseq-1)" href="#" class="prev"><span>이전</span></a></li>
<li id="btnnext" style="@(Model.Pages.Count() > 1 && Model.pseq < Model.Pages.Count() ? "":"display:none")"><a onclick="gopage(_pseq+1)" href="#" class="next"><span>다음</span></a></li>
</ul>
}
</div>
@*<div class="plyFooter">
<p>COPYRIGHT korea fair competition federation. ALL RIGHTS RESERVED. </p>
</div>*@
</div><!-- player -->
<div id="loading" style="display: none;position: fixed; top: 20%; left: 10%; right: 10%; border-radius: 10px; text-align: center; font-size: 20px; z-index: 2998; padding: 50px 0px; background-color: #333; opacity: 0.8; color: #fff;">콘텐츠를 로딩중입니다.</div>
<script type="text/javascript">
// 관리자에세 url 매개변수로 ismobile=1 을 함께 보낸다. 이에 대한 처리가 되어 있지 않음
const urlParams = new URLSearchParams(window.location.search);
const adminMobile = urlParams.get('ismobile') || '0';
2020-10-12 14:39:23 +09:00
$('html, body').addClass('player')
function plymClose (){
$('#plyHbg').removeClass('on');
$('.plyMenu').animate({ left: '-200px' }, 300);
};
2020-10-12 14:39:23 +09:00
$('#plyHbg').click(function(){
if($(this).is('.on')) {
plymClose();
}
else {
2020-10-12 14:39:23 +09:00
$(this).addClass('on');
$('.plyMenu').animate({ left: '0px' }, 300);
2020-10-12 14:39:23 +09:00
}
});
2020-10-12 14:39:23 +09:00
$('#plymClose').click(function(){
plymClose();
});
var _cpno = @Model.Page.cpno;
var _timerlog;
var _timerios;
var _logno = @Model.lip.logno;
var _sec = 0;
var _nextcpno = 0;
var _nextpseq = 0;
var _cpnos = '@string.Join(",", Model.Pages.Select(s=>s.cpno.ToString()))'.split(',');
var _pseq = @Model.pseq;
var _urls = '@string.Join("xxxnptechphdurlxxx", Model.Pages.Select(s=>Model.ismobile==1 ? s.srcm.Replace("'", "\""):s.srcp.Replace("'", "\"")))'.split('xxxnptechphdurlxxx');
var _psec = '@string.Join(",", Model.Pages.Select(s=>s.psec))'.split(',');
var _tsec = 0;
var _okmid = false;
var _passunload = false;
var _isie = true;
var _mtime = @Model.CMInning.mtime;
var _ctype = @Model.CMInning.ctype;
//var hasurlmp4 = @(hasurlmp4?1:0) == 1;
2021-08-23 15:10:15 +09:00
var _logtime = 300;
2020-10-12 14:39:23 +09:00
var _mtimesec = 0;
var _loging = false;
var _isload = false;
$(window).on("resize", function () {
resizeme();
});
function resizeme() {
if ($("#video1").length > 0) {
$("#video1").css("max-height", window.innerHeight - 120);
}
}
function closestudy() {
2021-08-23 15:10:15 +09:00
if (@Model.istaste != 1 && !_islogout) {
golog(false, true, false, true);
_passunload = true;
2021-08-23 15:10:15 +09:00
}
//opener.document.location.reload();
self.close();
}
2020-10-12 14:39:23 +09:00
$(window).load(function () {
if (@Model.status == 0) {
_passunload = true;
self.close();
} else {
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
if (msie < 0) {
msie = ua.indexOf("Trident/");
}
if (msie < 0)
{
_isie = false;
}
if (_ctype == 0 || _ctype == 1 || _ctype == 3) {
$.each(_urls, function (i, d) {
_urls[i] = '@(Model.CMInning.ctype < 2 ? (Model.Contents+"/"+Model.CMInning.ccode+"/"):"")' + d;
});
$("#video1").on("play", function () {
if (getint(_psec[_pseq - 1]) > 0 && !isnavigated) {
$("#video1")[0].currentTime = getint(_psec[_pseq - 1]);
}
});
$("#video1").on("loadeddata", function () {
$("#playerbox").show();
$("#loading").hide();
//if ($("#playerbox").length > 0) {
// $("#playerbox").show();
//}
//$("#loading").hide();
if ($("#prenextbox").length > 0) {
$("#prenextbox").show();
}
if (!isnavigated) {
//console.log(1);
if (getint(_psec[_pseq - 1]) > 0) {
try {
$("#video1")[0].currentTime = getint(_psec[_pseq - 1]);
isnavigated = true;
} catch (e) { }
//console.log(2);
}
}
});
$("#video1").on("error", function () {
if (($("#video1").attr("src") || "") != "") {
_passunload = true;
clearInterval(_timerlog);
2024-11-05 14:53:08 +09:00
msg("콘텐츠를 학습할 수 없는 상태입니다. 운영자에게 문의해주세요.", null, null, null, "goclose()");
2020-10-12 14:39:23 +09:00
}
});
if (ismobile() || adminMobile == '1') {
//if ($("#ifr1").length > 0) {
// $("#ifr1").addClass("mobileiframe");
// $("#ifr1")[0].height = ($(window).height() - 180) + 'px';
//}
var iframe = $("#ifr1");
if (iframe.length > 0) {
var headerHeight = $('#header').outerHeight() || 180;
var newHeight = $(window).height() - headerHeight;
iframe.css({
'width': '100%',
'height': newHeight + 'px'
});
}
else {
console.error("ifr1 요소를 찾지 못함!");
2020-10-12 14:39:23 +09:00
}
}
2020-10-12 14:39:23 +09:00
if (@Model.istaste == 1) {
srcchange();
} else {
_timerlog = setInterval(golog, 1000);
srcchange();
}
} else if (_ctype == 2 && @Model.istaste != 1) {
_timerlog = setInterval(golog, 1000);
}
}
console.log('ctype: ' + _ctype);
console.log('Model.CMInning.ismenu: ' + @Model.CMInning.ismenu);
var frameObj = document.getElementById("ifr1");
if (frameObj != null) {
$(frameObj).load(function () {
try {
window.frames["ifr1"].document.oncontextmenu = function () { return false; };
$(window.frames["ifr1"].document).on("keydown", function (e) {
return false;
});
}
catch (e) { }
//var win = frameObj.contentWindow || window.frames[frameObj.name];
//frameObj.addEventListener("contextmenu", function (e) { e.preventDefault(); });
//var doc = win.document || (iframe.contentDocument || win.document);
//frameObj.contentDocument.body.oncontextmenu = function () { return false; }
//doc.oncontextmenu = function () { return false; };
});
}
//if (opener && (opener._cdmsisopenning || 0) == 1) {
// opener._cdmsisopenning = 0;
//}
});
function mp4play() {
_timerlog = setInterval(golog, 1000);
srcchange();
}
var isurlmp4ing = false;
var isnavigated = false;
function srcchange() {
//if (_urls[_pseq - 1].substr(0, 1) == "/" || _urls[_pseq - 1].indexOf(location.host) > -1) {
// $.ajax({
// url: _urls[_pseq - 1],
// type: 'HEAD',
// error: function () {
// _passunload = true;
// clearInterval(_timerlog);
// alert(_urls[_pseq - 1]);
// msg("콘텐츠를 학습할 수 없는 상태입니다. 운영자에게 문의해주세요.", null, null, null, "self.close()", 3000);
// },
// success: function () {
// fncontents();
// }
// });
//}
//else {
// fncontents();
//}
if (_urls[_pseq - 1].substr(_urls[_pseq - 1].length - 4, 4) != ".mp4") {
//jQuery.ajax({
// url: _urls[_pseq - 1],
// dataType: 'jsonp',
// type: 'GET',
// error: function (e) {
// if (e.status != 200) {
// _passunload = true;
// clearInterval(_timerlog);
// msg("콘텐츠를 학습할 수 없는 상태입니다. 운영자에게 문의해주세요..", null, null, null, "self.close()", 3000);
// }
// },
// success: function (xhr) {
// if (xhr.status == 200) {
// fncontents();
// } else {
// _passunload = true;
// clearInterval(_timerlog);
// msg("콘텐츠를 학습할 수 없는 상태입니다. 운영자에게 문의해주세요...", null, null, null, "self.close()", 3000);
// }
// },
// complete: function (xhr) {
// //try { console.log(xhr.status); } catch (e) { console.log('x'); }
// if (xhr.status == 200) {
// fncontents();
// }
// }
//});
$.ajax({
type: "GET",
url: _urls[_pseq - 1],
data: {},
timeout: 3000,
dataType: "jsonp",
jsonp: "jsonp",
success: function (response, textS, xhr) {
console.log('urlok');
fncontents();
},
error: function (xmlHttpRequest, textStatus, errorThrown) {
if (xmlHttpRequest.status == 200) {
console.log('urlerrorok');
fncontents();
} else {
_passunload = true;
clearInterval(_timerlog);
msg("콘텐츠를 학습할 수 없는 상태입니다. 운영자에게 문의해주세요...", null, null, null, "goclose()", 3000);
//msg("콘텐츠를 학습할 수 없는 상태입니다. 운영자에게 문의해주세요...", null, null, null);
2020-10-12 14:39:23 +09:00
}
}
});
} else {
fncontents();
}
}
function fncontents() {
//if (!_isload) {
isurlmp4ing = false;
if ($("#ifr1").length == 1) {
$("#ifr1").attr("src", "").hide();
}
if ($("#video1").length == 1) {
$("#video1").attr("src", "").hide();
}
if (/*hasurlmp4 && */_urls[_pseq - 1].substr(_urls[_pseq - 1].length - 4, 4).toUpperCase() == ".MP4") {
isurlmp4ing = true;
}
if (_ctype == 0 || isurlmp4ing) {
$("#loading").show();
if ($("#prenextbox").length > 0) {
$("#prenextbox").hide();
}
$("#video1").attr("src", "");
$("#playerbox").hide();
if (ismobile() || (@Model.CMInning.isoversize == 1) || isurlmp4ing) {
$("#video1").attr("src", _urls[_pseq - 1]).show();
if (/iPad|iPhone|iPod/.test(navigator.userAgent)) {
//$("#video1")[0].addEventListener('loadeddata', function () {
$("#loading").hide();
$("#playerbox").show();
//}, false);
}
if (!isnavigated) {
//console.log(1);
if (getint(_psec[_pseq - 1]) > 0) {
try {
$("#video1")[0].currentTime = getint(_psec[_pseq - 1]);
if ($("#video1")[0].currentTime != 0) {
isnavigated = true;
}
} catch (e) { }
//console.log(2);
}
}
} else {
fetchVideo(_urls[_pseq - 1]).then(function (blob) {
changeVideoSource(blob, $("#video1")[0], $("#playerbox"));
});
}
} else if (_ctype == 1) {
$("#ifr1").attr("src", _urls[_pseq - 1]).show();
} else if (_ctype == 3) {
if (_urls[_pseq - 1].substr(0, 5).toUpperCase() == "HTTPS") {
//$("#ifr1").attr("src", "https://" + location.hostname + "/CDMS/HTTPS?url="+_urls[_pseq - 1]);
$("#ifr1").attr("src", _urls[_pseq - 1]).show();
} else {
$("#ifr1").attr("src", _urls[_pseq - 1]).show();
}
}
resizeme();
//}
}
let loginErrCnt = 0;
function golog(ispaging, isunload, isinning, sync) {
2021-08-23 15:10:15 +09:00
2020-10-12 14:39:23 +09:00
ispaging = ispaging || false;
isunload = isunload || false;
isinning = isinning || false;
sync = sync || false;
2020-10-12 14:39:23 +09:00
_tsec++;
if (!ispaging && !isunload && !isinning) {
_sec++;
2021-08-23 15:10:15 +09:00
}
2020-10-12 14:39:23 +09:00
if (_mtimesec > 0) {
_mtimesec++;
if (_mtimesec > 10) {
if (!_okmid) {
clearInterval(_timerlog);
_passunload = true;
self.close();
}
}
}
if (_mtimesec < 1 && ((_sec > 0 && _sec % _logtime == 0) || ispaging || isunload || isinning) && !_loging) {
_loging = true;
var _psecond = 0;
try {
if ($("#video1").length > 0) {
_psecond = getint($("#video1")[0].currentTime);
}
2021-01-26 10:17:53 +09:00
} catch (e) { }
capp("/focommon/studylog", { logno: _logno, lectno: @Model.lip.lectno, cmino: @Model.lip.cmino, cpno: _cpno, studysec: _sec, ispc: ismobile() ? 0 : 1, nextcpno: ispaging ? _nextcpno : 0, getiframe: @(Model.CMInning.ismenu == 1 && Model.CMInning.ctype == 2 ? 1 : 0), issample: @Model.istaste, psec: _psecond }, "cbstudylog" + (ispaging ? "page" : "") + (isunload ? "unload" : "") + (isinning ? "inning" : ""), null, null, true, null, true, null, sync);
2020-10-12 14:39:23 +09:00
} else if (_mtime > 0 && !_okmid && _tsec >= _mtime && _mtimesec < 1) {
//clearInterval(_timerlog);
_mtimesec = 1;
$("#playerbox").addClass("hidecontent");
if (_ctype == 0 && navigator.userAgent.match(/iPhone|iPod/i)) {
var vid = document.getElementById('video1');
vid.webkitExitFullscreen();
} else {
try {
if (navigator.userAgent.match(/iPhone|iPod/i)) {
alert('10초안에 중간출석을 확인해주세요.');
}
else if (typeof (document.msExitFullscreen) == "function") {
document.msExitFullscreen();
} else if (typeof (document.webkitExitFullscreen) == "function") {
document.webkitExitFullscreen();
}
} catch (e) {
2020-10-12 14:39:23 +09:00
try {
document.webkitExitFullscreen();
} catch (e2) {
2020-10-12 14:39:23 +09:00
}
}
}
2021-08-23 15:10:15 +09:00
msg("중간출석 확인 메시지입니다. 10초안에 확인을 눌러주세요.", null, null, null, "okmid()");
2020-10-12 14:39:23 +09:00
}
}
function okmid() {
capp("/focommon/studylogmid", { lectno: @Model.lip.lectno, cmino: @Model.lip.cmino}, "cbokmid");
}
function cbokmid() {
if (capResult.code == 1000) {
$("#playerbox").removeClass("hidecontent");
_okmid = true;
_mtimesec = 0;
_loging = false;
//_timerlog = setInterval(golog, 1000);
if (_ctype == 0) {
$("#video1")[0].play();
}
} else {
_passunload = true;
self.close();
}
}
var _islogout = false;
function cbstudylog() {
if (capResult.code == 1000) {
console.log('logok: sec('+_sec+'), log('+capResult.obj+')');
_sec = 0;
_loging = false;
//_timerlog = setInterval(golog, 1000);
loginErrCnt = 0;
2020-10-12 14:39:23 +09:00
} else {
$("#playerbox").remove();
clearInterval(_timerlog);
loginErrCnt += 1
if (loginErrCnt > 5) {
_islogout = true;
_passunload = true;
//msg("학습로그가 정상 기록이 되지 않았습니다..", null, null, null, "self.close()");
self.close() // 영남측에서 강종으로 요청함
}
//msg("다른 기기로 로그인되었습니다.", null, null, null, "self.close()");
2020-10-12 14:39:23 +09:00
_islogout = true;
_passunload = true;
//setTimeout(function () {
// _passunload = true;
// self.close();
//}, 5000);
}
}
2020-10-12 14:39:23 +09:00
function cbstudylogpage() {
if (capResult.code == 1000) {
console.log('logok: sec(' + _sec + '), logno(' + capResult.obj + ')');
_sec = 0;
_loging = false;
_cpno = _nextcpno;
_logno = getint(capResult.obj);
_pseq = _nextpseq;
//if ('@(Model.CMInning.ismenu)' == '1') {
2020-10-12 14:39:23 +09:00
if (_ctype == 0 || _ctype == 1 || _ctype == 3) {
srcchange();
} else {
$("#html1").html(capResult.msg);
}
//}
2020-10-12 14:39:23 +09:00
//_timerlog = setInterval(golog, 1000);
$("#cplist li a").removeClass("current");
$("#cplist li").eq(_pseq-1).find("a").addClass("current");
} else if (@Model.istaste == 1) {
_loging = false;
_cpno = _nextcpno;
_pseq = _nextpseq;
//if ('@(Model.CMInning.ismenu)' == '1') {
2020-10-12 14:39:23 +09:00
if (_ctype == 0 || _ctype == 1 || _ctype == 3) {
srcchange();
} else {
$("#html1").html(capResult.msg);
}
//}
2020-10-12 14:39:23 +09:00
$("#cplist li a").removeClass("current");
$("#cplist li").eq(_pseq - 1).find("a").addClass("current");
loginErrCnt = 0;
2020-10-12 14:39:23 +09:00
} else {
loginErrCnt += 1
if (loginErrCnt > 5) {
_islogout = true;
_passunload = true;
//msg("학습로그가 정상 기록이 되지 않았습니다..", null, null, null, "self.close()");
self.close() // 영남측에서 강종으로 요청함
}
/*
//msg("다른 단말기에서 로그인되었습니다. 학습을 종료합니다.");
2020-10-12 14:39:23 +09:00
setTimeout(function () {
_passunload = true;
self.close();
}, 5000);
*/
2020-10-12 14:39:23 +09:00
}
}
function cbstudylogunload() {
}
function gopage(nextpseq) {
_nextpseq = nextpseq;
_nextcpno = getint(_cpnos[nextpseq - 1]);
if (_ctype == 0) {
//$("#loading").show();
if ($("#prenextbox").length > 0) {
$("#prenextbox").hide();
}
}
$("#plyHbg").removeClass("on");
$('.plyMenu').animate({ left: '-200px' }, 300);
if (!ismobile()) {
$('.plyWrap').animate({ marginLeft: '0px' }, 300);
}
$("#btnpre,#btnnext").show();
if (nextpseq == 1) {
$("#btnpre").hide();
} else if (nextpseq == @Model.Pages.Count()) {
$("#btnnext").hide();
}
//clearInterval(_timerlog);
golog(true);
}
2024-06-24 12:45:12 +09:00
function getprgrs() {
var r = -1;
if (@Model.istaste == 1) {
r = 100;
} else {
$.ajax({
type: "post",
2024-06-24 12:45:12 +09:00
url: "/focommon/prgrs", @*플레이바 제어매서드*@
async: false,
data: { lectno: @Model.lip.lectno, cmino: @Model.lip.cmino},
success: function (r2) {
r = parseInt(r2, 10);
}, error: function (e) {
r = -1;
}
});
}
return r;
}
2020-10-12 14:39:23 +09:00
window.onbeforeunload = function () {
if (!_passunload && @Model.istaste != 1 && !_islogout) {
clearInterval(_timerlog);
2021-08-23 15:10:15 +09:00
golog(false, true, false, false);
}
if (opener) {
opener.location.href = opener.location.href.replace(/#/gi, '');
2020-10-12 14:39:23 +09:00
}
}
var _ispre = false;
function goinning(ispre) {
_ispre = ispre || false;
//검증(다음or이전차시 존재, 환급&당일6개차시학습완료)
clearInterval(_timerlog);
capp("/focommon/checkinningchange", { lectno: @Model.lip.lectno, cmino: @Model.lip.cmino, ispre: _ispre }, "cbcheckgoinning");
}
var _prenextcmino = 0;
function cbcheckgoinning() {
if (capResult.code == 1000) {
if (capResult.obj == -1) {
msg(_ispre ? "현재 첫 번째 차시를 학습중입니다." : "현재 마지막차시를 학습중입니다.");
_timerlog = setInterval(golog, 1000);
} else if (capResult.obj == -2) {
_timerlog = setInterval(golog, 1000);
msg("현재차시를 학습완료해야 다음차시를 학습할 수 있습니다.");
} else if (capResult.obj == -3) {
_timerlog = setInterval(golog, 1000);
2021-09-10 14:02:05 +09:00
msg("일일 최대 학습회차는 10시간(10차시)입니다.");
2020-10-12 14:39:23 +09:00
} else {
//학습로그 & 차시이동
_prenextcmino = capResult.obj;
golog(false, false, true);
}
} else {
_passunload = true;
opener.location.href = opener.location.href.replace(/#/gi, '');
self.close();
}
}
function cbstudyloginning() {
if (capResult.code == 1000) {
console.log('logok-inning: sec(' + _sec + '), log(' + capResult.obj + ')');
_sec = 0;
_loging = false;
_passunload = true;
location.href = "/CDMS/Play?cmino=" + _prenextcmino + "&ismobile=" + (ismobile() ? 1 : 0) + "&lectno=@Model.lip.lectno&pseq=1";
} else {
console.log('cbstudyloginning error');
_passunload = true;
self.close();
}
}
/* 페이지별 학습시간(초)전달 : parent.getpagelearn(pageindex) */
function getpagelearn(pseq) {
var result = -1;
var cpno = getint(_cpnos[pseq - 1]);
$.ajax({
type: "post",
url: "/focommon/pagelearningtotaltime",
async: false,
data: { lectno: @Model.lip.lectno, cmino: @Model.lip.cmino, cpno: cpno},
success: function (data) {
if (data.code == 1000) {
result = parseInt(data.obj);
} else {
result = -1;
}
}
2021-08-23 15:10:15 +09:00
});
return result;
}
2021-08-23 15:10:15 +09:00
function goclose() {
if (@Model.istaste != 1 && !_islogout) {
capp("/focommon/studyclose", { logno: _logno, issample : @Model.istaste}, "cbgoclose", null, null, true, null, true, null, true);
}
self.close();
}
function cbgoclose(){
_passunload = true;
self.close();
}
2020-10-12 14:39:23 +09:00
</script>