///ajax let server = "https://letsus.co.kr/study"; function get_step(step){ let str = ""; switch(step){ case "think": str = "생각열기"; break; case "app": str = "응용하기"; break; case "goal": str = "학습목표"; break; case "doing": str = "미리보기"; break; case "step": str = "학습하기"; break; case "exam": str = "실력다지기"; break; case "today": str = "오늘은"; break; } return str; } function insert_qna(obj){ console.log(obj); let res = new Object(); $.ajax({ type: "post", url: server + "/ajax/set_qna.html", data: { func_mode: "insert", class_seq : obj.class_seq, chapter_seq : obj.chapter_seq, study_step : obj.study_step, content : obj.text }, async: false, dataType: "json", success: function(response) { res = response; }, error : function(e){ console.log(e); } }); return res; } function get_qna(){ let res = new Object(); $.ajax({ type: "post", url: server + "/ajax/set_qna.html", data: { func_mode: "get" }, async: false, dataType: "json", success: function(response) { res = response; }, error : function(e){ console.log(e); } }); return res; } $(document).ready(function(){ // header 스크롤 내렸을때 이벤트 // $(function(){ // $(window).scroll(function(){ // var headerScroll = $(this).scrollTop(); // // console.log(headerScroll); // if(headerScroll > 10){ // $('#header').addClass('activated'); // } else { // $('#header').removeClass('activated'); // }; // }); // }); // top_btn 스크롤 이벤트 // $(function(){ // $(window).scroll(function(){ // var topBtn = $(this).scrollTop(); // if(topBtn > 260){ // $('.top_btn').addClass('activated'); // } else { // $('.top_btn').removeClass('activated'); // }; // var topScroll = $('.top_btn'); // topScroll.on('click', function(){ // $('.nav_bottom ul').stop().animate({scrollTop:0}, 500); // }); // }); // }); // bottom_nav 메뉴 스크롤 조절 $('.top_btn').on('click', function() { let menuHeight = document.querySelector('#btScroll').scrollTop; if(menuHeight > 0) { $('#btScroll').animate({ scrollTop:0 }, 500); } else if(menuHeight < 150) { $('#btScroll').animate({ scrollTop:9999 }, 1000); }; }); $('#btScroll').scroll(function() { if($(this).scrollTop() > 0) { $('.top_btn img').addClass('active') } else { $('.top_btn img').removeClass('active') } }); function scrollLength() { let btScrollLength = $('#btScroll li').length; if( btScrollLength > 6 ) { $('.nav_bottom .top_btn').css('display' , 'flex'); } else { $('.nav_bottom .top_btn').css('display' , 'none'); } }; scrollLength(); $('#main .content_tit .content_list a').on('click', function() { if( window.innerWidth < 1380) { $(this).toggleClass('on'); } }); // main_slider 커스텀 // let mainSwiper = new Swiper('.swiper', { // // Optional parameters // direction: 'horizontal', // effect: 'slide', // loop: false, // slidesPerView: 1, // speed: 800, // pagination: { // el: ".swiper-pagination", // type: "fraction", // }, // // Navigation arrows // navigation: { // nextEl: '.swiper-button-next', // prevEl: '.swiper-button-prev', // }, // }) // content_select page tab_menu $('.content_top .diary_list').click(function() { $(this).addClass('on').siblings().removeClass('on') $('.content_middle .diary_wrap').addClass('on').siblings().removeClass('on') }); $('.content_top .reference_list').click(function() { $(this).addClass('on').siblings().removeClass('on') $('.content_middle .reference_wrap').addClass('on').siblings().removeClass('on') }); // 팝업 클릭 이벤트 및 외부영역 클릭시 팝업창 닫기 $('.progress').on('click', function() { let navTop = $('.nav_top'); if( navTop.css('display') === 'none' ) { navTop.show(200); $('.progress img').addClass('on'); } if ( navTop.css('display') === 'block') { // 외부영역 클릭 시 팝업 닫기 $(document).mouseup(function (e) { if(navTop.has(e.target).length === 0){ navTop.hide(200); $('.progress img').removeClass('on'); } }); }; }); // nav_bottom $('#main .content_tit .content_list a').on('click', function() { let navBottom = $('.nav_bottom'); let windowWidth = $(window).width(); if( windowWidth < 1381 || getPageName() == 'app.html' || getPageName() == 'step.html' ) { if( navBottom.css('display') === 'none' ) { navBottom.show(200); $('.content_list a img').addClass('on'); } if ( navBottom.css('display') === 'block') { // 외부영역 클릭 시 팝업 닫기 $(document).mouseup(function (e) { if(navBottom.has(e.target).length === 0){ navBottom.hide(200); $('.content_list a img').removeClass('on'); } }); }; } }); // user menu event $('#header .header_inner .user_box>a, .user_box2>a').on('click', function() { let userMenu = $('.user_menu'); if( userMenu.css('display') === 'none' ) { userMenu.show(200); } if ( userMenu.css('display') === 'block') { // 외부영역 클릭 시 팝업 닫기 $(document).mouseup(function (e) { if(userMenu.has(e.target).length === 0){ userMenu.hide(200); } }); }; }); // step menu btn $('.t_box .t_menu').on('click', function() { let tMenu = $('.t_menu_wrap'); if( tMenu.css('right') < '0' ) { tMenu.addClass('on'); } if ( tMenu.hasClass('on') === true ) { // 외부영역 클릭 시 팝업 닫기 $(document).mouseup(function (e) { if(tMenu.has(e.target).length === 0){ tMenu.removeClass('on'); } }); }; }); $('.t_menu_wrap .t_top .t_menu_close').on('click', function() { $('.t_menu_wrap').removeClass('on'); }); // chapter btn $('.chapter_btn').on('click', function() { let chapter = $('.chapter_wrap'); if( chapter.css('height') < '1' ) { chapter.addClass('on'); $('.chapter_btn img').addClass('on'); } if ( chapter.hasClass('on') === true ) { // 외부영역 클릭 시 팝업 닫기 $(document).mouseup(function (e) { if(chapter.has(e.target).length === 0){ chapter.removeClass('on'); $('.chapter_btn img').removeClass('on'); } }); }; }); $('.download_drop').on('click', function() { let downList = $('.drop_list'); if( downList.css('height') < '1' ) { if( $('.drop_list li').length == 1 ) { $('.drop_list').css('height','54px'); } else if($('.drop_list li').length == 2){ $('.drop_list').css('height','107px'); } else if($('.drop_list li').length == 3){ $('.drop_list').css('height','162px'); } $('#main.step_main .content_tit .tit_right .t_box .download_list ul li:last-child a').css('border-bottom','none'); // downList.addClass('on'); } if ( downList.height() > 1 ) { // 외부영역 클릭 시 팝업 닫기 $(document).mouseup(function (e) { if(downList.has(e.target).length === 0){ $('.drop_list').css('height','0px'); } }); }; }); // menual popup btn // $('.t_box .t_menu').on('click', function() { // let tMenu = $('.t_menu_wrap'); // if( tMenu.css('right') < '0' ) { // tMenu.addClass('on'); // } if ( tMenu.hasClass('on') === true ) { // // 외부영역 클릭 시 팝업 닫기 // $(document).mouseup(function (e) { // if(tMenu.has(e.target).length === 0){ // tMenu.removeClass('on'); // } // }); // }; // }); // day_check complete btn $('.dimm').click(function() { $('.dimm').hide(100); // $('.day_complete').hide(200); }); $('.dimm_complete').click(function() { $(this).hide(0); $('.day_complete').hide(100); $('.notice_popup').hide(100); }); $('.notice_popup a').click(function() { $('.dimm_complete').hide(0); $('.notice_popup').hide(100); }); function menual() { if( $('.menual_popup').hasClass('on') == true ) { $('.t_box .menual_btn').html('교재닫기'); } else if ( $('.menual_popup').hasClass('on') == false ) { $('.t_box .menual_btn').html('교재열기'); } }; // step popup event menual(); $('#main.step_main .content_tit .tit_right .t_box .menual_btn').click(function() { $('.step_content .menual_popup').toggleClass('on'); menual(); }); $('.step_content .menual_popup .close').click(function() { $('.step_content .menual_popup').removeClass('on'); menual(); }); $('.step_content .menual_popup .menual_tit .btn_wrap .click_wide').click(function() { $('.step_content .menual_popup').toggleClass('active'); }); $('.step_content .menual_popup .video_box').click(function() { $('.step_content .menual_popup .video_wrap').toggleClass('active'); $('.step_content .menual_popup .menual_content').toggleClass('active'); }); function getPageName(){ var pageName = ""; var tempPageName = window.location.href; var strPageName = tempPageName.split("/"); pageName = strPageName[strPageName.length-1].split("?")[0]; return pageName; }; if(getPageName() == 'think.html') { $('#think').addClass('on') } else if (getPageName() == 'goal.html') { $('#goal').addClass('on').parent().find('li a').removeClass('on'); } else if (getPageName() == 'doing.html') { $('#doing').addClass('on').parent().find('li a').removeClass('on'); $('.chatbot_wrap, .ar_wrap').css('right','-7%'); } else if (getPageName() == 'exam.html') { $('#exam').addClass('on').parent().find('li a').removeClass('on'); } else if (getPageName() == 'today.html') { $('#today').addClass('on').parent().find('li a').removeClass('on'); } else if (getPageName() == 'content_select.html') { $('.chapter_inner').addClass('chapter_inner2'); }; // exam.html , today.html , info_correction.html 페이지시 content_tit02 클래스 부여 if(getPageName() == 'exam.html' || getPageName() == 'today.html' || getPageName() == 'info_correction.html') { $('.content_tit').addClass('content_tit02'); }; // app.html , step.html 페이지시 menual_btn display:flex 적용 if(getPageName() == 'app.html' || getPageName() == 'step.html') { $('.menual_btn').css('display', 'flex'); $('.t_menu_wrap').addClass('t_menu_wrap02'); $('#main .content_tit .content_list a img').css('display','block'); $('#main .content_tit .content_list').addClass('step_nav') }; // app.html 페이지시 비디오 학습 display none if(getPageName() == 'app.html') { $('.menual_tit .video_box').css('display','none'); }; // chapter_wrap 가로 스크롤 이벤트 // $.fn.hasScrollBar = function() { // return (this.prop("scrollWidth") == 0 && this.prop("clientWidth") == 0) // || (this.prop("scrollWidth") > this.prop("clientWidth")); // }; // 좌우 스크롤이 있는지 없는지 여부 검사 // function wheel(name){ // $(name).on('mousewheel',function(e){ // let hasScroll = $(this).hasScrollBar(); // if(!hasScroll){ //스크롤이 없으면 그냥 일반 스크롤 // }else{ //있으면 아래 스크롤 받는값을 없애고 좌우스크롤 // e.preventDefault(); // let wheelDelta = e.originalEvent.wheelDelta; // if(wheelDelta > 0){ // $(this).scrollLeft(-wheelDelta + $(this).scrollLeft()); // }else{ // $(this).scrollLeft(-wheelDelta + $(this).scrollLeft()); // } // } // }); // } // $(function(){ // wheel('.chapter_inner'); // }); // chatbot $('.chatbot_icon').on('click', function() { let chatBot = $('.chatbot_wrap'); let msg = "안녕! 나는 조이야! 어떤게 궁금해?"; let firstChat = '
  • chatbot_icon

    ' + msg + '

  • '; $('.chatbot_wrap .question_inner').addClass('on'); if( chatBot.css('height') < '2' ) { chatBot.addClass('on'); //ajax $('.talk_box').empty(); $('.talk_box').append(firstChat); } if ( chatBot.hasClass('on') === true ) { // 외부영역 클릭 시 팝업 닫기 $(document).mouseup(function (e) { if(chatBot.has(e.target).length === 0){ chatBot.removeClass('on'); $('.chatbot_wrap .question_inner').removeClass('on'); } }); }; }); $('.ar_icon').on('click', function() { let arBox = $('.ar_wrap'); $('.ar_wrap').addClass('on'); if( arBox.css('height') < '2' ) { arBox.addClass('on'); } if ( arBox.hasClass('on') === true ) { // 외부영역 클릭 시 팝업 닫기 $(document).mouseup(function (e) { if(arBox.has(e.target).length === 0){ arBox.removeClass('on'); $('.chatbot_wrap .ar_inner').removeClass('on'); } }); }; }); $('.chatbot_wrap .close_btn').on('click', function() { $('.chatbot_wrap').removeClass('on'); }); $('.ar_wrap .close_btn').on('click', function() { $('.ar_wrap').removeClass('on'); }); // chatbot 질문등록 // $('.chatbot_text_upload').on('click', function() { // let txtVal = $('#txtVal').val();; // let txtUpload = '
  • '+ txtVal +'

  • '; // $('.talk_box').append(txtUpload); // }); // chatbot $('.chatbot_tab li:first-child').on('click', function() { $('.chatbot_question').addClass('on').siblings().removeClass('on'); $('.chatbot_tab li:first-child a').addClass('on').parent().siblings().find('a').removeClass('on'); }); $('.chatbot_tab li:last-child').on('click', function() { $('.chatbot_check').addClass('on').siblings().removeClass('on') $('.chatbot_tab li:last-child a').addClass('on').parent().siblings().find('a').removeClass('on'); }); });