PageSourceSearch

https://organiclife.co.kr/data/skin/front/moment/js/gd_common.js?ts=1769499408

js organiclife.co.kr collected 2026-10-06 13:17:19 UTC 23,656 bytes, 740 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        _value = this.valueOf();
74        if(/[9]{9}/g.test(_value)) _value = _value.toFixed(9);
75        return numeral(Math.floor( _value * Math.pow(10, digits)) / Math.pow(10, digits)).format('0,' + format);
76    };
77}
78
79/**
80 * 스트링 치환 메소드
81 * @returns {String}
82 */
83String.prototype.format = function () {
84    var formatted = this;
85    for (var i = 0; i < arguments.length; i++) {
86        formatted = formatted.replace("{" + i + "}", arguments[i]);
87    }
88    return formatted;
89};
90
91/**
92 * DOM 로드
93 */
94$(document).ready(function () {
95
96    // IE 9 이하 placeholder 처리
97    if (gd_is_ie() < 10) {
98        $("input, textarea").placeholder();
99
100        $('form').submit(function(e){
101            $(this).find("input, textarea").each(function(){
102                var _name = this.name;
103                var _placeholder = this.getAttribute('placeholder');
104
105                if (_name && _placeholder) {
106                    var _target = document.getElementsByName(_name)[0];
107                    if (_target.value == _placeholder) {
108                        _target.value = '';
109                    }
110                }
111            });
112        });
113    }
114
115	// jQuery Validator 기본값 설정
116    $.validator.setDefaults({
117        onfocusout: false,
118        onclick: false,
119        onkeyup: false,
120        errorPlacement: function (error, element) {
121            // do nothing
122        },
123        invalidHandler: function (form, validator) {
124            var errors = validator.numberOfInvalids();
125            if (errors) {
126                alert(validator.errorList[0].message);
127                validator.errorList[0].element.focus();
128            }
129        },
130        submitHandler: function (form) {
131            form.submit();
132        }
133    });
134
135    // jQuery Validator 기본 메시지 설정
136    jQuery.extend(jQuery.validator.messages, {
137        required: __("필수항목 입니다."),
138        remote: __("이 필드를 수정해주세요."),
139        email: __("이메일을 정확하게 입력해주세요."),
140        url: __("유효하지 않은 URL이 입력되었습니다."),
141        date: __("날짜형식이 맞지 않습니다."),
142        dateISO: __("유효한 ISO 타입의 날짜로 다시 입력해주세요."),
143        number: __("숫자만 입력하실 수 있습니다."),
144        digits: __("숫자만 입력하실 수 있습니다."),
145        creditcard: __("유효한 신용카드 번호로 다시 입력해주세요."),
146        equalTo: __("동일한 값을 입력해주세요."),
147        accept: "Please enter a value with a valid extension.",
148        maxlength: jQuery.validator.format(__("최대 %i 이하 입력해 주세요.", "{0}")),
149        minlength: jQuery.validator.format(__("최소 %i 이상 입력해 주세요.", "{0}")),
150        rangelength: jQuery.validator.format(__("%1$i자에서 %2$iê¹
150Œì§€ 입력가능합니다.", ["{0}", "{1}"])),
151        range: jQuery.validator.format(__("%1$i와 %2$i사이의 숫자를 입력해주세요.", ["{0}", "{1}"])),
152        max: jQuery.validator.format(__("최대 %i 이상 입력하실 수 없습니다.", "{0}")),
153        min: jQuery.validator.format(__("최소 %i 이하 입력하실 수 없습니다.", "{0}"))
154    });
155
156    //검색어
157    $("#frmSearchTop").validate({
158        submitHandler: function (form) {
159            if ($("#frmSearchTop input[name='adUrl']").val() && $("#frmSearchTop input[name='keyword']").val() == '') document.location.href = $("#frmSearchTop input[name='adUrl']").val();
160            else form.submit();
161        },
162        rules: {
163            keyword: {
164                required: function () {
165
166                    if ($("#frmSearchTop input[name='adUrl']").val()) {
167                        return false;o
168                    }
169                    else {
170                        return true;
171                    }
172                }
173            }
174        },
175        messages: {
176            keyword: {
177                required: __('검색어를 입력하세요.')
178            }
179        }
180    });
181
182    // 최근 검색어 삭제
183    $('.btn_top_search_del').click(function(e){
184        e.stopPropagation();
185        $self = $(this);
186        $.post('../goods/goods_ps.php', {
187            'mode': 'delete_recent_keyword',
188            'keyword': $(this).data('recent-keyword')
189        }, function (data, status) {
190            // 값이 없는 경우 성공
191            if (status == 'success' && data == '') {
192                if ($self.closest('ul').find('li').length == 1) {
193                    $self.closest('li').remove();
194                    $('.btn_top_search_all_del').remove();
195                    $('.js_recent_area').append('<dd>' + __('최근 검색어가 없습니다.') + '</dd>');
196                } else {
197                    $self.closest('li').remove();
198                }
199            } else {
200                console.log('request fail. ajax status (' + status + ')');
201            }
202        });
203    });
204
205    // 최근 검색어 전체 삭제
206    $('.btn_top_search_all_del').click(function(e){
207        $.post('../goods/goods_ps.php', {
208            'mode': 'delete_recent_all_keyword'
209        }, function (data, status) {
210            // 값이 없는 경우 성공
211            if (status == 'success' && data == '') {
212                $('.js_recent_list').find('li').remove()
213                $('.btn_top_search_all_del').remove();
214                $('.js_recent_area').append('<dd>' + __('최근 검색어가 없습니다.') + '</dd>');
215            } else {
216                console.log('request fail. ajax status (' + status + ')');
217            }
218        });
219    });
220
221    // Ajax 에러 및 처리 기본값 설정
222    $.ajaxSetup({
223        beforeSend: function (xhr, settings) {
224            xhr.url = settings.url;
225            xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'));
226        },
227        complete: function () {
228            gd_trigger_checkbox_ui();
229            gd_select_remodeling();
230            gd_checkbox_all();
231
232            //이미지 로딩 향상 사용 시 호출.
233            if ($.isFunction($.fn.lazyload) === true) {
234                setTimeout(function() {
235                    $("img.gd_image_lazy").lazyload({threshold:200});
236                }, 1);
237            }
238        },
239        error: function (xhr, textStatus, error) {
240            if (xhr.status == '404' && error == 'Not Found') {
241                console.log('[404 Not Found]\nThe requested URL was not found.');
242            }
243            else if (xhr.status == '500' && error == 'Internal Server Error' && xhr.responseText != '') {
244                console.log(xhr.responseText);
245            }
246            gd_close_layer();
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: 'yes'
388    });
389    win.focus();
390    return win;
391}
392/**
393 * 쿠키 생성
394 */
395function createCookie(name, value, days) {
396    var expires;
397    if (days) {
398        var date = new Date();
399        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
400        expires = "; expires=" + date.toGMTString();
401    } else {
402        expires = "";
403    }
404    document.cookie = name + "=" + value  + "; path=/; expires=" + expires + ";";
405}
406/**
407 * 팝업창 Cookie 컨트롤
408 * @param string name 팝업창 이름 (코드_창종류)
409 * @param object elemnt elemnt
410 * @return
411 */
412function gd_popup_cookie(name, elemnt) {
413    if (elemnt.checked === true) {
414        createCookie(name,'true',1);
415        var popupKind = name.split('_');
416        if (popupKind[1] == 'window') {
417            setTimeout('self.close()');
418        } else {
419            setTimeout("$('#" + name + "').hide()");
420        }
421    } else {
422       createCookie(name, null);
423    }
424    return;
425}
426
427/**
428 * 메일 도메인 선택
429 */
430function gd_select_email_domain(name,select) {
431    if (typeof select === 'undefined') {
432        select = 'emailDomain';
433    }
434    var $email = $(':text[name=' + name + ']');
435    var $emailDomain = $('select[id='+select+']');
436    $emailDomain.on('change', function (e) {
437        var emailValue = $email.val();
438        var indexOf = emailValue.indexOf('@');
439        if (indexOf == -1) {
440            if ($emailDomain.val() === 'self') {
441                $email.val(emailValue + '@');
442            } else {
443                $email.val(emailValue + '@' + $emailDomain.val());
444            }
445            $email.trigger('focusout');
446        } else {
447            if ($emailDomain.val() === 'self') {
448                $email.val(emailValue.substring(0, indexOf + 1));
449                $email.focus();
450            } else {
451                $email.val(emailValue.substring(0, indexOf + 1) + $emailDomain.val());
452                $email.trigger('focusout');
453            }
454        }
455    });
456}
457
458/**
459 * 도로명 주소 찾기 (팝업)
460 *
461 * @author artherot
462 * @param string zoneCodeID zonecode input ID
463 * @param string addrID address input ID
464 * @param string zipCodeID zipcode input ID
465 */
466function gd_postcode_search(zoneCodeID, addrID, zipCodeID) {
467    var win = gd_popup({
468        url: '../share/postcode_search.php?zoneCodeID=' + zoneCodeID + '&addrID=' + addrID + '&zipCodeID=' + zipCodeID,
469        target: 'postcode',
470        width: 540,
471        height: 700,
472        resizable: 'yes',
473        scrollbars: 'yes'
474    });
475    win.focus();
476    return win;
477}
478
479/**
480 * 비회원 개인정보 수집항목 동의 링크
481 */
482function gd_redirect_collection_agree() {
483    window.open('/service/private.php');
484}
485
486/**
487 * 파일 업로드 객체
488 */
489var gdAjaxUpload = {
490    upload : function(data) {
491        var formData = new FormData();
492        for (var k in data.params){
493            if (data.params.hasOwnProperty(k)) {
494                formData.append(k, data.params[k]);
495            }
496        }
497        if(data.onbeforeunload){
498            window.onbeforeunload = data.onbeforeunload;
499            data.formObj.on("submit", function () {
500                window.onbeforeunload = null;
501            });
502        }
503
504        if(data.formObj.find('[name=uploadType][value=ajax]').length < 1) {
505            data.formObj.append('<input type="hidden"  name="uploadType" value="ajax" >');
506        }
507        var index = data.thisObj.closest('form').find('input:file').index(data.thisObj);
508        formData.append('uploadFile', data.thisObj[0].files[0]);
509
510        $.ajax({
511            url: data.actionUrl,
512            type: 'POST',
513            data: formData,
514            async: false,
515            cache: false,
516            contentType: false,
517            processData: false,
518            dataType: 'json',
519            success: function (returnData) {
520                returnData['index'] = index;
521                if(returnData.result == 'ok') {
522                    if ($('input[name="uploadFileNm[' + index + ']"]').length == 0) {
523                        data.formObj.append("<input type='hidden' name='uploadFileNm[" + index + "]' value='" + returnData.uploadFileNm + "'>");
524                        data.formObj.append("<input type='hidden' name='saveFileNm[" + index + "]' value='" + returnData.saveFileNm + "'>");
525                    }
526                    else {
527                        $("input[name='uploadFileNm[" + index + "]']").val(returnData.uploadFileNm);
528                        $("input[name='saveFileNm[" + index + "]']").val(returnData.saveFileNm);
529                    }
530                    if(typeof data.successAfter == 'function') {
531                        data.successAfter(returnData);
532                    }
533                }
534                else if(returnData.result == 'cancel'){
535                    if ($("input[name='uploadFileNm[" + index + "]']").length > 0) {
536                        $("input[name='uploadFileNm[" + index + "]']").remove();
537                        $("input[name='saveFileNm[" + index + "]']").remove();
538                    }
539                }
540                else {
541                    gdAjaxUpload.isSuccess = false;
542                    $('label[for=attach' + (index + 1) + '] .text').val('');  //파일시스템 텍스트 빈값 처리
543                    alert(returnData.errorMsg);
544                    if(typeof data.failAfter == 'function') {
545                        data.failAfter(returnData);
546                    }
547                }
548            }
549        });
550    }
551};
552
553/**
554 * 프레임 리사이즈
555 */
556function gd_resize_frame(obj) {
557    var iframeHeight = (obj).contentWindow.document.body.clientHeight;
558    (obj).height = iframeHeight + 80;
559}
560
561/**
562 * 회원다운로드 쿠폰 링크 다운 받기
563 *
564 * @param couponNo
565 */
566function couponLinkDown(couponNo) {
567    var params = {
568        mode: "couponDownLink",
569        couponCode: couponNo
570    };
571    $.ajax({
572        method: "POST",
573        async: false,
574        cache: false,
575        url: "/mypage/coupon_link_down.php",
576        data: params,
577        success: function (data) {
578            result = JSON.parse(data);
579            alert(result['msg']);
580            if (result['code'] == '0') {
581                document.location.href = "/member/login.php";
582            }
583        },
584        error: function (data) {
585            alert(result['msg']);
586        }
587    });
588}
589
590/**
591 * PG 관련 영수증 보기
592 *
593 * @author artherot
594 * @param string modeStr 카드, 현금영수증 종류 (card, cash)
595 * @param string orderNo 주문 번호
596 */
597function gd_pg_receipt_view(modeStr, orderNo) {
598    // 사이즈를 미리 설정 - 자동으로 창이 커지지 않아 미리 설정함
599    var preWidth = 430;
600    var preHeight = 700;
601
602    // 미리 팝업창을 띄우기
603    var prePopupData = {
604        'url': 'about:blank',
605        'target': 'show_receipt',
606        'width': preWidth,
607        'height': preHeight
608    };
609    var show_receipt = gd_popup(prePopupData);
610
611    // 각 PG별 영수증 팝업창
612    $.post('../share/show_receipt.php', {
613        mode: modeStr,
614        orderNo: orderNo
615    }, function (data) {
616        var infoData = data;
617        if (typeof infoData['error'] == 'undefined') {
618            gd_popup(infoData);
619        }
620        else {
621            alert(infoData['error']);
622            show_receipt.close();
623        }
624    }, 'json');
625}
626
627/*** IE 버전 체크 ***/
628function gd_is_ie () {
629    var nav = navigator.userAgent.toLowerCase();
630    if (nav.indexOf('msie') != -1) {
631        return parseInt(nav.split('msie')[1]);
632    } else {
633        return false;
634    }
635}
636
637/**
638 * 쿼리스트링값 찾기
639 * @param query
640 * @param variable
641 * @returns {string}
642 */
643function gd_get_query_variable(query, variable) {
644    var vars = query.split('&');
645    for (var i = 0; i < vars.length; i++) {
646        var pair = vars[i].split('=');
647        if (decodeURIComponent(pair[0]) == variable) {
648            return decodeURIComponent(pair[1]);
649        }
650    }
651    console.log('Query variable %s not found', variable);
652}
653
654/**
655 * 동적 스크립트 바인딩 (스크립트 로딩 후 메서드 실행되도록 처리)
656 *
657 * @author Jong-tae Ahn
658 * @param number
659 * @param places
660 * @param symbol
661 * @param thousand
662 * @param decimal
663 * @returns {string}
664 */
665function add_script(url, callback) {
666    var done = false; // 스크립트 로딩 여부
667    var head = document.getElementsByTagName("head")[0] || document.documentElement;
668    var script = document.createElement("script");
669
670    //script.charset = 'UTF-8';
671    script.src = url;
672    script.onload = script.onreadystatechange = function () {
673        if (!done && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete")) {
674            done = true;
675            callback();
676
677            // IE에서 메모리 누수 방지를 위한 처리
678            script.onload = script.onreadystatechange = null;
679            if (head && script.parentNode) {
680                head.removeChild(script);
681            }
682        }
683    };
684
685    // Use insertBefore instead of appendChild  to circumvent an IE6 bug.
686    // This arises when a base node is used (#2709 and #4378).
687    head.insertBefore(script, head.firstChild);
688}
689
690
691
692
693/*** 스토리지 지원 여부 ***/
694function supports_html5_storage() {
695    try {
696        return 'localStorage' in window && window['localStorage'] !== null;
697    } catch (e) {
698        return false;
699    }
700}
701
702/*** 세션 스토리지 저장 ***/
703function saveSession(control_key, control_value) {
704    if (!supports_html5_storage()) {
705        createCookie(control_key, control_value, 7);
706    } else {
707        sessionStorage[control_key] = control_value;
708    }
709};
710
711/*** 세션 스토리지 로드 ***/
712function loadSession(control_key) {
713    var control_value;
714    if (!supports_html5_storage()) {
715        control_value = readCookie(control_key);
716    } else {
717        control_value = sessionStorage[control_key];
718    }
719    return control_value;
720};
721
722/*** 로컬 스토리지 저장 ***/
723function saveVal(control_key, control_value) {
724    if (!supports_html5_storage()) {
725        createCookie(control_key, control_value, 7);
726    } else {
727        localStorage.setItem(control_key, control_value);
728    }
729};
730
731/*** 로컬 스토리지 로드 ***/
732function loadVal(control_key) {
733    var control_value;
734    if (!supports_html5_storage()) {
735        control_value = readCookie(control_key);
736    } else {
737        control_value = localStorage.getItem(control_key);
738    }
739    return control_value;
740};

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.