PageSourceSearch

https://www.ssupl.com/data/skin/front/19-07_C/js/gd_common.js?ts=1607411411

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

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.