PageSourceSearch

https://miguhara.com/ind-script/optimizer_user.php?filename=lY9BDs…8add7ef6676893726cfe0a7&t=1782981438&user=T

js miguhara.com collected 2026-10-07 20:17:08 UTC 40,033 bytes, 1,170 lines download raw bytes

1document.addEventListener("DOMContentLoaded", function () {
2
3    function scrollItemIntoView(item) {
4    if (!item) return;
5
6    item.scrollIntoView({
7        behavior: "smooth",
8        inline: "start",
9        block: "nearest"
10    });
11}
12
13
14    /* =====================================================
15        0. 기본 설정
16    ===================================================== */
17    const mode = localStorage.getItem("cate_mode") || "category";
18    const groupNames = {
19        category: "카테고리별",
20        line: "라인별",
21        best: "베스트",
22        new: "신상품",
23        sale: "특가"
24    };
25
26    const switchRow   = document.querySelector('.cate-switch-row');
27    const switchGroup = document.getElementById('cateSwitchGroup');
28    const cateBtn     = document.getElementById("cateSwitchBtn");
29    const dynamicList = document.getElementById("cateDynamicList");
30    const mainCateList = document.getElementById("mainCateList");
31
32    cateBtn.innerText = groupNames[mode];
33    document.body.classList.add("js-ready");
34
35    /* =====================================================
36        1. BEST 슬라이드 (기존 유지)
37    ===================================================== */
38    const prdListBestEl = document.getElementById("prdListBestSlide");
39    if (prdListBestEl) {
40        new Swiper(prdListBestEl, {
41            speed: 400,
42            slidesPerView: 2.5,
43            spaceBetween: 10,
44            autoHeight: true,
45            pagination: {
46                el: "#prdListBestSlide .swiper-pagination",
47                type: "progressbar",
48            },
49            breakpoints: {
50                768: {
51                    spaceBetween: 23,
52                    slidesPerView: 4.5,
53                },
54            },
55            on: {
56                init() {
57                    prdListBestEl.classList.add("swReady");
58                },
59            },
60        });
61    }
62
63    /* =====================================================
64        2. 카테고리 번호 상수
65    ===================================================== */
66    const CATEGORY_CATE = 172;
67    const LINE_CATE     = 174;
68    const BEST_CATE     = 301;
69    const NEW_CATE      = 169;
70    const SALE_CATE     = 247;
71
72    /* =====================================================
73        3. 카테고리 그룹 찾기
74    ===================================================== */
75    function findGroupByCateNo(cateNo) {
76        const link = document.querySelector(`.menuCategory a[href*="cate_no=${cateNo}"]`);
77        if (!link) return null;
78        const li = link.closest("li");
79        return li ? li.querySelector(".mcate3_ul") : null;
80    }
81
82    function determineGroupMode(group, mode, targetCateNo) {
83        if (!group || !targetCateNo) return null;
84        return [...group.querySelectorAll("a")].some(a =>
85            a.href.includes(`cate_no=${targetCateNo}`)
86        ) ? mode : null;
87    }
88
89    /* =====================================================
90        4. 그룹 매핑
91    ===================================================== */
92    const categoryGroups = {
93        category: { group: findGroupByCateNo(CATEGORY_CATE), name: "카테고리별" },
94        line:     { group: findGroupByCateNo(LINE_CATE),     name: "라인별" },
95        best:     { group: findGroupByCateNo(BEST_CATE),     name: "베스트" },
96        new:      { group: findGroupByCateNo(NEW_CATE),      name: "신상품" },
97        sale:     { group: findGroupByCateNo(SALE_CATE),     name: "특가" }
98    };
99
100    /* =====================================================
101        5. 카테고리 렌더링
102    ===================================================== */
103   function copyCategories(sourceGroup) {
104    if (!sourceGroup) return;
105
106    const nowCate = new URLSearchParams(location.search).get("cate_no");
107    dynamicList.innerHTML = "";
108
109    sourceGroup.querySelectorAll("li").forEach(li => {
110        const a = li.querySelector("a");
111        if (!a) return;
112
113        const newLi = document.createElement("li");
114        const newA  = document.createElement("a");
115
116        newA.href = a.href;
117        newA.innerText = a.innerText.replace(/\s*\(.*?\)/g, "").trim();
118
119        if (newA.href.includes(`cate_no=${nowCate}`)) {
120            newLi.classList.add("selected");
121        }
122
123        newLi.appendChild(newA);
124        dynamicList.appendChild(newLi);
125    });
126}
127
128/*
129카테고리별에 첫번째 li는 안 나오도록
130 function copyCategories(sourceGroup) {
131        if (!sourceGroup) return;
132
133        const nowCate = new URLSearchParams(location.search).get("cate_no");
134        dynamicList.innerHTML = "";
135
136        const isCategoryMode = localStorage.getItem("cate_mode") === "category";
137        let index = 0;
138
139        sourceGroup.querySelectorAll("li").forEach(li => {
140            const a = li.querySelector("a");
141            if (!a) return;
142
143            if (isCategoryMode && index === 0) {
144                index++;
145                return;
146            }
147
148            const newLi = document.createElement("li");
149            const newA  = document.createElement("a");
150
151            newA.href = a.href;
152            newA.innerText = a.innerText.replace(/\s*\(.*?\)/g, "").trim();
153
154            if (newA.href.includes(`cate_no=${nowCate}`)) {
155                newLi.classList.add("selected");
156            }
157
158            newLi.appendChild(newA);
159            dynamicList.appendChild(newLi);
160            index++;
161        });
162    }
163
164*/
165
166    function centerCategoryItem(item) {
167        const container = dynamicList;
168        const scrollPos =
169            item.offsetLeft -
170            container.offsetWidth / 2 +
171            item.offsetWidth / 2;
172
173        container.scrollLeft = Math.max(
174            0,
175            Math.min(scrollPos, container.scrollWidth - container.clientWidth)
176        );
177    }
178
179    function renderCategory(mode) {
180        const groupInfo = categoryGroups[mode];
181        cateBtn.innerText = groupInfo?.name || "카테고리별";
182
183        if (!groupInfo?.group) return;
184        copyCategories(groupInfo.group);
185
186        requestAnimationFrame(() => {
187            const selected = dynamicList.querySelector(".selected");
188            if (selected) {
189                    scrollItemIntoView(selected);
190            }
191        });
192    }
193
194    /* =====================================================
195        6. 초기 모드 결정
196    ===================================================== */
197    const params = new URLSearchParams(location.search);
198    const cateNo = params.get("cate_no");
199
200    let initialMode = mode;
201
202    if (cateNo == LINE_CATE) initialMode = "line";
203    else if (cateNo == BEST_CATE) initialMode = "best";
204    else if (cateNo == NEW_CATE) initialMode = "new";
205    else if (cateNo == SALE_CATE) initialMode = "sale";
206    else {
207        initialMode =
208            determineGroupMode(categoryGroups.category.group, "category", cateNo) ||
209            determineGroupMode(categoryGroups.line.group, "line", cateNo) ||
210            determineGroupMode(categoryGroups.best.group, "best", cateNo) ||
211            determineGroupMode(categoryGroups.new.group, "new", cateNo) ||
212            determineGroupMode(categoryGroups.sale.group, "sale", cateNo) ||
213            "category";
214    }
215
216    localStorage.setItem("cate_mode", initialMode);
217    renderCategory(initialMode);
218
219    /* =====================================================
220        7. 모바일 토글 (click)
221    ===================================================== */
222    cateBtn.addEventListener("click", function (e) {
223        e.preventDefault();
224        e.stopPropagation();
225
226        if (window.innerWidth <= 1000) {
227            switchRow.classList.toggle("active");
228        }
229    });
230
231    /* =====================================================
232        8. PC 화살표 상태 고정 (핵심)
233    ===================================================== */
234    if (switchGroup && mainCateList) {
235
236        // 버튼 처음 hover 시 화살표 고정
237        switchGroup.addEventListener("mouseenter", () => {
238            if (window.innerWidth > 1000) {
239                switchRow.classList.add("is-open");
240            }
241        });
242
243        // 버튼 + 메뉴 영역 완전히 벗어나면 해제
244        document.addEventListener("mousemove", (e) => {
245            if (window.innerWidth <= 1000) return;
246
247            if (
248                !switchGroup.contains(e.target) &&
249                !mainCateList.contains(e.target)
250            ) {
251                switchRow.classList.remove("is-open");
252            }
253        });
254    }
255
256/* =====================================================
257        9. 드롭다운 메뉴 클릭 
258    ===================================================== */
259    if (mainCateList) {
260        mainCateList.querySelectorAll("li a").forEach(a => {
261            a.addEventListener("click", function (e) {
262                e.preventDefault();
263                e.stopPropagation();
264
265                const targetMode = this.dataset.mode;
266                if (!targetMode) {
267                    location.href = this.href;
268                    return;
269                }
270
271                localStorage.setItem("cate_mode", targetMode);
272                renderCategory(targetMode);
273
274                switchRow.classList.remove("active");
275
276                const NO_SUB_CATEGORIES = ["sale", "best", "new"];
277                
278                if (NO_SUB_CATEGORIES.includes(targetMode)) {
279                    location.href = this.href;
280                    return; 
281                }
282
283                requestAnimationFrame(() => {
284                    const first = dynamicList.querySelector("li a");
285                    if (first) first.click();
286                });
287            });
288        });
289    }
290
291});
292
293$(document).ready(function(){
294    var $d1_wrap = $('.gnb_menu');
295    var $d1_img = $('.category_img li');
296    var $d1_list = $d1_wrap.find('.d1');
297    var len = $d1_list.length;
298
299    $.ajax({
300        url : '/exec/front/Product/SubCategory',
301        dataType: 'json',
302        success: function(aData) {
303            if (aData == null || aData == 'undefined') {
304                return;
305            }
306            $.each(aData, function(index, key) {
307                var $d1 = $d1_wrap.find('.d1[data-param$="=' + key.parent_cate_no + '"]');
308                if ($d1.length > 0) {
309                    var _index = $d1_list.index($d1);
310
311                    if ($d1.hasClass('sub_on') === false) {
312                        $d1.addClass('sub_on');
313                        $d1.append('<div class="d2-wrap"></div>');
314                    }
315                    $d1.find('.d2-wrap').append('<p><a href="/product/list.html'+key.param+'">'+key.name+'</a></p>');
316                    return;
317                }
318
319                var $d2 = $d1_wrap.find('.d2[data-param$="=' + key.parent_cate_no + '"]');
320            });
321        }
322    });
323});
324$(function(){ 
325    if($(".menuCategory > li").length==0){
326         $(".menuCategory").hide();
327    };
328    
329    
330    
331    $('.xans-product-menupackage .menuCategory > li').mouseover(function(){
332    	$(this).children('ul').css('display','inline-block');
333  	});
334    
335    $('.xans-product-menupackage .menuCategory > li').mouseout(function(){
336    	$(this).children('ul').css('display','none');
337  	});
338    
339    $('.xans-product-menupackage .menuCategory > li > ul > li').mouseover(function(){
340    	$(this).children('.button').children('.subCategory').css('display','inline-block');
341  	});
342    
343    $('.xans-product-menupackage .menuCategory > li > ul > li').mouseout(function(){
344    	$(this).children('.button').children('.subCategory').css('display','none');
345  	});
346        
347});
348
349
350
351$(document).ready(function(){
352    var $cate1_ul = $('.cate1_ul');
353    var $cate1_li_img = $('.category_img li');
354    var $cate1_li_list = $cate1_ul.find('.cate1_li');
355    var len = $cate1_li_list.length;
356
357    $.ajax({
358        url : '/exec/front/Product/SubCategory',
359        dataType: 'json',
360        success: function(aData) {
361            if (aData == null || aData == 'undefined') {
362                return;
363            }
364            $.each(aData, function(index, key) {
365                var $cate1_li = $cate1_ul.find('.cate1_li[data-param$="=' + key.parent_cate_no + '"]');
366                if ($cate1_li.length > 0) {
367                    var _index = $cate1_li_list.index($cate1_li);
368
369                    if ($cate1_li.hasClass('more_cate') === false) {
370                        $cate1_li.addClass('more_cate');
371                        $cate1_li.append('<div class="cate2_ul"><ul></ul><div class="img">'+$cate1_li_img.eq(_index % len).html()+'</div></div>');
372                    }
373                    $cate1_li.find('.cate2_ul ul').append('<li data-param="'+key.param+'" class="cate2_li"><a href="/product/list.html'+key.param+'">'+key.name+'</a></li>');
374                    return;
375                }
376
377                var $cate2_li = $cate1_ul.find('.cate2_li[data-param$="=' + key.parent_cate_no + '"]');
378                if ($cate2_li.length > 0) {
379                    if ($cate2_li.hasClass('more_cate') === false) {
380                        $cate2_li.addClass('more_cate');
381                        $cate2_li.append('<ul class="cate3_ul"></ul>');
382                    }
383                    $cate2_li.find('.cate3_ul').append('<li data-param="'+key.param+'" class="cate3_li"><a href="/product/list.html'+key.param+'">'+key.name+'</a></li>');
384                    return;
385                }
386
387                var $cate3_li = $cate1_ul.find('.cate3_li[data-param$="=' + key.parent_cate_no + '"]');
388                if ($cate3_li.hasClass('more_cate') === false) {
389                    $cate3_li.addClass('more_cate');
390                    $cate3_li.append('<ul class="cate4_ul"></ul>');
391                }
392                $cate3_li.find('.cate4_ul').append('<li data-param="'+key.param+'" class="cate4_li"><a href="/product/list.html'+key.param+'">'+key.name+'</a></li>');
393            });
394
395            setCategory();
396        }
397    });
398});
399
400function setCategory(){
401    
402    //마우스 오버시 효과
403	(function(){
404		var $this=$('#category_wrap');
405		var $cate1_li=$this.find('.cate1_li');
406		var $cate2_li=$this.find('.cate2_li');
407        var $cate3_li=$this.find('.cate3_li');
408		var fadespeed=200;
409
410		$cate1_li.bind('mouseenter',function(){			
411			$(this).addClass('viewcate');           
412			$(this).find('.cate2_ul').stop(true,true).fadeIn(fadespeed);
413			if($(this).hasClass('more_cate')==false){
414                var $cate1_li_img = $('.category_img li');
415                var $cate1_li_list = $('.cate1_ul').find('.cate1_li');
416                var len = $cate1_li_list.length;
417                var _index = $(this).index();
418                if($cate1_li_img.eq(_index % len).html().indexOf('img')=="-1"){
419                    $('div.img_nocate').remove();
420                }else{
421					$(this).append('<div class="img_nocate">'+$cate1_li_img.eq(_index % len).html()+'</div>');
422                }
423            }
424		}).bind('mouseleave',function(){
425			$(this).removeClass('viewcate');
426			$(this).find('.cate2_ul').stop(true,true).fadeOut(fadespeed);
427            $('div.img_nocate').remove();
428		});
429		$cate2_li.bind('mouseenter',function(){
430			$cate2_li.css('z-index',0);
431			$(this).css('z-index',1);
432			$(this).find('.cate3_ul').stop(true,true).fadeIn(fadespeed);
433			$(this).addClass('viewcate');
434		}).bind('mouseleave',function(){
435			$(this).find('.cate3_ul').stop(true,true).fadeOut(fadespeed);
436			$(this).removeClass('viewcate');
437		});
438        $cate3_li.bind('mouseenter',function(){
439			$cate3_li.css('z-index',0);
440			$(this).css('z-index',1);
441			$(this).find('.cate4_ul').stop(true,true).fadeIn(fadespeed);
442			$(this).addClass('viewcate');
443		}).bind('mouseleave',function(){
444			$(this).find('.cate4_ul').stop(true,true).fadeOut(fadespeed);
445			$(this).removeClass('viewcate');
446		});
447	})();
448
449
450    
451    	//전체카테고리
452	(function(){
453		var $this=$('#category_all');
454		var $cate1_li=$this.find('.cate1_li');
455		var $cate2_li=$this.find('.cate2_li');
456        var $cate3_li=$this.find('.cate3_li');
457		var $close=$this.find('.close_allcate');
458        var $cate_all_btn=$('#allcate_310618');
459		var fadespeed=200;
460        
461		$cate1_li.bind('mouseenter',function(){
462			$cate1_li.css('z-index',0);
463			$(this).css('z-index',1);
464			$(this).addClass('viewallcate');
465		}).bind('mouseleave',function(){
466			$(this).removeClass('viewallcate');
467		});
468		$cate2_li.bind('mouseenter',function(){
469			$cate2_li.css('z-index',0);
470			$(this).css('z-index',1);
471			$(this).find('.cate3_ul').stop(true,true).fadeIn(fadespeed);
472			$(this).addClass('viewallcate');
473		}).bind('mouseleave',function(){
474			$(this).find('.cate3_ul').stop(true,true).fadeOut(fadespeed);
475			$(this).removeClass('viewallcate');
476		});
477        $cate3_li.bind('mouseenter',function(){
478			$cate3_li.css('z-index',0);
479			$(this).css('z-index',1);
480			$(this).find('.cate4_ul').stop(true,true).fadeIn(fadespeed);
481			$(this).addClass('viewallcate');
482		}).bind('mouseleave',function(){
483			$(this).find('.cate4_ul').stop(true,true).fadeOut(fadespeed);
484			$(this).removeClass('viewallcate');
485		});
486        
487        $this.bind('click',function(e){
488             e.stopPropagation();
489        })
490        
491        
492        $cate_all_btn.bind('mouseenter',function(){
493            $(this).addClass('viewallcate');
494			$('#category_all').stop(true,true).fadeIn(fadespeed);
495            
496  			$('#scroll_icon').delay(200).fadeIn(200);
497            setTimeout(function() {
498  				$('#scroll_icon').addClass('scroll_icon_on');
499                setTimeout(function() {
500  					$('#scroll_icon').fadeOut(1000);
501                    setTimeout(function() {
502  						$('#scroll_icon').addClass('scroll_icon_off');
503					}, 1000);
504				}, 2000);
505			}, 400);
506            
507		}).bind('mouseleave',function(){
508			$('#category_all').stop(true,true).fadeOut(fadespeed);
509            $(this).removeClass('viewallcate');
510		});
511        
512        
513        $cate_all_btn.bind('mousewheel DOMMouseScroll', function(e) {
514			$('#scroll_icon').addClass('scroll_icon_off');
515        });
516        
517        
518        
519        /*
520        $cate_all_btn.bind('click',function(e){
521            e.stopPropagation();
522			if($(this).hasClass('viewallcate')){
523				$(this).removeClass('viewallcate')
524				$this.stop(true,true).fadeOut(fadespeed);
525			}else{
526				$(this).addClass('viewallcate')
527				$this.stop(true,true).fadeIn(fadespeed);
528			}
529		});
530        
531		$close.bind('click',function(e){
532             e.stopPropagation();
533			 $cate_all_btn.removeClass('viewallcate');
534			 $this.stop(true,true).fadeOut(fadespeed);
535		});
536        
537        $('body').bind('click',function(event){  
538            if($cate_all_btn.hasClass('viewallcate')){
539               $cate_all_btn.removeClass('viewallcate');
540               $this.stop(true,true).fadeOut(fadespeed);
541            }
542        });
543        */
544        
545	})();
546    
547    
548    
549    //대분류페이지의 중분류 카테고리
550    (function(){
551        var $this=$('.menuCategory');
552        if($this.length>0){
553            var $mcate2_li=$this.find('.mcate2_li');
554            var $mcate3_li=$this.find('.mcate3_li');
555            var fadespeed=200;
556            $mcate2_li.each(function(){
557                if($(this).find('.mcate3_ul').length>0){
558                    $(this).addClass('more_cate');
559                }
560            });
561            $mcate3_li.each(function(){
562                if($(this).find('.mcate4_ul').length>0){
563                    $(this).addClass('more_cate');
564                }
565            });
566            $mcate2_li.bind('mouseenter',function(){
567                $(this).addClass('viewcate');
568                $(this).find('.mcate3_ul').stop(true,true).fadeIn(fadespeed);
569            }).bind('mouseleave',function(){
570                $(this).removeClass('viewcate');
571                $(this).find('.mcate3_ul').stop(true,true).fadeOut(fadespeed);
572            });
573            $mcate3_li.bind('mouseenter',function(){
574                $(this).addClass('viewcate');
575                $(this).find('.mcate4_ul').stop(true,true).fadeIn(fadespeed);
576            }).bind('mouseleave',function(){
577                $(this).removeClass('viewcate');
578                $(this).find('.mcate4_ul').stop(true,true).fadeOut(fadespeed);
579            });
580        }
581    })();
582    
583  
584};
585
586/**
587 * 카테고리 리스트 상품 정렬
588 */
589var aUrl = location.href.split('?');
590var sQueryString = aUrl[1];
591var orgHeaderHeight = 0;
592var selAdd = 0;
593var maxTime = 5;
594
595/**
596 * 파라미터가 있을경우에만 처리
597 */
598$(function(){
599    if (sQueryString && sQueryString.indexOf('sort_method') > -1) {
600        for (var i=0; i<$('#selArray option').length; i++) {
601            if ($('#selArray option').eq(i).val().indexOf(sQueryString) > -1) {
602                $('#selArray option').eq(i).prop("selected", true);
603
604                orgHeaderHeight = $('#header').outerHeight(true);
605                fixedClassCheck();
606            }
607        }
608    }
609});
610
611$('#selArray').on('change', function() {
612    if ($('#selArray').val()) {
613        location.href=$('#selArray').val();
614    }
615});
616
617function goThumg(url) {
618    location.href = url+'?'+sQueryString;
619}
620
621function fixedClassCheck(){
622    var fixedBol = $('#header').hasClass('fixed');
623    if(!fixedBol){
624        if(selAdd < maxTime){ setTimeout(fixedClassCheck,100); }
625        selAdd++;
626    }else{
627        var fixedHeader = $('#header').find('.navigation').outerHeight(true),
628            scrollValue = $(document).scrollTop(),
629            scrollTop = scrollValue - (orgHeaderHeight+fixedHeader);
630
631        if(scrollTop > 0){ $(document).scrollTop(scrollTop); }
632    }
633}
634
635/**
636 * hasClass
637 */
638function hasClass(element, className){
639    return (' ' + element.className + ' ').indexOf(' ' + className+ ' ') > -1;
640};
641
642/**
643 *  toggle
644 */
645function toggleClassAll(element, handler, className){
646    var _handler = document.querySelector(handler);
647    document.querySelectorAll(handler).forEach(function(item){
648        item.addEventListener('click', function(){
649            var _element = item.parentNode;
650            if ( hasClass( _element, className ) ) {
651                _element.classList.remove( className );
652            } else {
653                _element.classList.add( className );
654            }
655        })
656    })
657};
658
659/**
660 *  findElements
661 */
662function findElements(element, findElement){
663    var resultElements = [];
664    document.querySelectorAll(element).forEach(function(item){
665        var findElementList = item.querySelectorAll(findElement);
666        findElementList = Array.prototype.slice.call(findElementList);
667        resultElements = resultElements.concat(findElementList);
668    })
669    return resultElements;
670};
671
672/**
673 *  setAttributeAl
674 */
675function setAttributeAll(elements, name, value){
676    elements.forEach(function(item){
677        item.setAttribute(name, value);
678    })
679};
680
681/**
682 *  상품 섬네일 로드되지 않을 경우, 기본값 설정
683 */
684function setDefaultImage(element) {
685    document.querySelectorAll(element).forEach(function(item){
686        var $img = new Image();
687        $img.onerror = function () {
688            item.src="//img.echosting.cafe24.com/thumb/img_product_big.gif";
689        }
690        $img.src = item.src;
691    });
692};
693
694/**
695 *  tooltip
696 */
697function setTooltipEvent(){
698    var input = findElements('.eTooltip', 'input');
699    input.forEach(function(item){
700        item.addEventListener('focusin', function(event){
701            var targetName = returnTargetName(event.target);
702            targetName.nextElementSibling.style.display = 'block'
703        });
704        item.addEventListener('focusout', function(event){
705            var targetName = returnTargetName(event.target);
706            targetName.nextElementSibling.style.display = 'none'
707        });
708    });
709}
710
711/**
712 *  tooltip input focus
713 */
714function returnTargetName(_this){
715    var ePlacename = _this.parentElement.getAttribute("class");
716    var targetName;
717    if(ePlacename == "ePlaceholder"){ //ePlaceholder supported
718        targetName = _this.parentElement;
719    }else{
720        targetName = _this;
721    }
722    return targetName;
723}
724
725/**
726 * window load
727 */
728window.addEventListener('load', function(){
729    if (document.querySelector('.thumbnail')){
730        setDefaultImage('.thumbnail img');
731    }
732    if (document.querySelector('.eTooltip')){
733        setAttributeAll(findElements('.eTooltip', '.btnClose'),'tabIndex','-1');
734        setTooltipEvent();
735    }
736    if (document.querySelector('div.eToggle')){
737        toggleClassAll(false, 'div.eToggle .title', 'selected');
738    }
739}); 
740// 1. 호스트 요소 탐색 함수
741function findHost() {
742  const entryDiv = document.querySelector('#ch-plugin-entry');
743  return entryDiv?.querySelector('div[style*="display: block"]');
744}
745
746// 2. 스타일 업데이트 함수 (두 요소 동시 제어)
747function updateStyles() {
748  const host = findHost();
749  let launcherDiv = null;
750  
751  // Shadow DOM 내부 요소 탐색
752  if (host) {
753    const shadow = host.shadowRoot;
754    launcherDiv = shadow?.querySelector('div[data-ch-testid="launcher"]');
755  }
756  
757  // 외부 요소 탐색
758  const scriptElement = document.querySelector('#ch-plugin-script');
759
760  if (window.innerWidth >= 1000) {
761    // Shadow DOM 내부 요소 스타일 변경
762    if (launcherDiv) {
763      launcherDiv.style.bottom = '24px';
764    }
765    // 외부 요소 스타일 변경
766    if (scriptElement) {
767      scriptElement.style.bottom = '100px';
768    }
769  } else {
770    // 필요 시 기본값 복원 (예: '171px' 등)
771    if (launcherDiv) launcherDiv.style.bottom = '';
772    if (scriptElement) scriptElement.style.bottom = '';
773  }
774}
775
776// 3. MutationObserver 설정 (동적 요소 감지)
777function observeShadowDOM(host) {
778  const shadow = host.shadowRoot;
779  if (!shadow) return;
780
781  const observer = new MutationObserver(() => {
782    // 요소가 추가될 때마다 스타일 업데이트
783    updateStyles();
784  });
785
786  observer.observe(shadow, {
787    childList: true,
788    subtree: true
789  });
790}
791
792// 4. 리사이즈 이벤트 핸들러
793window.addEventListener('resize', updateStyles);
794
795// 5. 초기 실행 로직
796document.addEventListener('DOMContentLoaded', () => {
797  const initCheck = setInterval(() => {
798    const host = findHost();
799    if (host) {
800      clearInterval(initCheck);
801      observeShadowDOM(host);
802      updateStyles(); // 최초 1회 실행
803    }
804  }, 100);
805});
806
807
808  
809
810
811
812
813
814
815
816
817
818//window popup script
819function winPop(url) {
820    window.open(url, "popup", "width=300,height=300,left=10,top=10,resizable=no,scrollbars=no");
821}
822/**
823 * document.location.href split
824 * return array Param
825 */
826function getQueryString(sKey)
827{
828    var sQueryString = document.location.search.substring(1);
829    var aParam       = {};
830
831    if (sQueryString) {
832        var aFields = sQueryString.split("&");
833        var aField  = [];
834        for(var i=0; i<aFields.length; i++){
835            aField = aFields[i].split('=');
836            aParam[aField[0]] = aField[1];            
837        }
838    }
839
840    aParam.page = aParam.page ? aParam.page : 1;
841    return sKey ? aParam[sKey] : aParam;
842};
843
844/**
845  *  구매버튼
846*/
847var globalBuyBtnScrollFunc = function() {
848    // 구매버튼 관련변수
849    var sFixId = $('#orderFixItem').length > 0  ? 'orderFixItem' : 'fixedActionButton',
850        $area = $('#orderFixArea'),
851        $item = $('#' + sFixId + '').not($area);
852
853    $(window).scroll(function(){
854        try {
855             // 구매버튼 관련변수
856            var iCurrentHeightPos = $(this).scrollTop() + $(this).height(),
857                iButtonHeightPos = $item.offset().top;
858
859            if (iCurrentHeightPos > iButtonHeightPos || iButtonHeightPos < $(this).scrollTop() + $item.height()) {
860                if (iButtonHeightPos < $(this).scrollTop() - $item.height()) {
861                    $area.fadeIn('fast');
862                } else {
863                    $area.hide();
864                }
865            } else {
866                $area.fadeIn('fast');
867            }
868        } catch(e) { }
869    });
870};
871
872$(function(){
873    // tab
874    $.eTab = function(ul) {
875        $(ul).find('a').on('click', function() {
876            var _li = $(this).parent('li').addClass('selected').siblings().removeClass('selected'),
877                _target = $(this).attr('href'),
878                _siblings = '.' + $(_target).attr('class');
879            $(_target).show().siblings(_siblings).hide();
880            return false
881        });
882    }
883    if ( window.call_eTab ) {
884        call_eTab();
885    };
886    globalBuyBtnScrollFunc();
887});
888
889$(document).ready(function() {
890    var varUA = navigator.userAgent.toLowerCase();
891    if (varUA.indexOf('android') > -1) {
892        $('.bottom-menu-item.recent').css('display', 'none');
893        $('.bottom-menu-item.android').css('display', 'block');
894    } else if (varUA.indexOf("iphone") > -1 || varUA.indexOf("ipad") > -1 || varUA.indexOf("ipod") > -1) {
895        $('.bottom-menu-item.recent').css('display', 'none');
896        $('.bottom-menu-item.apple').css('display', 'block');
897    } else {
898        $('.bottom-menu-item.recent').css('display', 'block');
899    }
900    let sUserAgent = navigator.userAgent.toLowerCase();
901    let oPlusAppTest = new RegExp('Cafe24Plus', 'i');
902    let element = document.getElementById("PlusappSettingsButton");
903
904    if (oPlusAppTest.test(sUserAgent)) {
905        $('.bottom-menu-item.recent').css('display', 'none');
906        $('.bottom-menu-item.apple').css('display', 'none');
907        $('.bottom-menu-item.android').css('display', 'none');
908        $('.bottom-menu-item.cafe24').css('display', 'block');
909        if (varUA.indexOf("iphone") > -1 || varUA.indexOf("ipad") > -1 || varUA.indexOf("ipod") > -1) {
910            $('.bottom-menu-item').css('padding-bottom', '20px');
911            $('.bottom-menu, .mo-btn-cart, .mo-btn-buy, .mo-fixed-btn-box').css('height', '85px');
912            $('#mainIndexPopUp .close-btn-list').css('padding-bottom', '20px');
913            $('#mainIndexPopUp .swiper-pagination').css('margin-bottom', '20px');
914            $('#mobile_buyOptionTab.step2 .buy-step-02 .buy-option-box-all').css('margin-bottom', '20px');
915            $('.xans-order-basketpackage .ec-base-button.gFixed').css('bottom', '85px');
916        }
917    }
918});
919
920$('.search-wrap.res-mo .search-menu').click(function() {
921	$('.schArea').stop().fadeToggle(100);
922});
923$('.sch_close').click(function() {
924	$('.schArea').stop().fadeToggle(100);
925});
926$('.sch_bg').click(function() {
927	$('.schArea').stop().fadeToggle(100);
928});
929
930$(document).ready( function() { $("input#keyword").attr("placeholder", "검색어를 입력하세요"); });
931
932(function() {
933  const desiredDomain = "miguhara.com";
934  const currentDomain = window.location.hostname;
935
936  if (!currentDomain.endsWith(desiredDomain)) {
937    const newUrl = `${window.location.protocol}//${desiredDomain}${window.location.pathname}${window.location.search}${window.location.hash}`;
938    window.location.replace(newUrl);
939  }
940})();
941
942(function($){
943    $.fn.extend({
944        center: function() {
945            this.each(function() {
946                var
947                    $this = $(this),
948                    $w = $(window);
949                $this.css({
950                    position: "absolute",
951                    top: ~~(($w.height() - $this.outerHeight()) / 2) + $w.scrollTop() + "px",
952                    left: ~~(($w.width() - $this.outerWidth()) / 2) + $w.scrollLeft() + "px"
953                });
954            });
955            return this;
956        }
957    });
958    $(function() {
959        var $container = function(){/*
960    <div id="modalContainer">
961        <iframe id="modalContent" scroll="0" scrolling="no" frameBorder="0"></iframe>
962    </div>');
963    */}.toString().slice(14,-3);
964        $('body')
965        .append($('<div id="modalBackpanel"></div>'))
966        .append($($container));
967        function closeModal () {
968            $('#modalContainer').hide();
969            $('#modalBackpanel').hide();
970        }
971        $('#modalBackpanel').on('click', closeModal);
972        zoom = function ($piProductNo, $piCategoryNo, $piDisplayGroup) {
973            var $url = '/product/image_zoom.html?product_no=' + $piProductNo + '&cate_no=' + $piCategoryNo + '&display_group=' + $piDisplayGroup;
974            $('#modalContent').attr('src', $url);
975            $('#modalContent').on("load",function(){
976                $(".header .close",this.contentWindow.document.body).on("click", closeModal);
977            });
978            $('#modalBackpanel').css({width:$("body").width(),height:$("body").height(),opacity:.4}).show();
979            $('#modalContainer').center().show();
980        }
981    });
982})(jQuery);
983EC$(function($) {
984  // 디바이스 체크
985  const isMobile = !/win16|win32|win64|mac|macintel/i.test(navigator.platform);
986  const device = isMobile ? 'mobile' : 'pc';
987
988  // 상세 페이지 소비자가 할인 표시
989  const oPriceInfoEl = $('#ec-product-price-info');
990  if (oPriceInfoEl.length) {
991    const salePriceEl = $('#span_product_price_text');
992    percentageCalc(oPriceInfoEl, salePriceEl);
993  }
994
995  // 상품 목록 소비자가 할인 표시
996  const productListEl = $('.xans-product-listmain, .xans-product-listrecommend, .xans-product-listnew, .xans-product-listnormal, .xans-search-result, .xans-product-listitem');
997  productListEl.each(function () {
998    const productItems = $(this).find('.prdList > li');
999    productItems.each(function () {
1000      const description = $(this).find('.description');
1001      const normalPriceEl = description.find('.xans-product > li, .xans-search > li').eq(0).find('span:eq(1)');
1002      const salePriceEl = description.find('.xans-product > li, .xans-search > li').eq(1).find('span:eq(1)');
1003      const discountWrapper = description.find('.xans-product > li, .xans-search > li').eq(2);
1004      const discountText = discountWrapper.find('strong').text();
1005      const discountPriceEl = discountWrapper.find('span:eq(1)');
1006      const discountTextRaw = discountPriceEl.text();
1007
1008      const altDiscountWrapper = description.find('.xans-product > li, .xans-search > li').eq(3);
1009      const altDiscountText = altDiscountWrapper.find('strong').text();
1010      const altDiscountPriceEl = altDiscountWrapper.find('span:eq(1)');
1011
1012      // 사용기한 텍스트 처리
1013      if (!discountText.includes('사용기한') && discountPriceEl.length) {
1014        salePriceEl.remove();
1015      } else {
1016        const formatted = discountTextRaw.substring(11).replaceAll('-', '.');
1017        discountPriceEl.text(`${formatted}까지`);
1018      }
1019
1020      if (altDiscountText.includes('사용기한')) {
1021        const formatted = altDiscountPriceEl.text().substring(11).replaceAll('-', '.');
1022        altDiscountPriceEl.text(`${formatted}까지`);
1023      }
1024
1025      percentageCalc(description, salePriceEl, discountPriceEl, discountTextRaw);
1026    });
1027  });
1028
1029  // 할인율/금액 계산 및 표시
1030  function percentageCalc(target, salePriceEl, discountPriceEl = null, discountTextRaw = '') {
1031    const customPrice = parseInt(target.attr('ec-data-custom')?.replace(',', '') || 0, 10);
1032    const price = parseInt(target.attr('ec-data-price')?.replace(',', '') || 0, 10);
1033    const saleDisplayType = 'p'; // 'p': 퍼센트, 'w': 원
1034    const regex = /\B(?=(\d{3})+(?!\d))/g;
1035
1036    // 할인 가격이 있는 경우
1037    if (discountPriceEl && discountTextRaw.includes('원')) {
1038      const discountValue = parseInt(discountTextRaw.split('원')[0].replace(',', ''), 10);
1039      if (customPrice > 0 && discountValue > 0 && discountValue !== customPrice) {
1040        const text = saleDisplayType === 'p'
1041          ? Math.round(((customPrice - discountValue) / customPrice) * 100) + '<span class="percent">%</span>'
1042          : (customPrice - discountValue).toString().replace(regex, ',') + '원 OFF';
1043        discountPriceEl.prepend(`<span class="sale_per">${text}</span>`);
1044      }
1045    }
1046
1047    // 일반 가격 할인 계산
1048    if (customPrice > 0 && price > 0 && price !== customPrice) {
1049      const text = saleDisplayType === 'p'
1050        ? Math.round(((customPrice - price) / customPrice) * 100) + '<span class="percent">%</span>'
1051        : (customPrice - price).toString().replace(regex, ',') + '원 OFF';
1052      salePriceEl.prepend(`<span class="sale_per">${text}</span>`);
1053    } else if (customPrice === price && (!discountPriceEl || !discountPriceEl.length)) {
1054      target.find('span:eq(1)').remove(); // 정상가만 표시되어 있다면 제거
1055    }
1056  }
1057});
1058
1059document.addEventListener("DOMContentLoaded", async () => {
1060  const BANNER_SCRIPT_URL = '/web/upload/appfiles/AIFBrluHGdhkEsW6ewuLoA/54a86062881164da392137b30910603f.js?v=' + Date.now();
1061
1062  try {
1063    const res = await fetch(BANNER_SCRIPT_URL);
1064    const scriptText = await res.text();
1065    const match = scriptText.match(/(?:const|var)\s+webpb_banner_data\s*=\s*(\{[\s\S]*?\});/);
1066    if (!match) return;
1067
1068    const webpbData = new Function("return " + match[1])();
1069    const groups = webpbData?.groups || {};
1070    const productTimers = new Map();
1071
1072    for (const groupKey in groups) {
1073      const group = groups[groupKey];
1074      if (group.name !== "상단 메뉴") continue;
1075
1076      const banners = Object.values(group.banners || {}).sort((a, b) => a.index - b.index);
1077
1078      for (const banner of banners) {
1079        const { texts, link, period_begin, period_end, is_period, index } = banner;
1080        const isTimeSale = texts?.[0] === "타임세일";
1081        if (!link || !(is_period === "T" || isTimeSale) || !link.includes("/product/list.html?cate_no=")) continue;
1082
1083        const now = new Date();
1084        let deadline;
1085
1086        if (isTimeSale) {
1087          deadline = getTonightMidnight();
1088        } else {
1089          if (!period_begin?.date || !period_end?.date) continue;
1090
1091          const beginTime = new Date(`${period_begin.date}T${period_begin.hour.padStart(2, '0')}:${period_begin.min.padStart(2, '0')}:00`);
1092          const endTime = new Date(`${period_end.date}T${period_end.hour.padStart(2, '0')}:${period_end.min.padStart(2, '0')}:00`);
1093          if (beginTime > now || endTime <= now) continue;
1094
1095          deadline = endTime;
1096        }
1097
1098        const productNames = await fetchProductNames(link);
1099        for (const name of productNames) {
1100          const existing = productTimers.get(name);
1101          if (!existing || index > existing.index) {
1102            productTimers.set(name, { index, deadline });
1103          }
1104        }
1105      }
1106    }
1107
1108    document.querySelectorAll(".prdList__item").forEach(item => {
1109      const nameEl = item.querySelector(".name");
1110      const thumbnail = item.querySelector(".thumbnail");
1111      if (!nameEl || !thumbnail) return;
1112
1113      const name = nameEl.textContent.trim();
1114      if (productTimers.has(name)) {
1115        const { deadline } = productTimers.get(name);
1116
1117        thumbnail.querySelector(".sale-discount-wrap")?.remove();
1118
1119        const wrap = document.createElement("div");
1120        wrap.className = "sale-discount-wrap";
1121
1122        const countdown = document.createElement("div");
1123        countdown.className = "sale-discount on";
1124        wrap.appendChild(countdown);
1125
1126        thumbnail.appendChild(wrap);
1127        startCountdown(countdown, deadline);
1128      }
1129    });
1130
1131  } catch (err) {
1132    console.warn("프로모션 타이머 오류:", err);
1133  }
1134
1135  function getTonightMidnight() {
1136    const d = new Date();
1137    d.setHours(24, 0, 0, 0);
1138    return d;
1139  }
1140
1141  async function fetchProductNames(url) {
1142    try {
1143      const res = await fetch(url);
1144      const html = await res.text();
1145      const doc = new DOMParser().parseFromString(html, "text/html");
1146      return Array.from(doc.querySelectorAll(".prdList__item .name")).map(el => el.textContent.trim());
1147    } catch {
1148      return [];
1149    }
1150  }
1151
1152  function startCountdown(el, deadline) {
1153    function update() {
1154      const now = new Date();
1155      const diff = deadline - now;
1156      if (diff <= 0) return;
1157
1158      const d = Math.floor(diff / (1000 * 60 * 60 * 24));
1159      const h = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
1160      const m = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60));
1161      const s = Math.floor((diff % (1000 * 60)) / 1000);
1162
1163      el.textContent = `남은 시간 : ${d}일 ${h}시간 ${m}분 ${s}초`;
1164    }
1165
1166    update();
1167    setInterval(update, 1000);
1168  }
1169});
1170

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.