PageSourceSearch

https://partsworld.co.kr/data/skin/front/designbook_topten_ba/js/gd_common.js?ts=1609392026

js partsworld.co.kr collected 2026-10-06 03:32:36 UTC 23,501 bytes, 735 lines download raw bytes

1/**
2 * This is commercial software, only users who have purchased a valid license
3 * and accept to the terms of the License Agreement can install and use this
4 * program.
5 *
6 * Do not edit or add to this file if you wish to upgrade Godomall5 to newer
7 * versions in the future.
8 *
9 * 공용 스크립트 및 프로토타입 정의
10 *
11 * @copyright ⓒ 2016, NHN godo: Corp.
12 * @link http://www.godo.co.kr
13 */
14
15
16/**
17 * 자바스크립트 Trim함수
18 *
19 * @deprecated 자바스크립트 기본 함수 혹은 $.trim() 사용
20 * @return string 좌우 공백 제거한 문자열
21 */
22//String.prototype.trim = function () {
23//    return this.replace(/^\s+|\s+$/, '');
24//};
25
26/**
27 * 자바스크립트 number_format 함수
28 *
29 * @deprecated numeral로 대체
30 * @return string 문자열을 세자리 단위로 쉼표 찍기
31 */
32//String.prototype.number_format = function()
33//{
34//    return this.replace(/(\d)(?=(?:\d{3})+(?!\d))/g, '$1,');
35//};
36
37// 멀티상점 변수 기본처리
38if (typeof gdCurrencyDecimalFormat === 'undefined') {
39    gdCurrencyDecimal = 0;
40    gdCurrencyDecimalFormat = 0;
41}
42
43// IE9에서 console 객체가 없어 console 객체가 없는 경우 log로 사용하도록 처리
44if (!window.console) console = {
45    log: function () {
46    }
47};
48
49// IE8 이하에서 Array.indexOf 지원하지 않는 경우에 대한 대응
50if (typeof Array.prototype.indexOf !== 'function') {
51    Array.prototype.indexOf = function (ele) {
52        return $.inArray(ele, this);
53    };
54}
55
56// IE8 이하에서 String.trim 지원하지 않는 경우에 대한 대응
57if (typeof String.prototype.trim !== 'function') {
58    String.prototype.trim = function(){
59        return $.trim(this);
60    };
61}
62
63// @qnibus bugfix. toFixed 사용시 무조건 반올림 처리하는 부분으로 인해 고도몰5의 정책과 맞지 않아서 toFixed 대신 사용해야 함
64if (typeof Number.prototype.toRealFixed !== 'function') {
65    Number.prototype.toRealFixed = function (digits, format) {
66        if (typeof digits === 'undefined') {
67            digits = gdCurrencyDecimal;
68        }
69        if (typeof format === 'undefined') {
70            format = gdCurrencyDecimalFormat;
71        }
72
73        return numeral(Math.floor(this.valueOf() * Math.pow(10, digits)) / Math.pow(10, digits)).format('0,' + format);
74    };
75}
76
77/**
78 * 스트링 치환 메소드
79 * @returns {String}
80 */
81String.prototype.format = function () {
82    var formatted = this;
83    for (var i = 0; i < arguments.length; i++) {
84        formatted = formatted.replace("{" + i + "}", arguments[i]);
85    }
86    return formatted;
87};
88
89/**
90 * DOM 로드
91 */
92$(document).ready(function () {
93
94    // IE 9 이하 placeholder 처리
95    if (gd_is_ie() < 10) {
96        $("input, textarea").placeholder();
97
98        $('form').submit(function(e){
99            $(this).find("input, textarea").each(function(){
100                var _name = this.name;
101                var _placeholder = this.getAttribute('placeholder');
102
103                if (_name && _placeholder) {
104                    var _target = document.getElementsByName(_name)[0];
105                    if (_target.value == _placeholder) {
106                        _target.value = '';
107                    }
108                }
109            });
110        });
111    }
112
113	// jQuery Validator 기본값 설정
114    $.validator.setDefaults({
115        onfocusout: false,
116        onclick: false,
117        onkeyup: false,
118        errorPlacement: function (error, element) {
119            // do nothing
120        },
121        invalidHandler: function (form, validator) {
122            var errors = validator.numberOfInvalids();
123            if (errors) {
124                alert(validator.errorList[0].message);
125                validator.errorList[0].element.focus();
126            }
127        },
128        submitHandler: function (form) {
129            form.submit();
130        }
131    });
132
133    // jQuery Validator 기본 메시지 설정
134    jQuery.extend(jQuery.validator.messages, {
135        required: __("필수항목 입니다."),
136        remote: __("이 필드를 수정해주세요."),
137        email: __("이메일을 정확하게 입력해주세요."),
138        url: __("유효하지 않은 URL이 입력되었습니다."),
139        date: __("날짜형식이 맞지 않습니다."),
140        dateISO: __("유효한 ISO 타입의 날짜로 다시 입력해주세요."),
141        number: __("숫자만 입력하실 수 있습니다."),
142        digits: __("숫자만 입력하실 수 있습니다."),
143        creditcard: __("유효한 신용카드 번호로 다시 입력해주세요."),
144        equalTo: __("동일한 값을 입력해주세요."),
145        accept: "Please enter a value with a valid extension.",
146        maxlength: jQuery.validator.format(__("최대 %i 이하 입력해 주세요.", "{0}")),
147        minlength: jQuery.validator.format(__("최소 %i 이상 입력해 주세요.", "{0}")),
148        rangelength: jQuery.validator.format(__("%1$i자에서 %2$iê¹
148Œì§€ 입력가능합니다.", ["{0}", "{1}"])),
149        range: jQuery.validator.format(__("%1$i와 %2$i사이의 숫자를 입력해주세요.", ["{0}", "{1}"])),
150        max: jQuery.validator.format(__("최대 %i 이상 입력하실 수 없습니다.", "{0}")),
151        min: jQuery.validator.format(__("최소 %i 이하 입력하실 수 없습니다.", "{0}"))
152    });
153
154    //검색어
155    $("#frmSearchTop").validate({
156        submitHandler: function (form) {
157            if ($("#frmSearchTop input[name='adUrl']").val() && $("#frmSearchTop input[name='keyword']").val() == '') document.location.href = $("#frmSearchTop input[name='adUrl']").val();
158            else form.submit();
159        },
160        rules: {
161            keyword: {
162                required: function () {
163
164                    if ($("#frmSearchTop input[name='adUrl']").val()) {
165                        return false;o
166                    }
167                    else {
168                        return true;
169                    }
170                }
171            }
172        },
173        messages: {
174            keyword: {
175                required: __('검색어를 입력하세요.')
176            }
177        }
178    });
179
180    // 최근 검색어 삭제
181    $('.btn_top_search_del').click(function(e){
182        e.stopPropagation();
183        $self = $(this);
184        $.post('../goods/goods_ps.php', {
185            'mode': 'delete_recent_keyword',
186            'keyword': $(this).data('recent-keyword')
187        }, function (data, status) {
188            // 값이 없는 경우 성공
189            if (status == 'success' && data == '') {
190                if ($self.closest('ul').find('li').length == 1) {
191                    $self.closest('li').remove();
192                    $('.btn_top_search_all_del').remove();
193                    $('.js_recent_area').append('<dd>' + __('최근 검색어가 없습니다.') + '</dd>');
194                } else {
195                    $self.closest('li').remove();
196                }
197            } else {
198                console.log('request fail. ajax status (' + status + ')');
199            }
200        });
201    });
202
203    // 최근 검색어 전체 삭제
204    $('.btn_top_search_all_del').click(function(e){
205        $.post('../goods/goods_ps.php', {
206            'mode': 'delete_recent_all_keyword'
207        }, function (data, status) {
208            // 값이 없는 경우 성공
209            if (status == 'success' && data == '') {
210                $('.js_recent_list').find('li').remove()
211                $('.btn_top_search_all_del').remove();
212                $('.js_recent_area').append('<dd>' + __('최근 검색어가 없습니다.') + '</dd>');
213            } else {
214                console.log('request fail. ajax status (' + status + ')');
215            }
216        });
217    });
218
219    // Ajax 에러 및 처리 기본값 설정
220    $.ajaxSetup({
221        beforeSend: function (xhr, settings) {
222            xhr.url = settings.url;
223            xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'));
224        },
225        complete: function () {
226            gd_trigger_checkbox_ui();
227            gd_select_remodeling();
228            gd_checkbox_all();
229
230            //이미지 로딩 향상 사용 시 호출.
231            if ($.isFunction($.fn.lazyload) === true) {
232                setTimeout(function() {
233                    $("img.gd_image_lazy").lazyload({threshold:200});
234                }, 1);
235            }
236        },
237        error: function (xhr, textStatus, error) {
238            if (xhr.status == '404' && error == 'Not Found') {
239                console.log('[404 Not Found]\nThe requested URL was not found.');
240            }
241            else if (xhr.status == '500' && error == 'Internal Server Error' && xhr.responseText != '') {
242                console.log(xhr.responseText);
243            }
244            gd_close_layer();
245            console.log('Ajax Error URL: ' + xhr.url, xhr.responseText);
246        }
247    });
248
249    $(document).on('click', '.btn_alert_login', function (e) {
250        var target = $(this).attr('id');
251        e.preventDefault();
252        alert(__('로그인하셔야 본 서비스를 이용하실 수 있습니다.'));
253        document.location.href = target == undefined ?  "../member/login.php" : "../member/login.php?id=" + target;
254        return false;
255    });
256
257    // 미확인 입금자 팝업
258    $('#ghostDepositorBanner').click(function () {
259        var url = '/service/popup_ghost_depositor.php';
260        var win = gd_popup({
261            url: url
262            , target: 'ghostDepositorPopup'
263            , width: 630
264            , height: 560
265            , resizable: 'no'
266            , scrollbars: 'no'
267        });
268        win.focus();
269        return win;
270    });
271
272    if ($('.btn_prev').length > 0) {
273        $('.btn_prev').click(function (e) {
274            e.preventDefault();
275            history.go(-1);
276        });
277    }
278
279    // 복사 기능
280    // https://github.com/zeroclipboard/zeroclipboard/blob/master/docs/api/ZeroClipboard.md
281    if ($('.gd_clipboard').length) {
282        if (navigator.userAgent.match(/MSIE 8/) !== null) {
283            $('.gd_clipboard').each(function () {
284                $(this).click(function () {
285                    alert(__("주소를 드래그 해서 복사해주세요"));
286                    return false;
287                });
288            });
289        } else {
290            var clipboard = new Clipboard('.gd_clipboard');
291            clipboard.on('success', function (e) {
292                var title = $(e.trigger).attr('title') == undefined ? '' : $(e.trigger).attr('title');
293                alert('[' + title + '] '+__('정보를 클립보드에 복사했습니다.\nCtrl+V를 이용해서 사용하세요.'));
294                e.clearSelection();
295            });
296            clipboard.on('error', function (e) {
297                console.error('Action:', e.action);
298                console.error('Trigger:', e.trigger);
299            });
300        }
301    }
302});
303
304// @qnibus bugfix. toFixed 사용시 무조건 반올림 처리하는 부분으로 인해 고도몰5의 정책과 맞지 않아서 toFixed 대신 사용해야 함
305if (typeof Number.prototype.toRealFixed !== 'function') {
306    Number.prototype.toRealFixed = function (digits, format) {
307        if (typeof digits === 'undefined') {
308            digits = gdCurrencyDecimal;
309        }
310        if (typeof format === 'undefined') {
311            format = gdCurrencyDecimalFormat;
312        }
313
314        return numeral(Math.floor(this.valueOf() * Math.pow(10, digits)) / Math.pow(10, digits)).format('0,' + format);
315    };
316}
317
318/**
319 * 기준화폐 환율변환
320 *
321 * @param price 금액
322 * @param isFormat 포맷여부
323 * @returns {*}
324 */
325function gd_money_format(price, isFormat) {
326    var convertPrice = fx.convert(price).toRealFixed();
327    if (typeof isFormat !== 'undefined') {
328        if (isFormat) {
329            return numeral().unformat(convertPrice);
330        }
331    }
332
333    return convertPrice;
334}
335
336/**
337 * 추가화폐 환율변환
338 *
339 * @param price 금액
340 * @param isFormat 포맷여부
341 * @returns {*}
342 */
343function gd_add_money_format(price, isFormat) {
344    var convertPrice = fx.convert(price, {to: gdCurrencyAddCode}).toRealFixed(gdCurrencyAddDecimal, gdCurrencyAddDecimalFormat);
345    if (typeof isFormat !== 'undefined') {
346        if (isFormat) {
347            return numeral().unformat(convertPrice);
348        }
349    }
350
351    return convertPrice;
352}
353
354/**
355 * 윈도우팝업 호출
356 * @param array options 창정보
357 * @return object Window 개체
358 */
359function gd_popup(options) {
360    if (!options.width) options.width = 500;
361    if (!options.height) options.height = 415;
362    var status = new Array();
363    $.each(options, function (i, v) {
364        if ($.inArray(i, ['url', 'target']) == '-1') {
365            status.push(i + '=' + v);
366        }
367    });
368    var status = status.join(',');
369    var win = window.open(options.url, options.target, status);
370    return win;
371}
372
373/**
374 * 통신판매사업자 상세조회창
375 * @param string businessNo 사업자 번호
376 * @return
377 */
378function gd_popup_bizInfo(businessNo) {
379    var url = 'http://www.ftc.go.kr/info/bizinfo/communicationViewPopup.jsp?wrkr_no=' + businessNo;
380    var win = gd_popup({
381        url: url
382        , target: 'communicationViewPopup'
383        , width: 750
384        , height: 700
385        , resizable: 'no'
386        , scrollbars: 'yes'
387    });
388    win.focus();
389    return win;
390}
391/**
392 * 쿠키 생성
393 */
394function createCookie(name, value, days) {
395    var expires;
396    if (days) {
397        var date = new Date();
398        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
399        expires = "; expires=" + date.toGMTString();
400    } else {
401        expires = "";
402    }
403    document.cookie = name + "=" + value  + "; path=/; expires=" + expires + ";";
404}
405/**
406 * 팝업창 Cookie 컨트롤
407 * @param string name 팝업창 이름 (코드_창종류)
408 * @param object elemnt elemnt
409 * @return
410 */
411function gd_popup_cookie(name, elemnt) {
412    if (elemnt.checked === true) {
413        createCookie(name,'true',1);
414        var popupKind = name.split('_');
415        if (popupKind[1] == 'window') {
416            setTimeout('self.close()');
417        } else {
418            setTimeout("$('#" + name + "').hide()");
419        }
420    } else {
421       createCookie(name, null);
422    }
423    return;
424}
425
426/**
427 * 메일 도메인 선택
428 */
429function gd_select_email_domain(name,select) {
430    if (typeof select === 'undefined') {
431        select = 'emailDomain';
432    }
433    var $email = $(':text[name=' + name + ']');
434    var $emailDomain = $('select[id='+select+']');
435    $emailDomain.on('change', function (e) {
436        var emailValue = $email.val();
437        var indexOf = emailValue.indexOf('@');
438        if (indexOf == -1) {
439            if ($emailDomain.val() === 'self') {
440                $email.val(emailValue + '@');
441            } else {
442                $email.val(emailValue + '@' + $emailDomain.val());
443            }
444            $email.trigger('focusout');
445        } else {
446            if ($emailDomain.val() === 'self') {
447                $email.val(emailValue.substring(0, indexOf + 1));
448                $email.focus();
449            } else {
450                $email.val(emailValue.substring(0, indexOf + 1) + $emailDomain.val());
451                $email.trigger('focusout');
452            }
453        }
454    });
455}
456
457/**
458 * 도로명 주소 찾기 (팝업)
459 *
460 * @author artherot
461 * @param string zoneCodeID zonecode input ID
462 * @param string addrID address input ID
463 * @param string zipCodeID zipcode input ID
464 */
465function gd_postcode_search(zoneCodeID, addrID, zipCodeID) {
466    var win = gd_popup({
467        url: '../share/postcode_search.php?zoneCodeID=' + zoneCodeID + '&addrID=' + addrID + '&zipCodeID=' + zipCodeID,
468        target: 'postcode',
469        width: 540,
470        height: 700,
471        resizable: 'yes',
472        scrollbars: 'yes'
473    });
474    win.focus();
475    return win;
476}
477
478/**
479 * 비회원 개인정보 수집항목 동의 링크
480 */
481function gd_redirect_collection_agree() {
482    window.open('/service/private.php');
483}
484
485/**
486 * 파일 업로드 객체
487 */
488var gdAjaxUpload = {
489    upload : function(data) {
490        var formData = new FormData();
491        for (var k in data.params){
492            if (data.params.hasOwnProperty(k)) {
493                formData.append(k, data.params[k]);
494            }
495        }
496        if(data.onbeforeunload){
497            window.onbeforeunload = data.onbeforeunload;
498            data.formObj.on("submit", function () {
499                window.onbeforeunload = null;
500            });
501        }
502
503        if(data.formObj.find('[name=uploadType][value=ajax]').length < 1) {
504            data.formObj.append('<input type="hidden"  name="uploadType" value="ajax" >');
505        }
506        var index = data.thisObj.closest('form').find('input:file').index(data.thisObj);
507        formData.append('uploadFile', data.thisObj[0].files[0]);
508
509        $.ajax({
510            url: data.actionUrl,
511            type: 'POST',
512            data: formData,
513            async: false,
514            cache: false,
515            contentType: false,
516            processData: false,
517            dataType: 'json',
518            success: function (returnData) {
519                returnData['index'] = index;
520                if(returnData.result == 'ok') {
521                    if ($('input[name="uploadFileNm[' + index + ']"]').length == 0) {
522                        data.formObj.append("<input type='hidden' name='uploadFileNm[" + index + "]' value='" + returnData.uploadFileNm + "'>");
523                        data.formObj.append("<input type='hidden' name='saveFileNm[" + index + "]' value='" + returnData.saveFileNm + "'>");
524                    }
525                    else {
526                        $("input[name='uploadFileNm[" + index + "]']").val(returnData.uploadFileNm);
527                        $("input[name='saveFileNm[" + index + "]']").val(returnData.saveFileNm);
528                    }
529                    if(typeof data.successAfter == 'function') {
530                        data.successAfter(returnData);
531                    }
532                }
533                else if(returnData.result == 'cancel'){
534                    if ($("input[name='uploadFileNm[" + index + "]']").length > 0) {
535                        $("input[name='uploadFileNm[" + index + "]']").remove();
536                        $("input[name='saveFileNm[" + index + "]']").remove();
537                    }
538                }
539                else {
540                    gdAjaxUpload.isSuccess = false;
541                    $('label[for=attach' + (index + 1) + '] .text').val('');  //파일시스템 텍스트 빈값 처리
542                    alert(returnData.errorMsg);
543                    if(typeof data.failAfter == 'function') {
544                        data.failAfter(returnData);
545                    }
546                }
547            }
548        });
549    }
550};
551
552/**
553 * 프레임 리사이즈
554 */
555function gd_resize_frame(obj) {
556    var iframeHeight = (obj).contentWindow.document.body.clientHeight;
557    (obj).height = iframeHeight + 80;
558}
559
560/**
561 * 회원다운로드 쿠폰 링크 다운 받기
562 *
563 * @param couponNo
564 */
565function couponLinkDown(couponNo) {
566    var params = {
567        mode: "couponDownLink",
568        couponCode: couponNo
569    };
570    $.ajax({
571        method: "POST",
572        cache: false,
573        url: "/mypage/coupon_link_down.php",
574        data: params,
575        success: function (data) {
576            result = JSON.parse(data);
577            alert(result['msg']);
578        },
579        error: function (data) {
580            alert(result['msg']);
581        }
582    });
583}
584
585/**
586 * PG 관련 영수증 보기
587 *
588 * @author artherot
589 * @param string modeStr 카드, 현금영수증 종류 (card, cash)
590 * @param string orderNo 주문 번호
591 */
592function gd_pg_receipt_view(modeStr, orderNo) {
593    // 사이즈를 미리 설정 - 자동으로 창이 커지지 않아 미리 설정함
594    var preWidth = 430;
595    var preHeight = 700;
596
597    // 미리 팝업창을 띄우기
598    var prePopupData = {
599        'url': 'about:blank',
600        'target': 'show_receipt',
601        'width': preWidth,
602        'height': preHeight
603    };
604    var show_receipt = gd_popup(prePopupData);
605
606    // 각 PG별 영수증 팝업창
607    $.post('../share/show_receipt.php', {
608        mode: modeStr,
609        orderNo: orderNo
610    }, function (data) {
611        var infoData = data;
612        if (typeof infoData['error'] == 'undefined') {
613            gd_popup(infoData);
614        }
615        else {
616            alert(infoData['error']);
617            show_receipt.close();
618        }
619    }, 'json');
620}
621
622/*** IE 버전 체크 ***/
623function gd_is_ie () {
624    var nav = navigator.userAgent.toLowerCase();
625    if (nav.indexOf('msie') != -1) {
626        return parseInt(nav.split('msie')[1]);
627    } else {
628        return false;
629    }
630}
631
632/**
633 * 쿼리스트링값 찾기
634 * @param query
635 * @param variable
636 * @returns {string}
637 */
638function gd_get_query_variable(query, variable) {
639    var vars = query.split('&');
640    for (var i = 0; i < vars.length; i++) {
641        var pair = vars[i].split('=');
642        if (decodeURIComponent(pair[0]) == variable) {
643            return decodeURIComponent(pair[1]);
644        }
645    }
646    console.log('Query variable %s not found', variable);
647}
648
649/**
650 * 동적 스크립트 바인딩 (스크립트 로딩 후 메서드 실행되도록 처리)
651 *
652 * @author Jong-tae Ahn
653 * @param number
654 * @param places
655 * @param symbol
656 * @param thousand
657 * @param decimal
658 * @returns {string}
659 */
660function add_script(url, callback) {
661    var done = false; // 스크립트 로딩 여부
662    var head = document.getElementsByTagName("head")[0] || document.documentElement;
663    var script = document.createElement("script");
664
665    //script.charset = 'UTF-8';
666    script.src = url;
667    script.onload = script.onreadystatechange = function () {
668        if (!done && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete")) {
669            done = true;
670            callback();
671
672            // IE에서 메모리 누수 방지를 위한 처리
673            script.onload = script.onreadystatechange = null;
674            if (head && script.parentNode) {
675                head.removeChild(script);
676            }
677        }
678    };
679
680    // Use insertBefore instead of appendChild  to circumvent an IE6 bug.
681    // This arises when a base node is used (#2709 and #4378).
682    head.insertBefore(script, head.firstChild);
683}
684
685
686
687
688/*** 스토리지 지원 여부 ***/
689function supports_html5_storage() {
690    try {
691        return 'localStorage' in window && window['localStorage'] !== null;
692    } catch (e) {
693        return false;
694    }
695}
696
697/*** 세션 스토리지 저장 ***/
698function saveSession(control_key, control_value) {
699    if (!supports_html5_storage()) {
700        createCookie(control_key, control_value, 7);
701    } else {
702        sessionStorage[control_key] = control_value;
703    }
704};
705
706/*** 세션 스토리지 로드 ***/
707function loadSession(control_key) {
708    var control_value;
709    if (!supports_html5_storage()) {
710        control_value = readCookie(control_key);
711    } else {
712        control_value = sessionStorage[control_key];
713    }
714    return control_value;
715};
716
717/*** 로컬 스토리지 저장 ***/
718function saveVal(control_key, control_value) {
719    if (!supports_html5_storage()) {
720        createCookie(control_key, control_value, 7);
721    } else {
722        localStorage.setItem(control_key, control_value);
723    }
724};
725
726/*** 로컬 스토리지 로드 ***/
727function loadVal(control_key) {
728    var control_value;
729    if (!supports_html5_storage()) {
730        control_value = readCookie(control_key);
731    } else {
732        control_value = localStorage.getItem(control_key);
733    }
734    return control_value;
735};

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.