PageSourceSearch

https://smartfarmkorea.net/static/js/content.js?v=491945ad-5555-43e4-99b7-843df0e9ccb8

js smartfarmkorea.net collected 2026-10-08 12:05:42 UTC 19,910 bytes, 495 lines download raw bytes

1$(document).ready(function() {
2    
3    // // 탭클릭 공통
4    $('.tabMenu_normal a , .tabMenu_line a , .tabMenu_basic a').click(function (e){
5        e.preventDefault();
6        var parent = $(this).closest('li');
7        if(!parent.hasClass('on')){
8
9            var parentUl = $(this).closest('ul');
10            var clsName = parentUl.prop('class').indexOf('normal') > 1?'tabMenu_normal': (  parentUl.prop('class').indexOf('basic')>0?'tabMenu_basic':'tabMenu_line');
11
12            //현재 선택되어있는 탭메뉴를 해제한다.
13            var nowOnMenu = $( '.' + clsName + ' .on');
14            nowOnMenu.removeClass('on');
15            $('div[class*="tab0"]').hide();
16            nowOnMenu.find('a').attr('title' , '');
17
18            //그 후 현재 선택된 탭메뉴를 표시한다.
19            var myIndex = $('.'+ clsName +' li').index(parent);
20            parent.addClass('on');
21            $(this).attr('title' , '선택됨');
22            $('div[class*="tab0'+ (myIndex + 1)  +'"]').show();
23        }
24    });
25
26
27    // // 레프트 메뉴 - 접기/펼치기
28    $(document).on("click", ".folding_btn", function () {
29        var $snbTitle = $(".snb-title");
30        var $snbTitleTxt = $(".snb-title a");
31        var $menus = $("#snb > .menus");
32
33        if ($snbTitle.width() > 80) {
34            // 접기
35            var originalText = $snbTitleTxt.text().trim(); // 현재 텍스트 저장
36            $snbTitleTxt.data("originalText", originalText); 
37            $snbTitle.animate({ width: "80px" }, 300, function () {
38                $snbTitleTxt.html('메<br>뉴 <div class="folding_btn"><i class="xi-angle-right"></i></div>');
39            });
40            // $menus.animate({ width: "0px" }, 300, function () {$(this).hide();});
41            $menus.fadeOut(300); // 메뉴 숨기기
42            $('#snb').addClass('folding');
43            $('#right-content > .inner').removeClass('sub-paddingL');
44            $('#right-content > .inner').addClass('folding_padding');
45
46            // sub04_0101 페이지에서만 페이지네이션 확인
47            if ($('#right-content').hasClass('sub04_0101')) {
48                setTimeout(function() {
49                    checkSwiperPagination();
50                }, 300);
51            }
52        } else {
53            // 펼치기
54            var originalText = $snbTitleTxt.data("originalText"); // 원래 텍스트 가져오기
55            $snbTitle.animate({ width: "260px" }, 300, function () {
56                $snbTitleTxt.html(originalText + ' <div class="folding_btn"><i class="xi-angle-left"></i></div>');
57            });
58            // $menus.show().animate({ width: "260px" }, 300);
59            $menus.fadeIn(300); // 메뉴 보이기
60            $('#snb').removeClass('folding')
61            $('#right-content > .inner').addClass('sub-paddingL');
62            $('#right-content > .inner').removeClass('folding_padding');
63
64            // sub04_0101 페이지에서만 페이지네이션 확인
65            if ($('#right-content').hasClass('sub04_0101')) {
66                setTimeout(function() {
67                    checkSwiperPagination();
68                }, 300);
69            }
70        }
71    });
72
73    // // 레프트 메뉴 - 메뉴
74    $('#snb .depth2_item.hasChild').click(function(){
75        $('#snb .depth2_item').removeClass('active');
76        $(this).addClass('active');
77    });
78
79
80    // // sub03_0101 분석서비스 탭테이블
81    $(".tabTable_normal li").click(function () {
82        $(".tabTable_normal li").removeClass("on");
83        $(this).addClass("on");
84        });
85
86    $(".tabTable_normal a").click(function () {
87        var parent1 = $(this).closest("li");
88        if (!parent1.hasClass("on")) {
89            var parentUl1 = $(this).closest("ul");
90            var clsName1 =
91            parentUl1.prop("class").indexOf("normal") > 1
92                ? "tabTable_normal"
93                : parentUl1.prop("class").indexOf("basic") > 0
94                ? "tabMenu_basic_cnt"
95                : "tabMenu_line_cnt";
96    
97            //현재 선택되어있는 탭메뉴를 해제한다.
98            var nowOnMenu1 = $("." + clsName1 + ".on");
99            nowOnMenu1.removeClass("on");
100            $('div[class*="tabTable0"]').hide();
101            nowOnMenu1.find("a").attr("title", "");
102    
103            //그 후 현재 선택된 탭메뉴를 표시한다.
104            var myIndex1 = $("." + clsName1 + " li").index(parent1);
105            parent1.addClass("on");
106            $(this).attr("title", "선택됨");
107            $('div[class*="tabTable0' + (myIndex1 + 1) + '"]').show();
108        }
109        });
110
111
112
113    // // sub02_0201 농업교육포털 교육신청 리스트 높이 통일
114    function debounce(func, wait) {
115        let timeout;
116        return function(...args) {
117            clearTimeout(timeout);
118            timeout = setTimeout(() => func.apply(this, args), wait);
119        };
120        }
121        
122        function setEqualHeight() {
123        const techCards = document.querySelectorAll('.sub_cnt_board .smartTech .techCardLi');
124        let maxHeight = 0;
125        
126        // 높이 초기화 (리사이즈, 탭 전환 시 다시 계산하기 위해)
127        techCards.forEach(card => card.style.height = 'auto');
128        
129        // 모든 카드의 높이 측정
130        techCards.forEach(card => {
131            const height = card.offsetHeight;
132            if (height > maxHeight) {
133            maxHeight = height;
134            }
135        });
136        
137        // 모든 카드에 동일한 높이 적용
138        techCards.forEach(card => card.style.height = `${maxHeight}px`);
139        }
140        
141        // 페이지 로드 시 실행
142        window.addEventListener('load', setEqualHeight);
143        
144        // 리사이즈될 때마다 실행 (디바운스 200ms 적용)
145        window.addEventListener('resize', debounce(setEqualHeight, 200));
146        
147        // 탭 클릭 시 실행
148        const tabs = document.querySelectorAll('.sub-tabMenu');
149        tabs.forEach(tab => {
150        tab.addEventListener('click', () => {
151            setTimeout(setEqualHeight, 50);
152        });
153        });
154
155
156    // // sub04_0101 시설원예 데이터셋 - 검색 박스 슬라이드
157    var search_box_swiper = new Swiper('.search_box_swiper', {
158        spaceBetween: 0,
159        slidesPerView: 'auto',
160        loop: false, // 무한 반복 비활성화
161        resistanceRatio: 0, // 스와이프 할 때 양쪽 여백 없게
162        navigation: {
163            nextEl: ".search_box_swiper .btn_next button",
164            prevEl: ".search_box_swiper .btn_prev button",
165        },
166        pagination: {
167            el: '.search_box_swiper .swiper-pagination',
168            type: 'progressbar',
169        },
170        on: {
171            init: function() {
172                // swiper 초기화 후에 pagination 상태 확인
173                checkSwiperPagination();
174            },
175            slideChange: function() {
176                // 슬라이드 변경 시 pagination 상태 확인
177                checkSwiperPagination();
178            }
179        }
180    });
181
182    // 실제 슬라이드들의 width
183    function getActualSlideWidth() {
184        var slides = document.querySelectorAll('.search_box_swiper .swiper-slide');
185        var totalWidth = 0;
186        
187        slides.forEach(function(slide) {
188            totalWidth += slide.offsetWidth; // 각 슬라이드의 실제 너비를 더함
189        });
190        
191        return totalWidth;
192    }
193
194    function checkSwiperPagination() {
195        // #right-content에 hasSearchForm 클래스를 가진 페이지에서만 실행되도록 조건 추가
196        if (document.querySelector('#right-content.hasSearchForm') || window.location.pathname.includes('hasSearchForm')) {
197            var checkWrap = document.querySelector('#searchForm .search_box_wrap .search_check_wrap');
198            var boxWrap = document.querySelector('#searchForm .search_box_wrap');
199            var swiperPagination = document.querySelector('.search_box_swiper .swiper-pagination');
200            var swiperNavigation = document.querySelector('.search_box_wrap .search_box_swiper_ctrl');
201            
202            var totalSlideWidth = getActualSlideWidth(); // 실제 슬라이드들의 총 너비
203            
204            // checkWrap의 너비가 boxWrap의 너비보다 크고, 실제 슬라이드 너비가 boxWrap을 넘을 때 pagination을 보이게 함
205            if (totalSlideWidth >
205 boxWrap.offsetWidth + 5) {
206                swiperPagination.style.display = 'block';
207                swiperNavigation.style.display = 'flex';
208                document.querySelector('#searchForm .search_box_wrap').classList.add('scrollOn');
209            } else {
210                swiperPagination.style.display = 'none';
211                swiperNavigation.style.display = 'none';
212                document.querySelector('#searchForm .search_box_wrap').classList.remove('scrollOn');
213            }
214        }
215    }
216    
217    // 리사이즈 될 때 페이지네이션/내비게이션 새로고침 (레프트 메뉴 접었다 펼 때도 해당 부분 js 적용)
218    window.addEventListener('resize', function() {
219        if (document.querySelector('#right-content.hasSearchForm') || window.location.pathname.includes('hasSearchForm')) {
220            checkSwiperPagination();
221        }
222    });
223
224
225    // // sub04_0301 OPEN-API 탭
226    // 부모 탭 클릭 이벤트
227    $(".board_tab_normal > li[data-type='parent']").click(function () {
228        $(".board_tab_normal > li[data-type='parent']").removeClass("on");
229        $(this).addClass("on");
230
231        // 부모 탭에 맞는 콘텐츠 표시
232        var parentIndex = "0"+($(".board_tab_normal > li[data-type='parent']").index(this) +1);
233        parentIndex = parentIndex.slice(-2);
234        $('div[class*="board_tab"]').hide(); // 모든 부모 콘텐츠 숨기기
235        $('div[class*="board_tab' + parentIndex + '"]').show(); // 해당 부모 콘텐츠만 표시
236    });
237
238    // 부모 탭 내의 a 태그 클릭 이벤트
239    $(".board_tab_normal a[data-type='parent']").click(function () {
240        var parentLi = $(this).closest("li");
241
242        if (!parentLi.hasClass("on")) {
243            // 현재 클릭한 a 태그의 전체 li 인덱스를 구한다
244            var allLis = $(".board_tab_normal > li[data-type='parent']"); // 부모 탭의 li만 선택
245            var liIndex = "0"+(allLis.index(parentLi)+1); // 클릭한 li의 전체 인덱스 구하기
246            liIndex = liIndex.slice(-2);
247
248            // 현재 선택된 탭메뉴 해제
249            allLis.removeClass("on");
250            $('div[class*="board_tab"]').hide();
251            allLis.find("a").attr("title", "");
252
253            // 클릭한 탭메뉴 활성화
254            parentLi.addClass("on");
255            $(this).attr("title", "선택됨");
256
257            // 해당 인덱스에 맞는 탭 콘텐츠 표시
258            $('div[class*="board_tab' + liIndex + '"]').show();
259        }
260    });
261
262    // 자식 탭 클릭 이벤트 (자식 탭에만 적용)
263    $(".board_tab_normal > li[data-type='child']").click(function () {
264        var parentTabContainer = $(this).closest(".board_tab_normal"); // 현재 클릭한 자식 탭의 부모 컨테이너
265        var childLis = parentTabContainer.find("li[data-type='child']"); // 자식 탭 그룹 내 모든 li
266        var parentContent = parentTabContainer.closest('div[class*="board_tab"]'); // 부모 컨텐츠 영역
267
268        var liIndex = "0"+(childLis.index(this)+1); // 클릭한 자식 li의 인덱스 구하기
269        liIndex = liIndex.slice(-2);
270
271        // 현재 선택된 자식 탭메뉴 해제
272        childLis.removeClass("on");
273
274        // 현재 부모 컨텐츠 안의 모든 자식 컨텐츠 숨기기
275        parentContent.find('div[class*="child_tab"]').hide();
276
277        // 클릭한 자식 탭메뉴 활성화
278        $(this).addClass("on");
279
280        // 현재 부모 컨텐츠 안에서 인덱스에 맞는 자식 탭 콘텐츠 표시
281        parentContent.find('div[class*="child_tab' + liIndex + '"]').show();
282    });
283
284    // 부모 탭 클릭 시 자식 탭 상태 유지
285    $(".board_tab_normal > li[data-type='parent']").click(function () {
286        var childLis = $(this).closest(".board_tab_normal").find("li[data-type='child']");
287        // 부모 탭을 클릭할 때 자식 탭의 "on" 클래스를 유지
288        childLis.each(function () {
289            if ($(this).hasClass("on")) {
290                $(this).addClass("on");
291            }
292        });
293    });
294
295     // nice-select 변경 이벤트
296    $(".board_tab_normal_mob select").on("change", function () {
297        var selectedValue = "0"+$(this).val(); // 선택한 옵션의 값 가져오기
298        selectedValue = selectedValue.slice(-2);
299    
300        // 모든 탭 콘텐츠 숨기기 (셀렉트 요소 제외)
301        $('div[class*="board_tab"]').not(".board_tab_normal_mob").hide();
302    
303        // 선택한 값에 해당하는 콘텐츠 표시
304        $('div[class*="board_tab' + selectedValue + '"]').show();
305    });
306
307    
308
309
310    // sub04_0401 농가식별코드
311        //발급방법 슬라이드
312        const swiper = new Swiper('.how_swiper', {
313            speed: 400,
314            spaceBetween: 100,
315            pagination: {
316                el: '.swiper-pagination',
317                type: 'bullets',
318            },
319        });
320
321        //활용예시 탭
322        $('#cont05 ul.tab li').click(function () {
323            if(!$(this).hasClass('active')){
324                var idx = $('#cont05 ul.tab li').index( $(this) );
325                $('#cont05 ul.tab li.active').removeClass('active');
326                $(this).addClass('active');
327                $('#cont05 div[class*="tab_"]').hide();
328                $('#cont05 div.tab_0' + (idx + 1)).show();
329            }
330        })
331
332
333    // 아코디언
334    // 초기 상태에서 .open 클래스를 가진 아코디언은 열려 있음
335    $(".accordionCnt.open").show().removeClass("close");
336
337    // 아코디언 제목 클릭 시
338    $(".accordionTit").click(function () {
339    var $currentAccordionCnt = $(this).next(".accordionCnt");
340    var $currentAccordionSvg = $(this).find(".xi-angle-down");
341
342    if ($currentAccordionCnt.hasClass("close")) {
343        // 현재 클릭된 아코디언을 닫고
344        $currentAccordionCnt.slideUp(200).addClass("close");
345        $currentAccordionSvg.css("transform", "rotate(360deg)");
346        $(this).removeClass('on');
347
348        // 현재 클릭된 아코디언만 열기
349        $currentAccordionCnt.slideDown(200).removeClass("close");
350        $currentAccordionSvg.css("transform", "rotate(180deg)");
351        $(this).addClass('on');
352    } else {
353        // 현재 클릭된 아코디언이 열려있다면 닫기
354        $currentAccordionCnt.slideUp(200).addClass("close");
355        $currentAccordionSvg.css("transform", "rotate(360deg)");
356        $(this).removeClass('on');
357    }
358    });
359
360
361
362    // // sub05_0101 이용안내 - Open API
363    let currentIndex = 0; // 현재 active 상태가 적용될 인덱스
364        const steps = document.querySelectorAll('.stepActiveBox ul li.box'); // li 요소들 가져오기
365
366        function activateStep() {
367            // 이전에 active 상태를 제거
368            steps.forEach(step => step.classList.remove('on'));
369
370            // 현재 인덱스의 li에 on 클래스를 추가
371            steps[currentIndex]?.classList.add('on');
372
373            // 순서대로 진행되도록 인덱스 변경
374            currentIndex = (currentIndex + 1) % steps.length;
374 // 마지막 요소에서 첫 번째로 돌아감
375        }
376
377        // 3초마다 activateStep 함수 호출
378        setInterval(activateStep, 3000);
379
380
381
382    // // 회원가입 (join_step01) 안내사항 닫기
383    $('.join_page .join_caution .btn_list').click(function(){
384        $('.join_caution').hide();
385        $('#joinMembership').show();
386    })
387
388
389    // // 회원가입 (join_step03) 권한 설정
390    $('#rightSelect').change(function() {
391        var selectedValue = $(this).val(); // 선택된 값 가져오기
392
393        // 모든 테이블을 숨김
394        //$('.table-rightSelect').hide();
395
396        // 선택된 권한에 맞는 테이블을 보여줌
397        if (selectedValue === '컨설턴트') {
398            $('.table-consultant').show();
399        } else if (selectedValue === '농업경영체') {
400            $('.table-agriOrganization').show();
401        } else if (selectedValue === '참여기업') {
402            $('.table-partiCompany').show();
403        }
404    });
405
406    //데이터셋 설명 on-off
407    $(".expBtn").on("click", function () {
408        $(this).toggleClass("on");
409
410        if($(this).hasClass("on")){
411            $("#expDiv").show();
412        }else{
413            $("#expDiv").hide();
414        }
415    });
416
417    // sub03_0401 농가활용서비스란
418    $(function () {
419        const $toggleBtn = $('.farmingServicePage .btn_folding');
420        const $tabs = $('.farmingServicePage .board_tab_normal li');
421
422        function getActivePanel() {
423            return $('.farmingServicePage .board_tab01:visible, .farmingServicePage .board_tab02:visible').first();
424        }
425
426        function getItems($panel) {
427            return $panel.find('.farmingService-list > li');
428        }
429
430        function resetAccordion($panel) {
431            getItems($panel).removeClass('open');
432            $panel.find('.accordion-content').stop(true, true).slideUp(0);
433        }
434
435        function updateToggleButton(isOpen) {
436            $toggleBtn.toggleClass('on', isOpen).text(isOpen ? '전체 접기' : '전체 펼치기');
437        }
438
439        function checkAllOpen($panel) {
440            const $items = getItems($panel);
441            return $items.length && $items.length === $items.filter('.open').length;
442        }
443
444        $tabs.on('click', function (e) {
445            e.preventDefault();
446
447            const idx = $(this).index();
448
449            // 탭 active
450            $(this).addClass('on').siblings().removeClass('on');
451
452            // 패널 전환
453            $('.farmingServicePage .board_tab01, .farmingServicePage .board_tab02').hide().eq(idx).show();
454
455            // 새 탭 진입 시 무조건 초기화
456            const $activePanel = getActivePanel();
457            resetAccordion($activePanel);
458            updateToggleButton(false);
459        });
460
461        $(document).on('click', '.accordion-tit', function () {
462            const $panel = $(this).closest('.farmingServicePage .board_tab01, .farmingServicePage .board_tab02');
463            const $item = $(this).closest('li');
464            const $content = $item.find('.accordion-content');
465
466            $item.toggleClass('open');
467            $content.stop(true, true).slideToggle(200);
468
469            // 전부 열리면 버튼 자동 변경
470            updateToggleButton(checkAllOpen($panel));
471        });
472
473        $toggleBtn.on('click', function () {
474            const $panel = getActivePanel();
475            const $items = getItems($panel);
476            const isOpenAll = $(this).hasClass('on');
477
478            if (isOpenAll) {
479                $items.removeClass('open');
480                $panel.find('.accordion-content').stop(true, true).slideUp(200);
481                updateToggleButton(false);
482            } else {
483                $items.addClass('open');
484                $panel.find('.accordion-content').stop(true, true).slideDown(200);
485                updateToggleButton(true);
486            }
487        });
488
489        resetAccordion(getActivePanel());
490        updateToggleButton(false);
491    });
492    
493}); ////
494
495

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.