let DOMAIN = "https://www.funquiz.co.kr"; let GATEWAY = "/ko/gateway"; let CONTEXT_PATH = "/ko"; let USER; function showLoading() { $("body").append("
"); $("body").append("
"); } function hideLoading() { $(".loading").remove(); $(".cover-all-in-progress").remove(); } function removePopupMessage() { $(".cover-all-in-progress").remove(); $(".result-message").remove(); } function toast(msg, duration, callback) { if (typeof window.FUNQUIZAPP !== 'undefined') { window.FUNQUIZAPP.showToast(msg); if (callback && typeof(callback) == "function") callback(); // } else if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.showToast) { // window.webkit.messageHandlers.showToast.postMessage(msg); // if (callback && typeof(callback) == "function") callback(); } else { if (duration == undefined) duration = 800; $("body").append("
"); $("body").append("
"+msg+"
"); var direction = (msg.length < 20) ? "center" : "left"; $("body").append("
"+msg+"
"); $(".result-message").show(); $("#custom-confirm-ok").on("click", function() { removePopupMessage(); if (callback_ok && typeof(callback_ok) == "function") callback_ok(); return false; }); } function showCustomConfirm(msg, callback_ok, callback_cancel) { $("body").append("
"); var direction = (msg.length < 20) ? "center" : "left"; $("body").append("
"+msg+""); $(".result-message").append(""); $(".result-message").append(""); $(".result-message").append("
"); $(".result-message").show(); $("#custom-confirm-ok").focus(); $("#custom-confirm-ok").on("click", function() { removePopupMessage(); if (callback_ok && typeof(callback_ok) == "function") callback_ok(); return false; }); $("#custom-confirm-cancel").on("click", function() { removePopupMessage(); if (callback_cancel && typeof(callback_cancel) == "function") callback_cancel(); return false; }); } function showSpinner(msg) { hideSpinner(); $("body").append("
"); $("body").append("
"+msg+"
"); } function hideSpinner() { $(".cover-all-in-progress").remove(); $(".spinner-box").remove(); } // 로그아웃 function logout() { $.post(GATEWAY + "/logout.fun").done(function() { location.href = CONTEXT_PATH + "/"; }); } // 로그인 후 로컬스토리지에 저장된 폼정보를 읽어 이동시킨다. function goAfterLogin() { var frm = localStorage.getItem("rtn"); localStorage.removeItem("rtn"); if (frm==null || frm=="") { location.href = CONTEXT_PATH + "/"; } else if (frm.indexOf("form")>-1 && frm.indexOf("frmReturn")>-1) { $("body").append(frm); document.frmReturn.submit(); } else { location.href = CONTEXT_PATH + "/"; } return; } // 사용자의 정보를 가져온다. 대부분의 경우 사용하지 않는다. // 이것은 로그인이 필요하지 않은 화면에서 로그인정보를 가져오기 위해 사용한다. function getUser() { $.post(GATEWAY + "/GetSession.fun") .done(function(data) { if ($.trim(data)!="") { USER = JSON.parse($.trim(data)); } setSignZone(); }) .fail(function() { toast("Oops. The server is busy.
Please try again in a moment.", 3000); }); } // 로그인영역을 제어한다. // [주의] 이 함수는 다국어 제어를 위해 페이지가 로드된 이후에 실행되어야 한다. function setSignZone() { $("ul.person_menu").remove(); $(".cover-all-in-progress").remove(); if (USER!=null && USER.domain!="lost") { USER.photo = (USER.photo!=null && USER.photo.indexOf("http")>-1) ? USER.photo : "/statics/images/login/nophoto.png?2023-3"; var html = "
  • "; html += "
  • "; $(".signzone").html(html); } else { var html = ""; html += "
  • "; html += "
  • "+lang.get("common","MENU_SIGNIN")+"
  • "; html += "
  • "+lang.get("common","MENU_SIGNUP")+"
  • "; $(".signzone").html(html); } } // 언어를 변경하면 쿠키를 변경한다. function changeLanguage(strLanguageCode) { if (strLanguageCode==null) strLanguageCode = $("select[name='lang']").val(); if (strLanguageCode=="undefined" || strLanguageCode=="") return; var currentDate = new Date(); var expirationDays = 180; currentDate.setTime(currentDate.getTime() + (expirationDays * 24 * 60 * 60 * 1000)); var expires = "expires=" + currentDate.toUTCString(); var path = "path=/"; // 최상위 경로로 설정 document.cookie = "lang=" + strLanguageCode + "; " + expires + "; " + path; location.reload(); } // 타임존에 따른 현재시간을 구하기 위해 사용자의 시간을 사용한다. // [주의] 이 함수는 CRUD시에 반드시 참조되어야 한다. function getCurrentDateTime() { var date = new Date(); let month = date.getMonth() + 1; let day = date.getDate(); let hour = date.getHours(); let minute = date.getMinutes(); let second = date.getSeconds(); month = month >= 10 ? month : '0' + month; day = day >= 10 ? day : '0' + day; hour = hour >= 10 ? hour : '0' + hour; minute = minute >= 10 ? minute : '0' + minute; second = second >= 10 ? second : '0' + second; return date.getFullYear() + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second; } function getCurrentDate() { var date = new Date(); let month = date.getMonth() + 1; let day = date.getDate(); month = month >= 10 ? month : '0' + month; day = day >= 10 ? day : '0' + day; return date.getFullYear() + '' + month + '' + day; } $(function(){ if (typeof window.FUNQUIZAPP !== 'undefined') { // for fcmkey save in android $.ajax({ method:'post', url: GATEWAY + "/GetToken.fun", }).done(function(r) { if (r!="") window.FUNQUIZAPP.updateUserFcmKey(r); }); } if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.updateUserFcmKey) { // for fcmkey save in ios $.ajax({ method:'post', url: GATEWAY + "/GetToken.fun", }).done(function(r) { if (r!="") window.webkit.messageHandlers.updateUserFcmKey.postMessage(r); }); } $("span.live-quiz-game-bullet").on("click", function(event){ event.preventDefault() var tgt = $(this).parent().parent().attr("onclick"); var regex = /goGame\('(.*?)'\);/; var match = tgt.match(regex); if (match && match.length > 1) { showCustomConfirm(" 지금 바로 게임 파티 열까요?", function() { location.href = "/ko/quiz/live/CreatePin.fun?" + match[1]; }, function() { // }); } return false; }); });