PageSourceSearch

https://www.hnedu.co.kr/comm/js/main.js

js hnedu.co.kr collected 2026-10-09 00:21:24 UTC 10,093 bytes, 315 lines download raw bytes

1$(document).ready(function() {
2    
3    // ----------------------------------------------------
4    // 1. 공통 유틸리티 함수
5    // ----------------------------------------------------
6    // 배경 업데이트 (슬라이드 speed: 600과 동일)
7    var bgSpeed = 600;
8    function updateBackground(bgImg, bgColor, instant) {
9        var $wrap = $('#main-visual .main-visual-bg');
10        var $olds = $wrap.children('.bg');
11        bgColor = bgColor || '#FFFFFF';
12        var css = {
13            'background-color': bgColor,
14            'background-image': bgImg ? 'url(' + bgImg + ')' : 'none',
15            'background-position': 'center',
16            'background-size': 'cover',
17            'background-repeat': 'no-repeat'
18        };
19        if (instant || $olds.length === 0) {
20            if ($olds.length) {
21                $olds.first().css(css);
22                $olds.slice(1).remove();
23            } else {
24                $wrap.append($('<div class="bg"></div>').css(css));
25            }
26            return;
27        }
28        var $next = $('<div class="bg"></div>').css($.extend({}, css, {opacity: 0}));
29        $wrap.append($next);
30        requestAnimationFrame(function() {
31            $next.css('opacity', 1);
32        });
33        setTimeout(function() {
34            $olds.remove();
35        }, bgSpeed);
36    }
37
38    // 숫자 0 붙이기
39    function padNum(num) {
40        return num < 10 ? '0' + num : String(num);
41    }
42
43    // 현재 슬라이드 카운트 텍스트 갱신
44    function updateCount($nav, currentIndex, totalCount) {
45        $nav.find('.current').text(padNum(currentIndex + 1));
46        $nav.find('.total').text(padNum(totalCount));
47    }
48
49
50    // ----------------------------------------------------
51    // 2. 메인 비주얼 (배경 연동형 탭 슬라이드) 셋업
52    // ----------------------------------------------------
53    $('.mainVisual_box').each(function() {
54        var $box = $(this);
55        var $slide = $box.find('.mainVisual_slide');
56        var $nav = $box.find('.mainVisual_nav');
57        var slideCount = $slide.find('.item').length;
58
59        // 아이템이 없으면 패스
60        if (slideCount === 0) return;
61
62        // 아이템이 1개일 경우: 슬라이드 기능 없이 배경/카운트만 세팅
63        if (slideCount < 2) {
64            updateCount($nav, 0, slideCount);
65            if ($box.hasClass('focus')) {
66                var $firstItem = $slide.find('.item').first();
67                updateBackground($firstItem.data('bg-img'), $firstItem.data('bg-color'), true);
68            }
69            return;
70        }
71
72        // Slick 이벤트 바인딩 (반드시 slick() 선언 전에 작성)
73        $slide.on('init reInit', function(event, slick) {
74            updateCount($nav, slick.currentSlide || 0, slick.slideCount);
75            if ($box.hasClass('focus')) {
76                var $currentSlide = $(slick.$slides.get(slick.currentSlide || 0));
77                updateBackground($currentSlide.data('bg-img'), $currentSlide.data('bg-color'), true);
78            }
79        });
80        $slide.on('beforeChange', function(event, slick, currentSlide, nextSlide) {
81            if ($box.hasClass('focus')) {
82                var $nextItem = $(slick.$slides.get(nextSlide));
83                updateBackground($nextItem.data('bg-img'), $nextItem.data('bg-color'));
84            }
85        });
86        $slide.on('afterChange', function(event, slick, currentSlide) {
87            updateCount($nav, currentSlide || 0, slick.slideCount);
88        });
89
90        // Slick 슬라이드 실행 (display: none 인 탭도 일단 다 초기화 해둠)
91        $slide.slick({
92            slidesToShow: 1,
93            slidesToScroll: 1,
94            infinite: true, // 무한 롤링 지원
95            autoplay: true,        // ★ 추가: 자동 재생 켜기
96            autoplaySpeed: 4000,   // ★ 추가: 4초(4000ms)마다 슬라이드 넘김
97            arrows: false,
98            dots: false,
99            adaptiveHeight: false,
100            speed: 600
101        });
102
103        // 네비게이션 좌/우 버튼 클릭 이벤트 (해당 박스 내부의 슬라이드만 제어)
104        $nav.find('.prev').on('click', function(e) {
105            e.preventDefault();
106            $slide.slick('slickPrev');
107        });
108        $nav.find('.next').on('click', function(e) {
109            e.preventDefault();
110            $slide.slick('slickNext');
111        });
112    });
113
114
115    // ----------------------------------------------------
116    // 3. 탭 클릭 시 이벤트 (배경 즉시 연동 및 크기 재계산)
117    // ----------------------------------------------------
118    $('.mainVisual_tab li').on('click', function() {
119        var tab_id = $(this).data('tab');
120
121        // 탭 버튼 활성화 디자인
122        $('.mainVisual_tab li').removeClass('focus');
123        $(this).addClass('focus');
124
125        // 콘텐츠 박스 교체
126        $('.mainVisual_box').removeClass('focus');
127        var $activeBox = $('#' + tab_id);
128        $activeBox.addClass('focus');
129
130        var $activeSlide = $activeBox.find('.mainVisual_slide');
131
132        if ($activeSlide.hasClass('slick-initialized')) {
133            // 숨어있던 슬라이드가 나타날 때 사이즈 오류 해결하는 핵심 코드
134            $activeSlide.slick('setPosition');
135            
136            // 탭이 바뀌는 즉시, 그 탭이 멈춰있는 현재 슬라이드의 배경으로 업데이트
137            var slickObj = $activeSlide.slick('getSlick');
138            var currentIndex = slickObj.currentSlide;
139            var $currentSlide = $(slickObj.$slides.get(currentIndex));
140            updateBackground($currentSlide.data('bg-img'), $currentSlide.data('bg-color'));
141        } else {
142            // 슬라이드 개수가 1개라 slick이 초기화 안된 박스일 때
143            var $firstItem = $activeBox.find('.item').first();
144            if ($firstItem.length) {
145                updateBackground($firstItem.data('bg-img'), $firstItem.data('bg-color'));
146            }
147        }
148    });
149
150
151    // ----------------------------------------------------
152    // 4. 메인 우측 배너 슬라이드 (동기화 슬라이드)
153    // ----------------------------------------------------
154    var $bannerSlide = $('.mainBanner_slide');
155    var $bannerTitSlide = $('.mainBanner_titSlide');
156    
157    if ($bannerSlide.find('.item').length > 1) {
158        $bannerSlide.slick({
159            slidesToShow: 1,
160            slidesToScroll: 1,
161            infinite: true,
162            autoplay: true,        // ★ 추가: 자동 재생 켜기
163            autoplaySpeed: 4000,   // ★ 추가: 4초(4000ms)마다 슬라이드 넘김
164            arrows: false,
165            dots: false,
166            speed: 600,
167            asNavFor: '.mainBanner_titSlide'
168        });
169        
170        // 동기화되는 텍스트 슬라이드에는 autoplay를 넣지 않아도 
171        // asNavFor로 연결된 메인 슬라이드가 넘어가면 알아서 같이 넘어갑니다.
172        $bannerTitSlide.slick({
173            slidesToShow: 1,
174            slidesToScroll: 1,
175            infinite: true,
176            arrows: false,
177            dots: false,
178            speed: 600,
179            asNavFor: '.mainBanner_slide'
180        });
181
182        // 우측 배너 화살표 연결
183        $('.mainBanner_head .prev').on('click', function() {
184            $bannerSlide.slick('slickPrev');
185        });
186        $('.mainBanner_head .next').on('click', function() {
187            $bannerSlide.slick('slickNext');
188        });
189    }
190
191});
192
193$(document).ready(function(){
194	
195	$('.library_tab li').click(function(){
196		var tab_id = $(this).attr('data-tab');
197		$('.library_tab li').removeClass('focus');
198		$('.library_box').removeClass('focus');
199		$(this).addClass('focus');
200		$("#"+tab_id).addClass('focus').find(".subject_tab li").eq(0).trigger("click");
201		$('.library_roll').slick('setPosition');
202	});
203
204	$('.subject_tab li').click(function(){
205		var tab_id = $(this).attr('data-tab-sub');
206		$('.subject_tab li').removeClass('on');
207		$('.subject_box').removeClass('on');
208		$(this).addClass('on');
209		$("#"+tab_id).addClass('on');
210		$('.library_roll').slick('setPosition');
211	});
212
213
214		$('.library_roll').slick({
215			infinite: false,
216			slidesToShow: 5,
217			slidesToScroll: 5,
218			dots: false,
219			arrows: true,
220			autoplay: false,
221			speed: 1000,
222			autoplaySpeed: 5000,
223			responsive: [
224				{
225					breakpoint: 1281,
226					settings: {
227						slidesToShow: 4,
228						slidesToScroll: 4,
229					}
230				},
231				{
232					breakpoint: 981,
233					settings: {
234						slidesToShow: 3,
235						slidesToScroll: 3,
236					}
237				},
238				{
239					breakpoint: 681,
240					settings: {
241						slidesToShow: 2,
242						slidesToScroll: 2,
243					}
244				}
245			]
246		});
247			
248		$('.book_roll').slick({
249			infinite: false,
250			slidesToShow: 5,
251			slidesToScroll: 5,
252			dots: false,
253			arrows: true,
254			prevArrow: $('#book_prev'),
255			nextArrow: $('#book_next'),
256			autoplay: false,
257			speed: 1000,
258			autoplaySpeed: 5000,
259			responsive: [
260				{
261					breakpoint: 1281,
262					settings: {
263						slidesToShow: 4,
264						slidesToScroll: 4,
265					}
266				},
267				{
268					breakpoint: 981,
269					settings: {
270						slidesToShow: 3,
271						slidesToScroll: 3,
272					}
273				},
274				{
275					breakpoint: 681,
276					settings: {
277						slidesToShow: 2,
278						slidesToScroll: 2,
279					}
280				}
281			]
282		});
283			
284		$('.multimedia_roll').slick({
285			infinite: false,
286			slidesToShow: 3,
287			slidesToScroll: 1,
288			dots: false,
289			arrows: true,
290			prevArrow: $('#multimedia_prev'),
291			nextArrow: $('#multimedia_next'),
292			autoplay: false,
293			speed: 1000,
294			autoplaySpeed: 5000,
295			responsive: [
296				{
297					breakpoint: 981,
298					settings: {
299						slidesToShow: 2,
300						slidesToScroll: 1,
301					}
302				},
303				{
304					breakpoint: 481,
305					settings: {
306						slidesToShow: 1,
307						slidesToScroll: 1,
308					}
309				}
310			]
311		});
312
313
314
315});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.