let oCommon;
$(document).ready(function () {
oCommon = new Common();
oCommon.init();
if ($("#count-dday").length > 0) {
oCommon.countDay();
}
if ($('.form-regi').length > 0) {
$(window).resize(function () {
if ($(window).width() < 1023) {
$('.form-regi').each(function () {
var instance = $(this).overlayScrollbars();
instance.destroy();
});
} else {
$('.form-regi').each(function () {
var instance = $(this).overlayScrollbars({});
});
}
});
}
});
function Common() {
this.strCurrentQustionSeq = '';
this.eleQAMine = $('
');
this.eleQAYours = $('');
this.resInterval = null;
this.intIntervalSec = 30;
this.strWebinarKey = null;
this.init = function () {
oCommon.intIntervalSec = $('body').data('interval');
oCommon.intIntervalChatSec = $('body').data('interval-chat');
oCommon.intIntervalSurveySec = $('body').data('interval-survey');
oCommon.intIntervalQASec = $('body').data('interval-qa');
oCommon.strWebinarKey = $('body').data('key');
$('a[href="#notifyTooltip"]').click(function () {
if (!$.trim($('#notifyTooltip .tooltip-content').text())) {
return (false);
}
});
oCommon.initToggleLabel();
oCommon.loadWidget();
oCommon.initArchiveList();
if ($('.widget').length > 0) {
oCommon.requestData();
oCommon.requestChatData();
oCommon.requestSurveyData();
oCommon.initInterval();
}else{
oCommon.initInterval('qa');
}
if ($('#qnaMsgPopup.qnaFull').length > 0) {
setTimeout(function(){oCommon.requestQAData();},200);
}
if ($('.notify-wrap .js-close-popup').length > 0) {
$('.notify-wrap .js-close-popup').click(function () {
$('.notify-wrap .badge').hide();
});
}
$('.widget-body').on('click', '.btn-tab[aria-expanded]', function (e) {
let strWidgetID = $(this).attr('id');
if (strWidgetID == 'qnaTab' && $('#qnaContent').is(':visible') == true) {
$('.widget-qna .badge').hide();
}
});
if ($('#notifyTooltip').length > 0) {
$(document).off('click', '#notifyTooltip .js-toggle-content');
$(document).on('click', '#notifyTooltip .js-toggle-content', function () {
console.log($.trim($('.notify-wrap .inner-wrap').text()));
if (!$.trim($('.notify-wrap .inner-wrap').text())) {
$('.notify-wrap').removeClass('is-expanded');
} else {
$('.notify-wrap').addClass('is-expanded');
}
});
}
$('#quizContent').load('/index/_elements/widget_quiz.php');
$('#votingContent').load('/index/_elements/widget_voting.php');
if ($('#qnaMsgPopup').length > 0) {
oCommon.initQAMegPopup();
}
}
this.toggleRegistration = function () {
$('.login_set').toggle();
$('.regi_set').toggle();
if ($('.regi_set').is(':visible')) {
$('.header').parent('div').addClass('login');
$('.header').parent('div').addClass('regi');
$('.btn_login span').text('로그인');
$('.side_menu .modal').click();
if ($(window).width() < 1023) {
$('.form-regi').each(function () {
var instance = $(this).overlayScrollbars();
instance.destroy();
});
} else {
$('.form-regi').each(function () {
var instance = $(this).overlayScrollbars({overflowBehavior: {x: 'hidden', y: 'scroll'}});
});
}
} else {
$('.header').parent('div').removeClass('login');
$('.header').parent('div').removeClass('regi');
$('.btn_login span').text('등록하기');
$('.side_menu .modal').click();
$('.form-regi .os-host').each(function () {
var instance = $(this).overlayScrollbars();
instance.destroy();
});
}
}
this.countDay = function () {
$(".count-dday").each(function () {
let strDDay = $(this).data('dday');
let strDateFormat = $(this).data('format');
console.log(strDateFormat);
if (typeof (strDateFormat) == 'undefined') {
strDateFormat = 'D - %D일 %H시간 %M분 %S초'
}
$(this).countdown(strDDay, function (event) {
$(this).html(
event.strftime(strDateFormat)
);
});
})
}
this.initArchiveList = function () {
$(document).on('click', '.relative-attachment .js-toggle-content', function (e) {
oCommon.loadArchiveList();
});
}
this.loadArchiveList = function () {
$('.relative-attachment #post_list').load('/index/_elements/archive_list.php', {'webinar_key': oCommon.strWebinarKey});
}
this.initQAMegPopup = function () {
$('.msg-slider').slick({
dots: false,
infinite: false,
swipe: false,
slidesToShow: 1,
prevArrow: '.btn-arrow.prev',
nextArrow: '.btn-arrow.next'
});
$('.msg-slider').unbind('beforeChange');
$('.msg-slider').on('beforeChange', function (slick, currentSlide) {
console.log($(currentSlide.$slides[currentSlide.currentSlide]).data('seq'));
oCommon.updateQuestioinStatus($(currentSlide.$slides[currentSlide.currentSlide]).data('seq'), 'close');
});
$('.msg-slider').on('afterChange', function (slick, currentSlide) {
console.log($(currentSlide.$slides[currentSlide.currentSlide]).data('seq'));
oCommon.initQASlideCount();
oCommon.updateQuestioinStatus($(currentSlide.$slides[currentSlide.currentSlide]).data('seq'), 'onair');
});
$('.msg-slider').on('init', function (slick, currentSlide) {
setTimeout(function(){
console.log(currentSlide);
console.log(currentSlide.$slides);
console.log($(currentSlide.$slider)[currentSlide.currentSlide]);
oCommon.updateQuestioinStatus($(currentSlide.$slides[currentSlide.currentSlide]).data('seq'), 'onair');
},1000);
});
oCommon.initQASlideCount();
}
this.initQASlideCount = function(){
$('#qnaMsgPopup .question_number .current').text($('.slick-active').data('current'));
$('#qnaMsgPopup .question_number .total').text($('.slick-slide').length);
}
this.loadSpeakerQA = function () {
let strLastData = $('#qnaMsgPopup').data('last-date');
oCommon.strCurrentQustionSeq = $('.msg-slider .item').eq($('.msg-slider').slick('slickCurrentSlide')).data('seq');
$.ajax({
url: '/index/_elements/append_qa_contents.php',
data: {'webinar_key': oCommon.strWebinarKey, 'last_date': strLastData},
type: 'POST',
dataType: 'jsonp',
success: function (resultData) {
/*
if(resultData) {
openPopup('#qnaMsgPopup', null);
$('.msg-slider').unbind('afterChange');
$('.msg-slider').unbind('init');
$('.msg-slider').slick('unslick');
$('#qnaMsgPopup .msg-slider').append(resultData);
oCommon.initQAMegPopup();
oCommon.initQASlideCount();
$('#qnaMsgPopup').data({'last-date': $('.slick-active').data('last-date')});
if(oCommon.strCurrentQustionSeq) {
$('.msg-slider').slick('goTo', $('.msg-slider .item[data-seq="' + oCommon.strCurrentQustionSeq + '"]').index());
}
}
*/
}
});
/*
$('#qnaMsgPopup .msg-slider').load(
'/index/_elements/popup_qa_contents.php',
{'webinar_key': oCommon.strWebinarKey,'last_date':strLastData},
function () {
openPopup('#qnaMsgPopup', null);
$('.msg-slider').unbind('afterChange');
$('.msg-slider').unbind('init');
$('.msg-slider').slick('unslick');
oCommon.initQAMegPopup();
$('#qnaMsgPopup .question_number .current').text($('.slick-active').data('current'));
$('#qnaMsgPopup .question_number .total').text($('.slick-active').data('total'));
if(oCommon.strCurrentQustionSeq) {
$('.msg-slider').slick('slickGoTo', $('.msg-slider .item[data-seq="' + oCommon.strCurrentQustionSeq + '"]').index());
}
}
);
*/
}
this.updateQuestioinStatus = function (strQuestionKey, strStatus) {
if (strQuestionKey) {
let boolReturn;
if (strStatus == 'close') {
// boolReturn = confirm('답변 완료 처리 하시겠습니까?');
boolReturn = true;
} else {
boolReturn = true;
}
if (boolReturn === true) {
$.ajax({
url: '/_connector/yellow.501.php',
data: {'viewID': 'UPDATE_QUESTION_STATUS', 'webinar_key': oCommon.strWebinarKey, 'question_key': strQuestionKey, 'status': strStatus},
type: 'POST',
dataType: 'json',
success: function (jsonResult) {
if (jsonResult.state) {
if (jsonResult.question_status == 'close') {
$('#msg_' + jsonResult.question_key + ' .status').text('(답변완료)');
}
// if (jsonResult.question_status == 'close') oCommon.loadSpeakerQA();
} else {
alert('답변 완료 처리 오류입니다.');
}
}
});
}
}
}
this.initInterval = function (strType) {
if (typeof (strType) == 'undefined') {
strType = 'all';
}
if (strType == 'all' || strType == 'log') {
if(!oCommon.intIntervalSec){
alert('Log timeout을 확인하세요.');
}else {
oCommon.resInterval = setInterval(function () {
oCommon.requestData();
}, oCommon.intIntervalSec * 1000);
}
}
if (strType == 'all' || strType == 'chat') {
if(!oCommon.intIntervalChatSec){
alert('Chat timeout('+oCommon.intIntervalChatSec+')을 확인하세요.');
}else {
oCommon.resIntervalChat = setInterval(function () {
oCommon.requestChatData();
}, oCommon.intIntervalChatSec * 1000);
}
}
if (strType == 'all' || strType == 'survey') {
if(!oCommon.intIntervalSurveySec){
alert('Survey timeout을 확인하세요.');
}else {
oCommon.resIntervalSurvey = setInterval(function () {
oCommon.requestSurveyData();
}, oCommon.intIntervalSurveySec * 1000);
}
}
if (strType == 'qa') {
if(!oCommon.intIntervalQASec){
// alert('QA timeout을 확인하세요.');
}else {
oCommon.resIntervalQA = setInterval(function () {
oCommon.requestQAData();
}, oCommon.intIntervalQASec * 1000);
}
}
}
this.requestData = function () {
let intLastQASeq = $('#qnaContent').data("last-seq");
let intLastTimestamp = $('#notice_dropdown').data("last-timestamp");
$.ajax({
url: '/index/response_data.php',
data: {'webinar_key': oCommon.strWebinarKey, 'last_qa_seq': intLastQASeq, 'last_timestamp': intLastTimestamp},
type: 'POST',
dataType: 'json',
success: function (jsonResult) {
if (oCommon.intIntervalSec != jsonResult.interval_sec) {
oCommon.intIntervalSec = jsonResult.interval_sec;
clearInterval(oCommon.resInterval);
oCommon.initInterval('log');
}
console.log($('body').data('state'),jsonResult.webinar_state);
if ($('body').data('state') != jsonResult.webinar_state) {
document.location.replace(document.location.href);
}
}
});
}
this.requestChatData = function () {
let intLastQASeq = $('#qnaContent').data("last-seq");
let intLastTimestamp = $('#notice_dropdown').data("last-timestamp");
$.ajax({
url: '/index/response_data_chat.php',
data: {'webinar_key': oCommon.strWebinarKey, 'last_qa_seq': intLastQASeq, 'last_timestamp': intLastTimestamp},
type: 'POST',
dataType: 'json',
success: function (jsonResult) {
if (jsonResult.qa.length > 0) {
oCommon.appendQA(jsonResult.member_key, jsonResult.qa);
}
if (jsonResult.notice.length > 0) {
oCommon.appendNotice(jsonResult.notice);
}
if (jsonResult.counter > 0) {
oCommon.updateCounter(jsonResult.counter);
}
if (oCommon.intIntervalChatSec != jsonResult.interval_sec) {
oCommon.intIntervalChatSec = jsonResult.interval_sec;
clearInterval(oCommon.resIntervalChat);
oCommon.initInterval('chat');
}
}
});
}
this.requestSurveyData = function () {
let intLastQASeq = $('#qnaContent').data("last-seq");
let intLastTimestamp = $('#notice_dropdown').data("last-timestamp");
$.ajax({
url: '/index/response_data_survey.php',
data: {'webinar_key': oCommon.strWebinarKey, 'last_qa_seq': intLastQASeq, 'last_timestamp': intLastTimestamp},
type: 'POST',
dataType: 'json',
success: function (jsonResult) {
let oQuiz = jsonResult.quiz[0];
let oVote = jsonResult.vote[0];
let intQuizSeq = 0;
let intVoteSeq = 0;
if (jsonResult.counter > 0) {
oCommon.updateCounter(jsonResult.counter);
}
if (oCommon.intIntervalSurveySec = jsonResult.interval_sec) {
oCommon.intIntervalSurveySec = jsonResult.interval_sec;
clearInterval(oCommon.resIntervalSurvey);
oCommon.initInterval('survey');
}
if (typeof (oQuiz) != 'undefined') {
intQuizSeq = oQuiz.seq;
}
if (intQuizSeq != $('#quizContent').data('seq')) {
$('#quizContent').data('seq', intQuizSeq);
oCommon.loadQuiz();
}
if (typeof (oVote) != 'undefined') {
intVoteSeq = oVote.seq;
}
if (intVoteSeq != $('#votingContent').data('seq')) {
$('#votingContent').data('seq', intVoteSeq);
oCommon.loadVote();
}
if (jsonResult.start_survey_answered === false) {
oCommon.loadSurvey('start');
}
if (jsonResult.finish_survey_answered === false) {
oCommon.loadSurvey('finish');
}
}
});
}
// 연자용 QA
this.requestQAData = function () {
let strLastDate = $('#qnaMsgPopup').data('last-date');
$.ajax({
url: '/index/response_data_qa.php',
data: {'webinar_key': oCommon.strWebinarKey, 'last_date': strLastDate},
type: 'POST',
dataType: 'jsonp',
success: function (jsonResult) {}
});
}
this.loadSurvey = function (strSurveyType) {
if (!$('#surveyPopup').is(':visible')) {
$('#surveyPopup').load('/index/_elements/survey_popup.php', {'webinar_key': oCommon.strWebinarKey, 'survey_type': strSurveyType}, function () {
openPopup('#surveyPopup', null);
// $('#surveyPopup').addClass('open');
oCommon.initSurveyAnswer();
m_alert("'설문'에 참여해주세요.");
});
}
}
this.appendNotice = function (oNoticeList) {
let intNewFlg = false;
let eleNotice = $('');
let oNotice;
let strSubject;
let eleNoticeDropdown = $('');
for (intKey in oNoticeList) {
oNotice = oNoticeList[intKey];
strSubject = '' + oNotice['subject'] + '';
eleNotice.html(strSubject);
eleNoticeDropdown.html(oNotice['subject']);
if (oNotice.notice_type == 'archive') {
eleNotice.addClass('inform');
eleNoticeDropdown.addClass('inform');
} else {
eleNotice.removeClass('inform');
eleNoticeDropdown.removeClass('inform');
}
$('#notice_widget_list .os-content').prepend(eleNotice).ready(function () {
if ($('#notice_widget_list .os-content > p').length > 1) {
$('#notice_dropdown').addClass('js-toggle-content');
}
});
}
$('#notice_dropdown').data({'last-timestamp': oNotice.onair_timestamp});
$('#notice_dropdown').html(eleNoticeDropdown);
if (oNotice.notice_type == 'archive') {
m_alert("'공지' " + oNotice['subject']);
} else {
m_alert("'알람' " + oNotice['subject']);
}
}
this.appendQA = function (strMemberKey, oQAList) {
console.log(oQAList);
if ($('header').width() > 1023) {
if ($('#QA_list').css('height') != 'auto') {
$('#QA_list').css({'height': 'auto'});
$(window).resize();
}
}
if ($('#QA_list .empty').length > 0) {
$('#QA_list .empty').remove();
}
let intNewFlg = false;
for (intKey in oQAList) {
let oQA = oQAList[intKey];
let eleQA = null;
if (strMemberKey == oQA.member_key) {
eleQA = oCommon.eleQAMine.clone();
eleQA.find('.bubble').text(oQA.post_body);
} else {
intNewFlg = true;
eleQA = oCommon.eleQAYours.clone();
eleQA.find('.bubble').text(oQA.post_body);
eleQA.find('.name').text(oQA.post_name);
if (oQA.photo_file) {
eleQA.find('.profile-img img').attr({'src': oQA.photo_file});
}
}
$('#QA_list').append(eleQA).ready(function () {
$(window).resize();
});
if (intKey == oQAList.length - 1) {
$('#qnaContent').data({'last-seq': oQA.seq});
}
}
if (intNewFlg && !$('#qnaContent').is(':visible')) $('.widget-qna .badge').show();
if ($('#QA_list').length > 0) {
$('#QA_list').scrollTop($('#QA_list')[0].scrollHeight);
$('#QA_list').closest('.os-viewport').scrollTop($('#QA_list')[0].scrollHeight);
}
}
this.loadQuiz = function () {
let intQuizSeq = $('#quizContent').data('seq');
$('#quizContent').load('/index/_elements/widget_quiz.php', {'webinar_key': oCommon.strWebinarKey, 'seq': intQuizSeq}, function () {
$(window).resize();
oCommon.initQuizAnswer();
if ($('#quizContent .empty').length > 0) {
m_alert("'Quiz'가 종료되었습니다.");
// alert("'Quiz'가 종료되었습니다.");
} else {
m_alert("'Quiz'가 등록되었습니다.");
// alert("'Quiz'가 등록되었습니다.");
}
});
}
this.loadVote = function () {
let intVoteSeq = $('#votingContent').data('seq');
$('#votingContent').load('/index/_elements/widget_voting.php', {'webinar_key': oCommon.strWebinarKey, 'seq': intVoteSeq}, function () {
$(window).resize();
oCommon.initVoting();
if ($('#votingContent .empty').length > 0) {
m_alert("'Vote'가 종료되었습니다.");
// alert("'Vote'가 종료되었습니다.");
} else {
m_alert("'Vote'가 등록되었습니다.");
// alert("'Vote'가 등록되었습니다.");
}
});
// $('#votingContent').load('/index/_elements/widget_vote_result.php',{'seq':intVoteSeq},function(){
//
// });
}
this.initInputRange = function () {
$('.d-answer-range').each(function () {
$(this).unbind('input');
$(this).on('input', function () {
$(this).val($(this).val().replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1'));
});
$(this).unbind('blur');
$(this).on('blur', function () {
if ($.trim($(this).val())) {
let dobuleMax = $(this).data('max');
let dobuleMin = $(this).data('min');
if (dobuleMax < $(this).val()) {
$(this).val(dobuleMax);
}
if (dobuleMin > $(this).val()) {
$(this).val(dobuleMin);
}
}
});
});
}
this.initSurveyAnswer = function () {
oCommon.initInputRange();
let intSeq = $('#frm_survey').data('seq');
let eleForm = $('#frm_survey');
let options = {
url: '/_connector/yellow.501.php',
data: {'viewID': "SET_SURVEY_ANSWER", 'webinar_key': oCommon.strWebinarKey, 'survey_seq': intSeq},
dataType: 'json',
resetForm: false,
type: 'post', // 'get' or 'post', override for form's 'method' attribute
beforeSubmit: function () {
let boolReturn = true;
$('#frm_survey .survey-list li').each(function () {
let strAnswerType = $(this).data('answer-type');
if (strAnswerType == 'multi') {
let intMinAnswerCount = $(this).data('min');
let intMaxAnswerCount = $(this).data('max');
if (intMaxAnswerCount != '' && $(this).find('input[type=checkbox]:checked').length > intMaxAnswerCount) {
alert(($(this).index() + 1) + '항목의 최대 응답 가능 수는 ' + intMaxAnswerCount + '개 입니다.');
boolReturn = false;
return (false);
}
if (intMaxAnswerCount != '' && $(this).find('input[type=checkbox]:checked').length < intMinAnswerCount) {
alert(($(this).index() + 1) + '항목의 최초 응답 가능 수는 ' + intMinAnswerCount + '개 입니다.');
boolReturn = false;
return (false);
}
}
if ($(this).find('input[type=radio]').length > 0) {
if ($(this).find('input[type=radio]:checked').length == 0) {
alert(($(this).index() + 1) + '항목에 응답해주세요');
boolReturn = false;
return (false);
}
}
if ($(this).find('input[type=text]').length > 0) {
for (let intIndex = 0; intIndex < $(this).find('input[type=text]').length; intIndex++) {
if (!$.trim($(this).find('input[type=text]').eq(intIndex))) {
alert(($(this).index() + 1) + '항목에 응답해주세요');
boolReturn = false;
return (false);
}
}
}
});
if (boolReturn) {
$('#frm_survey .d-answer-range').each(function () {
let dobuleMax = $(this).data('max');
let dobuleMin = $(this).data('min');
if ((dobuleMax < $(this).val() || dobuleMin > $(this).val()) || isNaN($(this).val())) {
alert(dobuleMin + ' 부터 ' + dobuleMax + ' 사이값을 입력하세요');
$(this).focus();
boolReturn = false;
return (false);
}
});
}
if (boolReturn) {
boolReturn = confirm('등록 하시겠습니까?');
}
return (boolReturn);
},
success: function (jsonResult) {
if (jsonResult.result) {
$('#surveyPopup').removeClass('open').addClass('close');
$('#surveyPopup .container').remove();
m_alert('설문이 제출 되었습니다.');
alert('정상적으로 등록되었습니다');
} else {
m_alert(jsonResult.error_msg);
}
}
};
eleForm.ajaxForm(options);
}
this.initQuizAnswer = function () {
oCommon.initInputRange();
let intSeq = $('#quizContent').data('seq');
let eleForm = $('#frm_quiz');
let options = {
url: '/_connector/yellow.501.php',
data: {'viewID': "SET_SURVEY_ANSWER", 'webinar_key': oCommon.strWebinarKey, 'survey_seq': intSeq},
dataType: 'json',
resetForm: false,
type: 'post', // 'get' or 'post', override for form's 'method' attribute
beforeSubmit: function () {
let boolReturn = true;
$('#frm_quiz .d-answer-range').each(function () {
let dobuleMax = $(this).data('max');
let dobuleMin = $(this).data('min');
if ((dobuleMax < $(this).val() || dobuleMin > $(this).val()) || isNaN($(this).val())) {
alert(dobuleMin + ' 부터 ' + dobuleMax + ' 사이값을 입력하세요');
$(this).focus();
boolReturn = false;
return (false);
}
});
$('#frm_quiz .survey-list li').each(function () {
let strAnswerType = $(this).data('answer-type');
if (strAnswerType == 'multi') {
let intMinAnswerCount = $(this).data('min');
let intMaxAnswerCount = $(this).data('max');
if (intMaxAnswerCount != '' && $(this).find('input[type=checkbox]:checked').length > intMaxAnswerCount) {
alert(($(this).index() + 1) + '항목의 최대 응답 가능 수는 ' + intMaxAnswerCount + '개 입니다.');
boolReturn = false;
return (false);
}
if (intMaxAnswerCount != '' && $(this).find('input[type=checkbox]:checked').length < intMinAnswerCount) {
alert(($(this).index() + 1) + '항목의 최초 응답 가능 수는 ' + intMinAnswerCount + '개 입니다.');
boolReturn = false;
return (false);
}
}
if ($(this).find('input[type=radio]').length > 0) {
if ($(this).find('input[type=radio]:checked').length == 0) {
alert(($(this).index() + 1) + '항목에 응답해주세요');
boolReturn = false;
return (false);
}
}
if ($(this).find('input[type=text]').length > 0) {
for (let intIndex = 0; intIndex < $(this).find('input[type=text]').length; intIndex++) {
if (!$.trim($(this).find('input[type=text]').eq(intIndex))) {
alert(($(this).index() + 1) + '항목에 응답해주세요');
boolReturn = false;
return (false);
}
}
}
});
if (boolReturn) {
boolReturn = confirm('등록 하시겠습니까?');
}
return (boolReturn);
},
success: function (jsonResult) {
if (jsonResult.result) {
oCommon.loadQuiz();
alert('정상적으로 등록되었습니다.');
} else {
m_alert(jsonResult.error_msg)
}
}
};
eleForm.ajaxForm(options);
}
this.initVoting = function () {
let intSeq = $('#votingContent').data('seq');
let eleForm = $('#frm_vote');
let options = {
url: '/_connector/yellow.501.php',
data: {'viewID': "SET_SURVEY_ANSWER", 'webinar_key': oCommon.strWebinarKey, 'survey_seq': intSeq},
dataType: 'json',
resetForm: false,
type: 'post', // 'get' or 'post', override for form's 'method' attribute
beforeSubmit: function () {
let boolReturn = true;
$('#frm_vote .d-answer-range').each(function () {
let dobuleMax = $(this).data('max');
let dobuleMin = $(this).data('min');
if ((dobuleMax < $(this).val() || dobuleMin > $(this).val()) || isNaN($(this).val())) {
alert(dobuleMin + ' 부터 ' + dobuleMax + ' 사이값을 입력하세요');
$(this).focus();
boolReturn = false;
return (false);
}
});
$('#frm_vote .survey-list li').each(function () {
let strAnswerType = $(this).data('answer-type');
if (strAnswerType == 'multi') {
let intMinAnswerCount = $(this).data('min');
let intMaxAnswerCount = $(this).data('max');
if (intMaxAnswerCount != '' && $(this).find('input[type=checkbox]:checked').length > intMaxAnswerCount) {
alert(($(this).index() + 1) + '항목의 최대 응답 가능 수는 ' + intMaxAnswerCount + '개 입니다.');
boolReturn = false;
return (false);
}
if (intMaxAnswerCount != '' && $(this).find('input[type=checkbox]:checked').length < intMinAnswerCount) {
alert(($(this).index() + 1) + '항목의 최초 응답 가능 수는 ' + intMinAnswerCount + '개 입니다.');
boolReturn = false;
return (false);
}
}
if ($(this).find('input[type=radio]').length > 0) {
if ($(this).find('input[type=radio]:checked').length == 0) {
alert(($(this).index() + 1) + '항목에 응답해주세요');
boolReturn = false;
return (false);
}
}
});
if (boolReturn) {
boolReturn = confirm('등록 하시겠습니까?');
}
return (boolReturn);
},
success: function (jsonResult) {
if (jsonResult.result) {
alert('정상적으로 등록 되었습니다.');
oCommon.loadVote();
} else {
m_alert(jsonResult.error_msg)
}
}
};
eleForm.ajaxForm(options);
}
this.initToggleLabel = function () {
$('.js-toggle-label').on('keydown change', function (e) {
var $this = $(this);
var $label = $this.prev('.label');
if (e.type == 'keydown') {
$label.hide();
setTimeout(function () {
if (!$this.val()) {
$label.show();
}
}, 1);
return;
}
if (!$this.val()) {
$label.show();
} else {
$label.hide();
}
});
$('.js-toggle-label').trigger('change');
}
this.loadWidget = function () {
// if($('#noticeContent').length>0){
// $('#noticeContent').load('/index/_elements/widget_notice.php',{'key':oCommon.strWebinarKey},function(){$(window).resize();});
// }
if ($('#qnaContent').length > 0) {
$('#qnaContent').load('/index/_elements/widget_qa.php', {'key': oCommon.strWebinarKey}, function () {
// var instance = OverlayScrollbars(document.getElementById('qnaContent'), { });
// $('#qnaContent.tab-region .chat-view').overlayScrollbars({callbacks:{onContentSizeChanged :function(){this.scroll('100%');}}});
// var instance = $('#qnaContent.tab-region .chat-view').overlayScrollbars({});
// instance.scroll({ y : "100%" });
$('#QA_list').closest('.os-viewport').scrollTop($('#QA_list')[0].scrollHeight);
// $('#QA_list').scrollTop($('#QA_list')[0].scrollHeight);
$(window).resize();
oCommon.initQAForm();
});
}
}
this.initQAForm = function () {
let eleForm = $('#frm_qa');
let options = {
url: '/_connector/yellow.501.php',
data: {'viewID': "SET_QA", 'webinar_key': oCommon.strWebinarKey},
dataType: 'json',
resetForm: true,
type: 'post', // 'get' or 'post', override for form's 'method' attribute
beforeSubmit: function () {
// todo : validation
if ($.trim(eleForm.find('#post_body').val())) {
return (true);
} else {
return (false);
}
},
success: function (jsonResult) {
if (jsonResult.result) {
oCommon.requestChatData();
} else {
m_alert(jsonResult.error_msg);
}
}
};
eleForm.ajaxForm(options);
}
this.getNotice = function (strNoticeType, intNoticeSeq) {
$.ajax({
url: '/_connector/yellow.501.php',
data: {'viewID': 'GET_NOTICE', 'notice_type': strNoticeType, 'notice_seq': intNoticeSeq},
type: 'POST',
dataType: 'json',
success: function (jsonResult) {
$('.alert-msg .msg').html(jsonResult.contents);
openPopup("#alertPopup", null);
}
});
}
}
function responsive_filemanager_callback(strFieldId) {
oCommon.strFilesUploadApplyTargetElementId = strFieldId;
oCommon.fnFileUploadApplyCallback.call();
}
function m_alert(strMsg) {
$('.notify-wrap .tooltip-content .inner-wrap').html(strMsg);
$('.notify-wrap').addClass('is-expanded');
$('.notify-wrap .badge').show();
}
function m_confirm(strMsg) {
return (confirm(strMsg));
}