merge master into develop - CscListRForm.jsp FAQ 아코디언 버그 수정

This commit is contained in:
jilee4unity
2026-05-28 23:34:06 +09:00
7250 changed files with 570509 additions and 25 deletions

View File

@@ -0,0 +1,218 @@
const OXQuiz = (function() {
function init() {
loadImages();
addEventListeners();
getNotificationStatus();
}
function loadImages() {
if (screenInfo.basicInfo) {
const imagePath = screenInfo.basicInfo.scrReprsntImg;
loadImage('quizThumnail', imagePath, $('.quizThumnail img'));
}
}
function loadImage(imageType, imagePath, $img) {
if ($img.length) {
$img.attr('src', imagePath);
console.log(`${imageType} image loaded successfully`);
} else {
console.warn(`Image element not found for ${imageType}`);
}
}
function addEventListeners() {
$('#quizResult').on('click', handleQuizResult);
$('.qzSelect a').on('click', handleAnswerSelection);
$('#notificationBtn').on('click', handleNotification);
}
function handleAnswerSelection(e) {
e.preventDefault();
$('.qzSelect a').removeClass('on');
$(this).addClass('on');
}
function handleQuizResult() {
const selectedAnswer = $('.qzSelect a.on').data('answer');
if (!selectedAnswer) {
alert('OX 중 한 가지를 선택해 주세요.');
return;
}
$.ajax({
url: '/sopmal/bnft/participate',
method: 'POST',
contentType: 'application/json',
data: JSON.stringify({
bnfInnb: screenInfo.basicInfo.bnfInnb,
bnfQuizInnb: screenInfo.quizInfoList[screenInfo.currentQuiz - 1].bnfQuizInnb,
answCn: selectedAnswer
}),
success: handleQuizResponse,
error: handleQuizError
});
}
function handleQuizResponse(response) {
if (response.success) {
updateQuizState(response);
showResultModal(response);
} else {
alert(response.message || '퀴즈 참여에 실패했습니다.');
}
}
function handleQuizError(xhr, status, error) {
console.error('퀴즈 참여 실패:', error);
let errorMessage = '퀴즈 참여 중 오류가 발생했습니다. ';
if (xhr.status === 404) {
errorMessage += '퀴즈를 찾을 수 없습니다. 페이지를 새로고침 해주세요.';
} else if (xhr.status === 403) {
errorMessage += '권한이 없습니다. 로그인 상태를 확인해주세요.';
} else {
errorMessage += '잠시 후 다시 시도해주세요.';
}
alert(errorMessage);
}
function showResultModal(response) {
let modalId;
if (response.rewardCode === '13030') {
modalId = 'modal-3'; // 모든 퀴즈 정답
} else if (response.isCorrect) {
modalId = 'modal-1'; // 정답
} else {
modalId = 'modal-2'; // 오답
}
MicroModal.show(modalId, {
onClose: function() {
moveToNextQuiz();
}
});
}
function handleNotification() {
const currentStatus = $(this).data('status');
const newStatus = currentStatus === 'on' ? 'off' : 'on';
$.ajax({
url: '/sopmal/bnft/updateoxquizNotificationStatus',
method: 'POST',
contentType: 'application/json',
data: JSON.stringify({
bnfInnb: screenInfo.basicInfo.bnfInnb,
agreAt: newStatus === 'on' ? 'Y' : 'N'
}),
success: function(response) {
if (response.success) {
updateNotificationButton(newStatus === 'on');
} else {
alert('알림 상태 변경에 실패했습니다.');
}
},
error: function(xhr, status, error) {
console.error('알림 상태 변경 실패:', error);
alert('알림 상태 변경 중 오류가 발생했습니다.');
}
});
}
function getNotificationStatus() {
$.ajax({
url: '/sopmal/bnft/getoxquizNotificationStatus',
method: 'POST',
contentType: 'application/json',
data: JSON.stringify({ bnfInnb: screenInfo.basicInfo.bnfInnb }),
success: function(response) {
updateNotificationButton(response.notificationStatus);
},
error: function(xhr, status, error) {
console.error('알림 상태 조회 실패:', error);
}
});
}
function updateNotificationButton(isNotificationOn) {
const $notificationBtn = $('.live_btn.outline');
const $notificationText = $notificationBtn.find('span');
const $notificationIcon = $notificationBtn.find('i');
if (isNotificationOn) {
$notificationText.text('알림 신청 완료');
$notificationBtn.data('status', 'on').removeClass('outline');
$notificationIcon.removeClass('ico_alarm2').addClass('ico_alarm_on');
} else {
$notificationText.text('알림 신청');
$notificationBtn.data('status', 'off').addClass('outline');
$notificationIcon.removeClass('ico_alarm_on').addClass('ico_alarm2');
}
}
function updateQuizState(quizResult) {
screenInfo.quizInfoList[screenInfo.currentQuiz - 1].userAnswer = quizResult.userAnswer;
screenInfo.quizInfoList[screenInfo.currentQuiz - 1].isCorrect = quizResult.isCorrect ? 'O' : 'X';
updateQuizUI();
}
function updateQuizUI() {
// 퀴즈 스탬프 업데이트
$('.quizStamp li').each(function(index) {
const quizInfo = screenInfo.quizInfoList[index];
$(this).removeClass('on fail location');
if (quizInfo.isCorrect === 'O') {
$(this).addClass('on');
} else if (quizInfo.isCorrect === 'X') {
$(this).addClass('on fail');
}
if (index + 1 === screenInfo.currentQuiz) {
$(this).addClass('location');
}
});
// 현재 퀴즈 내용 업데이트
const currentQuiz = screenInfo.quizInfoList[screenInfo.currentQuiz - 1];
$('.quizBox .txt').text(currentQuiz.quizCn);
$('.bottomBtnControls button:last-child').prop('disabled', currentQuiz.userAnswer !== null);
// 힌트 URL 업데이트
$('.bottomBtnControls button:first-child').attr('onclick', `window.open('${currentQuiz.hintUrl}', '_blank')`);
const $resultButton = $('.bottomBtnControls button:last-child');
if (currentQuiz.userAnswer !== null) {
$resultButton.text('도전완료').prop('disabled', true).removeClass('theme').addClass('gray');
} else {
$resultButton.text('결과확인').prop('disabled', false).removeClass('gray').addClass('theme');
}
}
function moveToNextQuiz() {
if (screenInfo.currentQuiz < screenInfo.quizCount) {
screenInfo.currentQuiz++;
updateQuizUI();
resetQuizSelection();
} else {
alert('모든 퀴즈를 완료하셨습니다!');
}
}
function resetQuizSelection() {
$('.qzSelect a').removeClass('on');
}
function showHintModal(hintUrl) {
$.get(hintUrl, function(data) {
$('#hintModalContent').html(data);
MicroModal.show('hintModal');
});
}
return {
init: init,
showHintModal: showHintModal
};
})();
$(document).ready(function() {
OXQuiz.init();
});