$(document).ready(function(){ // Gnb Nav (메뉴 class, 서브 메뉴 class) //gnbAction('.gnb-list-main', '.gnb-list-sub'); gnbActionFull('.gnb-list-main-full', '.gnb-list-sub-full'); gnbScroll(); // Side Nav (메뉴 class, 서브 메뉴 class) sideAction('.nav-side-list-main', '.nav-side-list-sub'); // MainSlider mainSlider(); //HeightAuto heightAuto(); // 슬라이딩 Tab & Top //topBtnAction(); // Tab //$("#tabs").tabs(); tabAction(); tabAction2(); tabAction3(); tabAction4(); // Accordion // $("#accordion-list").accordion({ heightStyle: "content", active: false, collapsible: true }); accordionList(); // SideBar sideBarAction(); //Dday Dday(); //OpenPopupLink openPopupLink(); //ImgRolling imgRolling(); // Popup //PopupControlSub(); layerPopup(); $(".csn_1depth > button").click(function () { $(".csn_1depth > ul.csn_sub").toggleClass("on"); }); $(".csn_2depth > button").click(function () { $(".csn_2depth > ul.csn_sub").toggleClass("on"); }); $("#NonReady").click(function(event) { event.preventDefault(); alert("To be Updated!"); }); }); // 관련 함수들 -------------------------------------------------- /* // GNB Full Action function gnbFullAction() { $(".gnb-full-main").hover(function() { //마우스를 topnav에 오버시 $(this).parent().find(".gnb-full-sub").slideDown('normal').show(); //subnav가 내려옴. $(this).parent().hover(function() { }, function(){ $(this).parent().find(".gnb-full-sub").slideUp('fast'); //subnav에서 마우스 벗어났을 시 원위치시킴 }); }); } */ // GNB Action function gnbAction(depth1_name, depth2_name){ var depth1 = $(depth1_name); // 탑 메뉴, 메인메뉴 var depth2 = $(depth2_name); // 서브메뉴 depth2.hide(); depth1.each(function(index) { $(this).hover(function(event) { depth2.eq(index).stop().slideDown(); }, function() { depth2.stop().slideUp(); }); }); } function gnbActionFull(depth1_name, depth2_name){ var depth1 = $(depth1_name); // 탑 메뉴, 메인메뉴 var depth2 = $(depth2_name); // 서브메뉴 depth2.hide(); depth1.each(function(index) { $(this).hover(function(event) { depth2.stop().slideDown(); }, function() { depth2.stop().slideUp(); }); }); } // GNB Scroll function gnbScroll(){ var nav = $("#global-header"); $(window).on("scroll",function(){ if($(this).scrollTop()>250){ nav.addClass("gnb-scroll"); }else{ nav.removeClass("gnb-scroll"); } }); } // Side Action function sideAction(depth1_name, depth2_name){ var depth1 = $(depth1_name); // 탑 메뉴, 메인메뉴 var depth2 = $(depth2_name); // 서브메뉴 depth2.hide(); depth1.each(function(index) { $(this).click(function() { if (depth2.eq(index).is(":hidden")) { depth2.eq(index).stop().slideDown(); } else { depth2.eq(index).stop().slideUp(); } }); }); } //Main Slider function mainSlider() { var nicefade; $(function(){ try { nicefade = $('#visual .visual-main-list').nicefade({ // 전환되는 이미지 목록 animationDelay: 5000, // 다음 화면 전환 텀 // animationSpeed: 2, // 화면 전환 속도 fadeIn:7000, // 페이드인 indexList: $('#visual .visual-btn ul.visual-btn-list') // 버튼 리스트 class }); $('#previous-slide').click(function(e){ // 이전 버튼 e.preventDefault(); nicefade.previous(); }); $('#next-slide').click(function(e){ // 다음 버튼 e.preventDefault(); nicefade.next(); }); $('#stop-slideshow').click(function(e){ // 정지 버튼 e.preventDefault(); nicefade.stop(); }); } catch(e) {} }); } // Img Rolling function imgRolling(){ try { $("#my-als-list").als({ visible_items: 4, scrolling_items: 2, orientation: "vertical", //"horizontal" circular: "yes", autoscroll: "yes", interval: 5000, speed: 100, easing: "linear", direction: "top", start_from: 0 }); } catch(e) {} } // Img Rolling2 function imgRolling2(){ try { $("#my-als-list2").als({ visible_items: 5, scrolling_items: 1, orientation: "horizontal", //"vertical" circular: "yes", autoscroll: "yes", interval: 5000, speed: 100, easing: "linear", direction: "top", start_from: 0 }); } catch(e) {} } // Tab Action function tabAction(){ $(".tab-action-cont").hide(); $(".tab-action-cont").eq(0).show(); $(".tab-action-list li").each(function(i){ $(this).click(function(){ $(".tab-action-list li").removeClass("on"); $(this).addClass("on"); $(".tab-action-cont").hide(); $(".tab-action-cont").eq(i).show(); }); }); } function tabAction2(){ $(".tab-action-cont2").hide(); $(".tab-action-cont2").eq(0).show(); $(".tab-action-list2 li").each(function(i){ $(this).click(function(){ $(".tab-action-list2 li").removeClass("on"); $(this).addClass("on"); $(".tab-action-cont2").hide(); $(".tab-action-cont2").eq(i).show(); }); }); } function tabAction3(){ $(".tab-action-cont3").hide(); $(".tab-action-cont3").eq(0).show(); $(".tab-action-list3 li").each(function(i){ $(this).click(function(){ $(".tab-action-list3 li").removeClass("on"); $(this).addClass("on"); $(".tab-action-cont3").hide(); $(".tab-action-cont3").eq(i).show(); }); }); } function tabAction4(){ $(".tab-action-cont4").hide(); $(".tab-action-cont4").eq(0).show(); $(".tab-action-list4 li").each(function(i){ $(this).click(function(){ $(".tab-action-list4 li").removeClass("on"); $(this).addClass("on"); $(".tab-action-cont4").hide(); $(".tab-action-cont4").eq(i).show(); }); }); } //Accordion List function accordionList() { $('#accordion-list dt').on('click', function () { if ($(this).hasClass('on')) { slideUp(); } else { slideUp(); $(this).addClass('on').next().slideDown(); } function slideUp() { $('#accordion-list dt').removeClass('on').next().slideUp(); }; }) } // Open Accordion and move focus by scrolling. var offset_list = new Array(); function openAccordion(target) { var prefix = 'target-'; var accordion = 'accordion-list'; var i = 0; var target_id = prefix + target; $('#accordion-list dt').removeClass('on').next().slideUp(); $('#accordion-list dt').each(function() { var this_id = $(this).attr("id"); if (this_id == target_id) { $(this).addClass('on').next().slideDown(); var offset_top = offset_list[i]; if (!offset_top) { offset_top = $(this).offset().top; offset_list[i] = offset_top; } $('html, body').animate({scrollTop : offset_top}, 1000); } i++; }); } window.onload = function(){ var i = 0; if (offset_list.length < 1) { $('#accordion-list dt').each(function() { offset_list[i] = $(this).offset().top; i++; }); } } // Top btn Action function topBtnAction(){ var magin_top = 0; //marin-top $('a[href*=#]:not([href=#])').click(function() { if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); if (target.length) { $('html,body').animate({ scrollTop: target.offset().top - magin_top }, 1000); return false; } } }); } // Update function update(){ alert("to be updated"); } //MoreToggle function moreToggle(moreClass) { var display_val = $("."+moreClass).css("display"); if(display_val == "none") { $("."+moreClass).css("display", "block"); } else { $("."+moreClass).css("display", "none"); } } // Height Auto function heightAuto(){ $('.HeightAuto').css('height' , $(window).height() ); $(window).resize(function() { $('.HeightAuto').css('height' , $(window).height() ); }); } // Side Bar Action function sideBarAction(){ var side_offset_top = 400; // Side bar의 시작 위치(top) var side_margin_top = 170; // Side bar의 최소 위치(top) var tmp_scrollTop = $(window).scrollTop(); var apply_offset_top = side_offset_top; $('#side-bar').css("top", side_offset_top); $(window).scroll(function () { if (side_offset_top > $(window).scrollTop()) { apply_offset_top = side_offset_top - $(window).scrollTop(); $('#side-bar').css("top", apply_offset_top); } else { $('#side-bar').css("top", side_margin_top); } }); } function sideBarAction2(){ //by default, the static menu is hidden var showStaticMenuBar = false; //when scrolling... $(window).scroll(function () { //if the static menu is not yet visible... if (showStaticMenuBar == false) { //if I scroll more than 200px, I show it if ($(window).scrollTop() >= 120) { //showing the static menu $('#side-bar').addClass('fixed'); showStaticMenuBar = true; } } //if the static menu is already visible... else { if ($(window).scrollTop() < 20) { $('#side-bar').removeClass('fixed'); //I define it as hidden showStaticMenuBar = false; } } }); } // Dday function Dday(){ //지나온 날짜 계산 //var now = new Date(); //var then = new Date("march 4,2005"); //var gap = now.getTime() - then.getTime(); //gap = Math.floor(gap / (1000 * 60 * 60 * 24)); //document.write("blog 시작한지 " + gap + "일"); //남은 날짜 계산 var now = new Date(); var then = new Date("April 23,2020"); // var gap = then.getTime() - now.getTime(); gap = Math.floor((gap / (1000 * 60 * 60 * 24)) + 2); //document.getElementById('d-day').innerHTML = gap; $('#d-day').html(gap); } // OpenPopupLink function openPopupLink(){ try { $('.open-popup-link').magnificPopup({ type:'inline', midClick: true, fixedContentPos: true, mainClass: 'mfp-fade', overflowY: 'scroll' }); } catch(e) {} } //OpenWindow function openWindow(url,intWidth,intHeight) { window.open(url, "_blank", "width="+intWidth+",height="+intHeight+",resizable=1,scrollbars=1") ; } //LayerPopup function layerPopup(el){ try { var temp = $('#' + el); var bg = temp.prev().hasClass('bg'); //dimmed 레이어를 감지하기 위한 boolean 변수 if(bg){ $('.layer').fadeIn(); //'bg' 클래스가 존재하면, fadeIn 배경은 dimmed }else{ temp.fadeIn(); } // 화면의 중앙에 레이어를 띄움 if (temp.outerHeight() < $(document).height() ) temp.css('margin-top', '-'+temp.outerHeight()/2+'px'); else temp.css('top', '0px'); if (temp.outerWidth() < $(document).width() ) temp.css('margin-left', '-'+temp.outerWidth()/2+'px'); else temp.css('left', '0px'); temp.find('a.cbtn').click(function(e){ if(bg){ $('.layer').fadeOut(); //'bg' 클래스가 존재하면, fadeOut }else{ temp.fadeOut(); } e.preventDefault(); }); $('.layer .bg').click(function(e){ //배경 클릭 시, 레이어 fadeOut 이벤트핸들러 $('.layer').fadeOut(); e.preventDefault(); }); } catch(e) {} } //popup $(document).ready(function() { var id = '#dialog'; //Get the screen height and width var maskHeight = $(document).height(); var maskWidth = $(window).width(); //Set heigth and width to mask to fill up the whole screen $('#mask').css({'width':maskWidth,'height':maskHeight}); //transition effect $('#mask').fadeIn(500); $('#mask').fadeTo("slow",0.85); //Get the window height and width var winH = $(window).height(); var winW = $(window).width(); //Set the popup window to center $(id).css('top', winH/2-$(id).height()/2); $(id).css('left', winW/2-$(id).width()/2); //transition effect $(id).fadeIn(2000); //if close button is clicked $('.window .close').click(function (e) { //Cancel the link behavior e.preventDefault(); $('#mask').hide(); $('.window').hide(); }); //if mask is clicked $('#mask').click(function () { $(this).hide(); $('.window').hide(); }); // 현재 날짜 및 시간 const clock = document.getElementById("ustTime"); function getClock(){ const now = new Date(); let hour = now.getHours(); let minutes = now.getMinutes(); if(hour < 10) hour = "0"+hour; if(minutes < 10) minutes = "0"+minutes; clock.innerText = `${hour}:${minutes}`; } getClock(); setInterval(getClock, 1000); // 한국 시간 const clockSec = document.getElementById("kstTime"); function getClock2(){ const now = new Date(); const utc = now.getTime() + (now.getTimezoneOffset() * 60 * 1000); // 한국 시간 = (UTC + 9시간) const krTimeDiff = 9 * 60 * 60 * 1000; const krTime = new Date(utc + (krTimeDiff)); let khour = krTime.getHours(); let kminutes = krTime.getMinutes(); if(khour < 10) khour = "0"+khour; if(kminutes < 10) kminutes = "0"+kminutes; clockSec.innerText = `${khour}:${kminutes}`; } getClock2(); setInterval(getClock2, 1000); });