//==================================================================================
// 파일명 : netmaru_main.js
// 버 전 : 1.1
// 날 짜 : 2016.06.14
// 제작자 : 하영중
//
// 본 파일 소스의 모든 저작권은 netmaru에 있습니다. 임의의 수정 및 배포를 금합니다.
// 문 의 : 02-597-2343
//==================================================================================
// **************************
// ***** 기본 환경 변수 *****
// **************************
var myAudio = document.getElementById("myVideo");
var captionMode = false;
var movieSpeed;
var isMobile;
var percent;
var menuPos;
var pageBtn = false;
var update;
var posSpace; // 타임헤드 width값의 1/2
var volSpace; // 볼륨헤드 width값의 1/2
var endFlag = false;
var fullBtnClick = false;
var objectTime;
var playNum;
var tempVol;
var volumebarNum = 1;
var volumeTimeout;
var timeout;
var nextWidth;
var volumeOnTop;
var scriptTF;
var nowSpeedNum = 10;
var keyFlag = true;
var nextBalloonLeft;
var pageKind;
var contHideTime;
var nowVideoNum = 1;
var myAudio;
// ****************************
// ***** 페이지 시작 관련 *****
// ****************************
// 페이지 초기화
function nmr_pageInitFn(){
timeout = setTimeout(nmr_pageInitFn2, 300);
}
function nmr_pageInitFn2(){
clearTimeout(timeout);
$.ajax({url:'../common/top.htm', dataType:'html'}).done(function(data){
//$('#ui-top').html(data);
})
$.ajax({url:'menu.htm', dataType:'html'}).done(function(data){
$('#ui-menu').html(data);
})
if(!nmr_getPlayerType()){
$.ajax({url:'../common/next.htm', dataType:'html'}).done(function(data){
$('#ui-next').html(data);
})
$.ajax({url:'../common/prev.htm', dataType:'html'}).done(function(data){
$('#ui-prev').html(data);
})
}else{
/*if(bookmarkTImeArr[nowPageNum] != undefined){
$.ajax({url:'../common/bookmark.htm', dataType:'html'}).done(function(data){
$('#ui-bookmark').html(data);
})
}*/
}
$.ajax({url:'../common/bottom.htm', dataType:'html'}).done(function(data){
$('#ui-bottom').html(data);
})
timeout = setTimeout(nmr_controlInitFn, 200);
}
// 컨트롤바 초기화
function nmr_controlInitFn(){
clearTimeout(timeout);
if(changeable && nmr_getPlayerType()){
$('#warp-all').addClass('full');
}
//setTimeout(titleFn, 100);
// 버튼에 기능 넣기
$('#scriptClose').attr("href", "javascript:nmr_captionViewFn();");
if(pageKindNum == 1){
if(fullscreenBtnTF){
$('#fullScreenOn a').attr("href", "javascript:nmr_fullScreenOnFn();");
$('#fullScreenOff a').attr("href", "javascript:nmr_fullScreenOffFn();");
}else{
$('#fullScreenOn a').css("opacity", 0.3);
$('#fullScreenOn a').css('cursor', 'default');
$('#fullScreenOn a').attr("title", "");
$('#fullScreenOn ').addClass('disable');
}
$('.vod-speedOn a').attr("href", "javascript:nmr_speedOnFn();");
$('.vod-speedOff a').attr("href", "javascript:nmr_speedOffFn();");
}else{
$('#fullScreenOn a').css("opacity", 0.3);
$('#fullScreenOn a').css('cursor', 'default');
$('#fullScreenOn a').attr("title", "");
$('#fullScreenOn ').addClass('disable');
$('.vod-speedOn a, .vod-speedOff a').css("opacity", 0.3);
$('.vod-speed').css("opacity", 1);
$('.vod-speedOn a').css('cursor', 'default');
$('.vod-speedOn a').attr("title", "");
$('.vod-speedOn a').addClass('disable');
}
// 스크립트 버튼
if(scriptTF == false){
$('.scriptBtn a').css('opacity', 0.3);
$('.scriptBtn a').css('cursor', 'default');
$('.scriptBtn a').attr("title", "");
$('.scriptBtn a').addClass('disable');
}else{
$('.scriptBtn a').attr("href", "javascript:nmr_captionViewFn();");
}
if(!nmr_getPlayerType()){
$('#mobilePlayBtn a').attr("href", "javascript:nmr_playFn();");
$('#mobilePauseBtn a').attr("href", "javascript:nmr_pauseFn();");
$('#mobilePlayBtn a').hide();
if(nowPageNum == 1){
$('#ui-prev').hide();
}else if(nowPageNum == totalPages){
$('#ui-next').hide();
}
}
// 페이지 표시
//$('.pageNum').html(nowPageNum);
//$('.totalPageNum').html(totalPages);
// 버튼 세팅
$('#ui-bottom #menu_off').hide();
$('.playBtn a').hide();
$('.soundOff a').hide();
$('.controllockoff a').hide();
$('#fullScreenOff').hide();
// 페이지에 맞는 영상/음성 연결
var videoSrc;
if(pageKindNum == 1){
videoSrc = vod;
}else if(pageKindNum == 2){
videoSrc = audio;
}
// 배속 기능 세팅
nmr_vodSpeedInitFn();
// 영상 초기화
myAudio = document.getElementById("myVideo");
myAudio.preload = "false";
myAudio.autoplay = "false";
myAudio.src = vod;
if(pageKindNum == 1){
myAudio.poster = "../common/img/bg/poster.jpg";
}
// 쿠키에 저장된 볼륨, 컨트롤바 잠금 기능 설정값 불러오기
var cookieVol = getCookie("volume");
if(cookieVol.length > 0){
vol = Number(cookieVol);
if(vol > 0){
volumeSetNum = 1;
}else{
volumeSetNum = 0;
}
}else{
volumeSetNum = 1;
}
var cookieLock = getCookie("controlLock");
if(Number(cookieLock) == 1 && nmr_getPlayerType()){
controlLockNum = 1;
}else{
if(!nmr_getPlayerType()){
controlLockNum = 2;
}else{
controlLockNum = 1;
}
}
nextBalloonLeft = parseInt($('#bottom .nextBalloon a').css('left'));
// 접속 기기별 세팅
if(nmr_getPlayerType()){
isMobile = false;
nmr_playInitFn();
$('.nextBalloon a').hide();
$('.nextBalloon a').css('left', nextBalloonLeft - balloonMoveX);
}else{
isMobile = true;
$('#ui-loading').hide();
if(controlHideNShow){
$('#ui-bottom').addClass('hide');
$('#ui-top').addClass('hide');
}
$('#mobileStartBtn').show();
$('#mobileText').show();
//$('#bottom #timeControl .seekBar').hide();
nmr_scaleResizeFn();
$('#skip a').hide();
myAudio.pause();
}
document.getElementById("myVideo").onfocus = function(){
this.blur();
}
// 메가넥스트용 추가
if(local == false){
_setPageInfo(strFileName);
_setCurrentLocation(nowPageNum);
_progressSave();
}
}
/*function titleFn(){
// 상단 차시번호, 차시명 적기_181116
$('.weekNum').html(nowChasiNum);
$('.weekName').html(chasiNameArr[nowChasiNum]);
// 소제목 텍스트 처리_181116
if(smallTitleArr[nowPageNum] != undefined && smallTitleArr.length > 0){
smallMenuTxtFn();
}
}*/
// 기본 세팅 완료 후 재생 시작
function nmr_playInitFn(){
// 퀴즈, 정리하기 페이지 여부 확인
if($('.quizAll').length == 1){
pageKind = "quiz";
}else if($('.arrangeAll').length == 1){
pageKind = "arrange";
}
playNum = 1;
if(pageKindNum == 1){
myAudio.play();
}else if(!nmr_getPlayerType()){
myAudio.play();
}
if(!nmr_getPlayerType()){
nextWidth = parseInt($('#ui-next').css('width'));
$('#skip a').show();
}
tl.play();
$('#mobileStartBtn').hide();
$('#mobileText').hide();
$('#bottom #timeControl .seekBar').show();
$('#ui-loading').hide();
//myAudio2.pause();
// ********* 크롬 정책 변경으로 인한 첫 페이지 자동재생 관련 수정 - 180713 **********
var promise
if(pageKindNum == 1){
promise = document.querySelector('video').play();
}else{
promise = document.querySelector('audio').play();
}
if(promise !== undefined){
promise.then(function(){
}).catch(function(){
$('#chrome').show();
nmr_pauseFn();
});
}
// ********* 크롬 정책 변경으로 인한 첫 페이지 자동재생 관련 수정 - 180713 **********
myAudio.addEventListener('ended', nmr_onEnded, false);
setTimeout(nmr_volumeInitFn, 100);
if(nmr_getPlayerType()){
nmr_setVolumeFn(volumeSetNum);
}
nmr_setControlBarFn();
nmr_controlHideInitFn();
update = setInterval(intervalFn, 100);
//myAudio.addEventListener("timeupdate", intervalFn, false);
$("#scriptUI .text .txt").mCustomScrollbar({scrollbarPosition:"outside"});
$('.soundOn a, .soundOff a').hover(
function(){
volumebarNum = 2;
volumeTimeout = setTimeout(volumeBarOnOffFn, 100);
},
function(){
volumebarNum = 1;
volumeTimeout = setTimeout(volumeBarOnOffFn, 300);
}
);
$('#volumeBar').hover(
function(){
volumebarNum = 2;
},
function(){
volumebarNum = 1;
volumeTimeout = setTimeout(volumeBarOnOffFn, 300);
}
);
//setTimeout(alertDurationFn, 1000); //영상길이 확인용
}
function alertDurationFn(){
console.log(myAudio.duration);
}
// **************************
// ***** 재생 관련 기능 *****
// **************************
// 재생 시간에 따른 타임헤드 위치 조절, 타임바 크기 조절
function intervalFn(){
if(playNum == 1){
nmr_progressUpdateFn();
}
}
function nmr_progressUpdateFn(){
nmr_timeViewFn();
var headWidth = parseInt($("#timeControl #positionT").css('width')) / 2;
//var headWidth = 0;
var _xMin = $("#timeControl #seekBtn").offset().left;
var _dragWidth = $("#timeControl #seekBtn").width() - headWidth * 2 + 1;
var _xMax = _xMin + _dragWidth;
var percent = (myAudio.currentTime / myAudio.duration);
// 무비바 위치
_curPos = headWidth + (_dragWidth * percent);
if(myAudio.currentTime <= myAudio.duration){
$('#timeControl .seekBar').css("width", _curPos);
$('#timeControl #positionT').css("left", _curPos - headWidth);
}
// 스킵버튼
if(nowPageNum == 1){
if(myAudio.currentTime >= skipTime){
$('#skip a').hide();
}else{
$('#skip a').show();
}
}
//모바일 컨트롤바 시간 표시
if(isMobile){
var targetLeft = parseInt($('#timeControl #seekBtn').css('left')) + parseInt($('#timeControl #seekBtn').css('width')) - parseInt($('.timeView').css('width'));
if(parseInt($('#timeControl #positionT').css('left')) < parseInt($('.timeView').css('width'))){
$('.timeView').css('left', 0);
}else if(parseInt($('#timeControl #positionT').css('left')) >= targetLeft){
$('.timeView').css('left', targetLeft - parseInt($('.timeView').css('width')));
}else{
$('.timeView').css('left', parseInt($('#timeControl #positionT').css('left')) - parseInt($('.timeView').css('width')));
}
}
}
// 시간 표시
function nmr_timeViewFn(){
var cTime;
if(myAudio.currentTime >= myAudio.duration){
cTime = myAudio.duration;
}else{
cTime = myAudio.currentTime;
}
//현재시간 $$$
var cm = parseInt(cTime / 60);
var cs = parseInt(cTime % 60);
var ctxt = nmr_itostr(cm) + ':' + nmr_itostr(cs);
if(ctxt != $('.timer').html()){
$('.timer').html(ctxt);
}
//총시간
var tm = parseInt(myAudio.duration / 60);
var ts = parseInt(myAudio.duration % 60);
var ttxt = nmr_itostr(tm) + ':' + nmr_itostr(ts);
if(isMobile){
$('.mobileTimertotal').html(ttxt);
}else{
$('.timertotal').html(ttxt);
}
/*if(bookmarkTImeArr[nowPageNum] != undefined){
nmr_bookmarkCheckFn();
}*/
}
// 컨트롤바 이동
function nmr_setControlBarFn(){
var dragWidth;
var xmin;
var xmax;
posSpace = parseInt($('#positionT').css("width")) / 2;
if(!nmr_getPlayerType()){
// 드래그로 이동
var timeArea = document.getElementById("positionT");
timeArea.addEventListener('touchstart', function(event){
event.preventDefault();
clearInterval(autoHide);
nmr_headIncreaseFn();
nmr_pauseFn();
dragWidth = $('#timeControl .progress').width() * per;
xmin = $('#timeControl #seekBtn').offset().left;
}, {passive: true});
timeArea.addEventListener('touchmove', function(event){
nmr_nextPageFn(2);
pos = event.touches[0].clientX;
if(pos > xmin && pos < dragWidth + xmin){
pos2 = 100 * (pos - xmin) / dragWidth;
$('#timeControl .seekBar').css("width", pos2 + "%");
$('#timeControl #positionT').css('left', $('#timeControl .seekBar').width() - posSpace);
tTime = (myAudio.duration * pos2 / 100);
if(pageKindNum == 1){
//myAudio.currentTime = tTime;
}
percent = (myAudio.currentTime / myAudio.duration).toFixed(2);
tl.progress(percent);
nmr_timeViewFn();
}
event.preventDefault();
}, {passive: true});
timeArea.addEventListener('touchend', function(event){
event.preventDefault();
nmr_headDecreaseFn();
tTime = (myAudio.duration * pos2 / 100);
myAudio.currentTime = tTime;
tl.progress(percent);
nmr_playFn();
nmr_controlAutoHideFn();
}, {passive: true});
// 터치로 이동
var timeArea2 = document.getElementById("seekBtn");
timeArea2.addEventListener('touchstart', function(event){
event.preventDefault();
clearInterval(autoHide);
nmr_pauseFn();
dragWidth = $('#timeControl .progress').width() * per;
xmin = $('#timeControl #seekBtn').offset().left;
nmr_nextPageFn(2);
pos = event.touches[0].clientX;
if(pos > xmin && pos < dragWidth + xmin){
pos2 = 100 * (pos - xmin) / dragWidth;
$('#timeControl .seekBar').css("width", pos2 + "%");
$('#timeControl #positionT').css('left', $('#timeControl .seekBar').width() - posSpace);
tTime = (myAudio.duration * pos2 / 100);
myAudio.currentTime = tTime;
percent = (myAudio.currentTime / myAudio.duration).toFixed(2);
tl.progress(percent);
nmr_timeViewFn();
}
}, {passive: true});
timeArea2.addEventListener('touchend', function(event){
event.preventDefault();
tTime = (myAudio.duration * pos2 / 100);
myAudio.currentTime = tTime;
tl.progress(percent);
nmr_playFn();
nmr_controlAutoHideFn();
}, {passive: true});
}else{
$('#timeControl #seekBtn, #timeControl #positionT').on('mousedown',function(e){
e.preventDefault();
dragWidth = $("#timeControl #seekBtn").width();
nmr_pauseFn();
nmr_nextPageFn(2);
pos = e.pageX - $('#timeControl #seekBtn').offset().left;
if(pos > 0 && pos < dragWidth){
pos2 = 100 * pos / dragWidth;
$('#timeControl .seekBar').css('width', pos);
$('#timeControl #positionT').css('left', pos - posSpace);
tTime = (myAudio.duration * pos2 / 100);
myAudio.currentTime = tTime;
percent = (myAudio.currentTime / myAudio.duration).toFixed(2);
tl.progress(percent);
nmr_timeViewFn();
}
$('#timeControl #seekBtn, #timeControl #positionT, #warp-all').on('mousemove',function(e){
e.preventDefault();
pos = e.pageX - $('#timeControl #seekBtn').offset().left;
if(pos > 0 && pos < dragWidth){
pos2 = 100 * pos / dragWidth;
$('#timeControl .seekBar').css('width', pos);
$('#timeControl #positionT').css('left', pos - posSpace);
tTime = (myAudio.duration * pos2 / 100);
//myAudio.currentTime = tTime;
percent = (myAudio.currentTime / myAudio.duration).toFixed(2);
tl.progress(percent);
nmr_timeViewFn();
}
})
$('#timeControl #seekBtn, #timeControl #positionT, #warp-all').on('mouseup',function(e){
e.preventDefault();
$('#timeControl #seekBtn, #timeControl #positionT, #warp-all').off();
tTime = (myAudio.duration * pos2 / 100);
if(myAudio.duration - tTime < 1){
tTime = myAudio.duration - 1;
}
myAudio.currentTime = tTime;
percent = (myAudio.currentTime / myAudio.duration).toFixed(2);
tl.progress(percent);
nmr_playFn();
if(pageKindNum == 1){
nmr_applySpeed();
}
nmr_setControlBarFn();
nmr_controlHideInitFn();
})
})
}
$('#timeControl #seekBtn, #timeControl #positionT').mouseenter(function(){
$('#bottom #timeControl #positionT').addClass('over');
})
$('#timeControl #seekBtn, #timeControl #positionT').mouseleave(function(){
$('#bottom #timeControl #positionT').removeClass('over');
})
}
// 재생, 일시정지, 리플레이
function nmr_playFn(){
// ********* 크롬 정책 변경으로 인한 첫 페이지 자동재생 관련 수정 - 180713 **********
$('#chrome').hide();
// ********* 크롬 정책 변경으로 인한 첫 페이지 자동재생 관련 수정 - 180713 **********
if(myAudio.currentTime < myAudio.duration){
update = setInterval(intervalFn, 100);
nmr_playContents();
$('.playBtn a').hide();
$('.pauseBtn a').show();
if(isMobile){
$('#mobilePlayBtn a').hide();
$('#mobilePauseBtn a').show();
}
playStatus = true;
nmr_controlAutoHideFn();
playNum = 1;
if(pageKindNum == 1){
nmr_applySpeed();
}
if(pageKind == "quiz"){
if(parseInt($('.quizAll').css('left')) != 0){
goReplay();
}
}
}
}
function nmr_pauseFn(){
clearInterval(update);
myAudio.pause();
tl.pause();
$('.playBtn a').show();
$('.pauseBtn a').hide();
if(isMobile){
$('#mobilePlayBtn a').show();
$('#mobilePauseBtn a').hide();
}
playStatus = false;
nmr_controlAutoHideFn();
playNum = 2;
if(pageKindNum == 1){
//nmr_applySpeed();
nmr_speedSetFn(nowSpeedNum);
}
}
function nmr_replayFn(){
if(pageKind == "quiz"){
goReplay();
}
nmr_pauseFn();
myAudio.currentTime = 0;
percent = (myAudio.currentTime / myAudio.duration).toFixed(2);
tl.progress(percent);
nmr_nextPageFn(2);
nmr_playFn();
nmr_controlAutoHideFn();
playNum = 1;
}
function nmr_playContents(){
percent = (myAudio.currentTime / myAudio.duration).toFixed(2);
if(percent < 1){
tl.progress(percent);
tl.play();
}else{
//tl.progress(1);
tl.pause();
}
if(myAudio.currentTime < myAudio.duration){
myAudio.play();
}else{
myAudio.pause();
}
}
// 1페이지에서 스킵 기능
function nmr_skipFn(){
$('#skip a').hide();
nmr_pauseFn();
myAudio.currentTime = skipTime;
nmr_playFn();
}
// *********************
// ***** 볼륨 기능 *****
// *********************
// 사운드 on/off
function nmr_setVolumeFn(num){
if(num == 0){
nmr_setVol(0);
$('.soundOn a').hide();
$('.soundOff a').show();
}else{
if(vol == 0){
vol = 0.7;
}
nmr_setVol(vol);
$('.soundOff a').hide();
$('.soundOn a').show();
}
}
// 볼륨 설정
function nmr_setVol(value){
myAudio.volume = value;
tempVol = value;
if(value == 0){
nmr_volumePositionFn(0);
setCookie("volume", 0);
}else{
nmr_volumePositionFn(vol);
setCookie("volume", vol);
}
}
// 볼륨 조절
var volMax;
var volxmin;
function nmr_volumeInitFn(){
volMax = $('#volumeControl .seekBtn').width();
if(isMobile){
nmr_setVol(vol);
}else{
volSpace = parseInt($('#positionV').css('width')) / 2;
//volSpace = 0;
$('#volumeControl #positionV').on('mousedown',function(e){
e.preventDefault();
xmin = $('#volumeControl .seekBtn').offset().left;
volPos_width = $('#volumeControl .seekBtn').width();
xmax = xmin + volPos_width;
var pos = (e.pageX - xmin) / volPos_width;
if(pos >= 0 && pos <= volPos_width){
vol = pos;
nmr_setVolumeFn(vol);
}
$(document).on('mousemove',function(e){
e.preventDefault();
if(e.pageX-xmin >= 0 && (e.pageX-xmin) <= volPos_width){
var pos = (e.pageX - xmin) / volPos_width;
vol = pos;
nmr_setVolumeFn(vol);
$('#volumeControl #positionV').css("left",Math.round(volMax * vol - volSpace));
}
})
$(document).on('mouseup',function(e){
e.preventDefault();
$(document).off();
})
});
nmr_volumePositionFn(vol);
}
}
// 볼륨헤드 위치, 볼륨바 크기 조절
function nmr_volumePositionFn(num){
var dragWidth = $("#volumeControl .seekBtn").width();
var curPos = dragWidth * num;
if(curPos > dragWidth){
curPos = 0
}
$('#volumeControl .seekBar').css("width", Math.round(curPos));
$('#volumeControl #positionV').css("left", Math.round(volMax * num - parseInt($('#positionV').css('width')) / 2));
}
function volumeBarOnOffFn(){
clearTimeout(volumeTimeout);
if(volumebarNum == 2){
$('#volumeBar').show();
$('#bottom .timeView').addClass('vol');
$('#bottom #volumeControl #positionV').addClass('over');
}else{
$('#volumeBar').hide();
$('#bottom .timeView').removeClass('vol');
$('#bottom #volumeControl #positionV').removeClass('over');
}
}
// ********************
// ***** 자막관련 *****
// ********************
// 자막로딩
var scriptTargetY;
var smiNum = 0;
function nmr_loadSmi(){
document.write('');
//setTimeout(nmr_smiCheckFn, 100);
}
function nmr_smiCheckFn(){
for(i=1; i<=smiArr.length; i++){
if(i= smiArr[i-1][0] && myAudio.currentTime < smiArr[i][0]){
smiCurrentFn(i-1);
break;
}
}else{
if(myAudio.currentTime >= smiArr[i-1][0]){
smiCurrentFn(i-1);
break;
}
}
}
}
function smiCurrentFn(num){
$("#scriptUI .text .txt").html(smiArr[num][1]);
}
// 자막창 열고 닫기
function nmr_captionViewFn(){
if(captionMode == false){
if(menuNum == 2){
nmr_menuToggleFn();
}
if(vodSpeedTF){
nmr_speedOffFn();
}
clearInterval(autoHide);
$("#scriptUI").show();
$('#ui-bottom .scriptBtn a').addClass('selected');
captionMode = true;
}else{
nmr_controlAutoHideFn();
$("#scriptUI").hide();
$('#ui-bottom .scriptBtn a').removeClass('selected');
captionMode = false;
}
}
// *********************
// ***** 배속 기능 *****
// *********************
var vodSpeedTF = false;
function nmr_vodSpeedInitFn(){
var speedContent = "";
for(i=0; ix' + movieSpeedArr[i].toFixed(1) + ''
}
$('#speedBtnAll').html(speedContent);
$('#speedBtnAll').css('height', movieSpeedArr.length * parseInt($('#speedBtnAll li a').css('height')) + 5);
$('#speedBtnAll').css('top', 0 - parseInt($('#speedBtnAll').css('height')) + 20);
$('.vod-speedOff').hide();
$('#speedBtnAll li a').eq(nowSpeedNum).addClass('selected');
$('#speedBtnAll').hide();
}
function nmr_speedOnFn(){
$('#speedBtnAll').show();
$('.vod-speedOn').hide();
$('.vod-speedOff').show();
if(captionMode == true){
nmr_captionViewFn();
}
vodSpeedTF = true;
}
function nmr_speedOffFn(){
$('#speedBtnAll').hide();
$('.vod-speedOn').show();
$('.vod-speedOff').hide();
vodSpeedTF = false;
}
function nmr_speedSetFn(num){
nowSpeedNum = num;
movieSpeed = Number(movieSpeedArr[num]);
for(i=0; i 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)){
if(oldie == "Mozilla/4.0"){
return false;
}else{
nmr_initScale();
}
}else{
nmr_initScale();
}
//resizeTime = setTimeout(menumotionFn, 250);
}
}
function nmr_initScale(){
var ress = navigator.userAgent;
if(ress.indexOf("Android 1.", 0) > -1){
if(ress.indexOf("480", 0) > -1){
per = 0.5226824457593688;
}else if(ress.indexOf("600", 0) > -1){
per = 0.681
}else if(ress.indexOf("1280", 0) > -1){
per = 0.631
}
}else{
var dw = self.innerWidth;
var dh = self.innerHeight;
per = dw/contentW;
var per2 = dh/contentH;
if(per > per2 ){
per = per2;
}
var gapH = (dh-(contentH*per))/2;
gapW = (dw-(contentW*per))/2;
}
$("#warp-all").css('transform', 'scale('+per+','+per+')');
$('body').css('margin-top', gapH );
$('body').css('margin-left', gapW );
}
// *********************
// ***** 기타 기능 *****
// *********************
// 접속 기기 체크하기(PC, 모바일 여부)
function nmr_getPlayerType(){
var UserAgent = navigator.userAgent;
if (UserAgent.match(/iPhone|iPod|iPad|Android|Windows CE|BlackBerry|Symbian|Windows Phone|webOS|Opera Mini|Opera Mobi|POLARIS|IEMobile|lgtelecom|nokia|SonyEricsson/i) != null || UserAgent.match(/LG|SAMSUNG|Samsung/) != null){
// 모바일일 때
var fileref = document.createElement("link");
fileref.rel = "stylesheet";
fileref.type = "text/css";
fileref.href = "../common/inc/css/nmr_controlM.css";
document.getElementsByTagName("head")[0].appendChild(fileref);
return false;
}else{
// PC일 때
var fileref = document.createElement("link");
fileref.rel = "stylesheet";
fileref.type = "text/css";
fileref.href = "../common/inc/css/nmr_controlP.css";
document.getElementsByTagName("head")[0].appendChild(fileref);
return true;
}
}
// 퀴즈 효과음 재생
function playEffect(name){
myAudio3 = document.getElementById("myEffect");
myAudio3.autoplay = "autoplay";
var audio = audioURL + name;
myAudio3.src = audio;
myAudio3.volume = tempVol;
}
// ***********************
// ***** 인덱스 관련 *****
// ***********************
function nmr_indexInitFn(){
// 메뉴 이동 페이지 설정
for (var i=0; i<$('#ui-menu .indexBg a').length; i++){
var targetPage = $('#ui-menu .indexBg .subList a').eq(i).attr('data');
$('#ui-menu .indexBg .subList a').eq(i).attr("href","javascript:nmr_movePage(" + targetPage + ");");
}
nmr_goMenuFn();
}
function nmr_goMenuFn(){
$('#ui-menu .indexBg a').removeClass('selected');
for(var i=0; i<$('#ui-menu .menuList a').length; i++){
var data1 = $('#ui-menu .menuList a').eq(i).attr('data');
var data2 = $('#ui-menu .menuList a').eq(i+1).attr('data');
if(nowPageNum >= data1 && (Number(nmr_itostr(nowPageNum)) < data2 || data2 == undefined)){
var bigmenuNum1 = 0;
var bigmenuNum2 = 0;
if(i == 0){
bigmenuNum1 = bigMenuArr[0];
for(j=0; j= data1 && (Number(nmr_itostr(nowPageNum)) < data2 || data2 == undefined)){
$('#ui-menu .subList a').eq(i).removeClass('selectedFocus');
$('#ui-menu .subList a').eq(i).addClass('selected');
}
}
}
var menuNum = 1;
function nmr_menuToggleFn(){
if(menuNum == 1){
if(captionMode == true){
nmr_captionViewFn();
}
clearInterval(autoHide);
if(indexFull){
nmr_pauseFn();
}
$('#ui-menu').addClass('open');
$('#ui-bottom #menu_on').hide();
$('#ui-bottom #menu_off').show();
menuNum = 2;
}else{
nmr_controlAutoHideFn();
if(indexFull){
nmr_playFn();
}
$('#ui-menu').removeClass('open');
$('#ui-bottom #menu_on').show();
$('#ui-bottom #menu_off').hide();
menuNum = 1;
}
}
// ******************************
// ***** 컨트롤바 잠금 관련 *****
// ******************************
var touchNum = 0;
var touchTImeout;
function nmr_controlHideInitFn(){
if(controlHideNShow){
if(controlLockNum == 2){
nmr_controlHideFn();
$('.controllockon a').show();
$('.controllockoff a').hide();
}else{
$('.controllockon a').hide();
$('.controllockoff a').show();
}
if(!nmr_getPlayerType()){
var touchArea = document.getElementById("ui-contents");
touchArea.addEventListener('touchstart', function(event){
event.preventDefault();
touchTImeout = setTimeout(touchSensingFn, 300);
var touch1 = event.touches[0].clientX;
if(touch1 >= self.innerWidth / 2){
touchNum ++;
}else{
touchNum --;
}
}, false);
}else{
$('#warp-all').mouseenter(function(){clearTimeout(contHideTime); nmr_controlShowFn();});
$('#warp-all').mouseleave(function(){contHideTime = setTimeout(nmr_controlHideFn, 600);});
}
}
}
function touchSensingFn(){
clearTimeout(touchTImeout);
if(touchNum >= 2){
nmr_secondNextFn();
}else if(touchNum <= -2){
nmr_secondPrevFn()
}else{
nmr_mobileControlShowFn();
}
touchNum = 0;
}
var controldelay;
var controlShowNum = 1;
function nmr_mobileControlShowFn(){
if(controlShowNum == 2){
if(pageKind == "arrange" || pageKind == "quiz"){
controldelay = setTimeout(nmr_controlHideFn, 400);
}else{
nmr_controlHideFn();
}
}else{
if(pageKind == "arrange" || pageKind == "quiz"){
controldelay = setTimeout(nmr_controlShowFn, 400);
}else{
nmr_controlShowFn();
}
}
}
var autoHide;
function nmr_controlAutoHideFn(){
if(!nmr_getPlayerType()){
clearInterval(autoHide);
autoHide = setTimeout(nmr_controlHideFn, contAutoHideTime);
}
}
function nmr_controlHideFn(){
if(!nmr_getPlayerType()){
clearTimeout(autoHide);
if(pageKind == "arrange" || pageKind == "quiz"){
clearTimeout(controldelay);
}
if(controlLockNum == 2 && menuNum == 1){
if(pageBtn == false){
$('#ui-bottom').addClass('hide');
$('#ui-top').addClass('hide');
//if(endFlag == false){
$('#ui-prev').addClass('hide');
$('#ui-next').addClass('hide');
$('#mobilePnPBtn').removeClass('show');
//}
if(menuNum == 2){
nmr_menuToggleFn();
}
if(captionMode == true){
nmr_captionViewFn();
}
}else{
pageBtn = false;
}
}else{
//if(endFlag == false){
$('#ui-prev').addClass('hide');
$('#ui-next').addClass('hide');
$('#mobilePnPBtn').removeClass('show');
//}
}
}else{
clearTimeout(contHideTime);
if(controlLockNum == 2){
if(menuNum == 1 && captionMode == false){
$('#ui-bottom').addClass('hide');
$('#ui-top').addClass('hide');
}
}
}
controlShowNum = 1;
}
function nmr_controlShowFn(){
if(!nmr_getPlayerType()){
if(pageKind == "arrange" || pageKind == "quiz"){
clearTimeout(controldelay);
}
if(pageBtn == false){
$('#ui-bottom').removeClass('hide');
$('#ui-top').removeClass('hide');
//if(endFlag == false){
$('#ui-prev').removeClass('hide');
$('#ui-next').removeClass('hide');
$('#mobilePnPBtn').addClass('show');
//}
}else{
pageBtn = false;
}
nmr_controlAutoHideFn();
}else{
$('#ui-bottom').removeClass('hide');
$('#ui-top').removeClass('hide');
}
controlShowNum = 2;
}
function nmr_controlLockOnFn(num){
controlLockNum = 1;
$('.controllockon a').hide();
$('.controllockoff a').show();
if(num == 1){
setCookie("controlLock", controlLockNum);
}
}
function nmr_controlLockOffFn(){
controlLockNum = 2;
nmr_controlHideFn();
$('.controllockon a').show();
$('.controllockoff a').hide();
setCookie("controlLock", controlLockNum);
}
// ***************************
// ***** 학습도우미 관련 *****
// ***************************
// ***** 화면 안내 *****
function nmr_goHelp(){
clearInterval(autoHide);
keyFlag = false;
nmr_pauseFn();
$('#ui-help').show();
$.ajax({url:'../common/help/screen.htm', dataType:'html'}).done(function(data){
$('#ui-help').html(data);
})
}
// 학습화면 버튼
function nmr_screenBtnInitFn(){
for(i=0; i= mapPageArr[i] && nowChasiNum < mapPageArr[i+1]){
mapTabFn(i);
}
}else{
if(nowChasiNum >= mapPageArr[i]){
mapTabFn(i);
}
}
}
// 현재 차시에 맞는 모듈명 강조
for(i=0; i= mapModuleArr[i] && nowChasiNum < mapModuleArr[i+1]){
$("#ui-help #mapAll .module").eq(i-1).addClass('selected');
}
}else{
if(nowChasiNum >= mapModuleArr[i]){
$("#ui-help #mapAll .module").eq(i-1).addClass('selected');
}
}
}
}
// 러닝맵 화면 이동
function mapTabFn(num){
if(mapTotNum == 1){
$('#mapMove').hide();
}
for(i=0; i= 1){
vol = 1;
}
nmr_setVolumeFn(1);
nmr_setVol(vol);
}
// 키보드로 볼륨 down
function nmr_volDownFn(){
vol = vol - 0.05;
if(vol <= 0){
vol = 0;
nmr_setVolumeFn(0);
}
nmr_setVol(vol);
}
// 키보드로 재생, 일시정지
function nmr_spaceFn(){
if(playNum == 1){
nmr_pauseFn();
}else{
nmr_playFn();
}
}
// ********** 북마크 관련 **********
var bookmarkNum = 1;
function nmr_bookmarkOnOffFn(){
if(bookmarkNum == 1){
$('#bookmark').animate({left:-276}, 500);
bookmarkNum = 2;
}else{
$('#bookmark').animate({left:32}, 500);
bookmarkNum = 1;
}
}
function nmr_bookmarkInitFn(){
// 북마크 개수만큼만 보여주기
var bookmarkHeight = 0;
for(i=1; i<=bookmarkTImeArr[nowPageNum].length; i++){
$('#bookmarkText' + i + ' a').css('display', 'block');
$('#bookmarkText' + i + ' a').html(bookmarkNameArr[nowPageNum][i-1]);
$('#bookmarkText' + i + ' a').css('top', bookmarkHeight);
bookmarkHeight = bookmarkHeight + parseInt($('#bookmarkText' + i + ' a').css('height')) + 5;
}
// 북마크 개수에 맞게 길이 맞추기
//$('#bookmarkMiddle').css('height', 27*(bookmarkTImeArr[nowPageNum].length));
$('#bookmarkMiddle').css('height', bookmarkHeight);
$('#bookmarkBottom').css('top', parseInt($('#bookmarkTop').css('height')) + parseInt($('#bookmarkMiddle').css('height')));
bookmarkTopFn();
}
function bookmarkTopFn(){
// 북마크 위치 고정_181116
$('#ui-bookmark').css('top', parseInt($('#ui-top .subject').css('height')) + 5);
}
function nmr_bookmarkGoFn(num){
// 북마크 클릭해서 이동
var targetTime = bookmarkTImeArr[nowPageNum][num-1];
nmr_pauseFn();
tTime = targetTime;
myAudio.currentTime = tTime;
percent = (myAudio.currentTime / myAudio.duration).toFixed(2);
tl.progress(percent);
nmr_playFn();
}
function nmr_bookmarkCheckFn(){
for(i=1; i<=bookmarkTImeArr[nowPageNum].length; i++){
if(i= bookmarkTImeArr[nowPageNum][i-1] && myAudio.currentTime < bookmarkTImeArr[nowPageNum][i]){
bookmarkCurrentFn(i);
break;
}
}else if(myAudio.currentTime < bookmarkTImeArr[nowPageNum][0]){
bookmarkCurrentFn(0);
break;
}else{
if(myAudio.currentTime >= bookmarkTImeArr[nowPageNum][i-1]){
bookmarkCurrentFn(i);
break;
}
}
}
}
function bookmarkCurrentFn(num){
for(i=1; i<=bookmarkTImeArr[nowPageNum].length; i++){
$('#bookmarkText' + i + ' a').removeClass('selected');
}
$('#bookmarkText' + num + ' a').addClass('selected');
}
// 소제목 텍스트 처리_181116
function smallMenuTxtFn(){
$('.smallTitle').show();
$('.smallTitle .smallTitleBody').html(smallTitleArr[nowPageNum]);
}