PageSourceSearch

https://pinsure.co.kr/js/consult.js

js pinsure.co.kr collected 2026-10-06 12:11:49 UTC 9,416 bytes, 317 lines download raw bytes

1/*
2 * File       : js.js
3 * Author     : YONG
4 *
5 * 최종수정일 : 25/00/00
6 *
7 * SUMMARY:
8 * consult.js
9 */
10
11// =======================
12// 전화번호 유효성 검사 유틸
13// =======================
14const PhoneValidator = {
15    validPrefixes: {
16        mobile: ['010', '011', '016', '017', '018', '019'],
17        area2: ['02'],
18        area3: ['031', '032', '033', '041', '042', '043', '051', '052', '053', '054', '055', '061', '062', '063', '064']
19    },
20
21    getPrefix(phoneNum) {
22        return phoneNum.startsWith('02') ? phoneNum.slice(0, 2) : phoneNum.slice(0, 3);
23    },
24
25    isValid(phoneNum) {
26        const prefix = this.getPrefix(phoneNum);
27        const len = phoneNum.length;
28
29        if (this.validPrefixes.mobile.includes(prefix)) {
30            return len === 11;
31        }
32
33        if (this.validPrefixes.area2.includes(prefix)) {
34            return len === 9 || len === 10;
35        }
36
37        if (this.validPrefixes.area3.includes(prefix)) {
38            return len === 10 || len === 11;
39        }
40
41        return false;
42    },
43
44    filterInput($input) {
45        $input.on('input', function () {
46            this.value = this.value.replace(/[^0-9]/g, '');
47        });
48    }
49};
50
51const InputFilter = {
52    // 숫자만 허용 (ex. 나이 입력, 숫자 필드 등)
53    allowOnlyNumbers($input) {
54        $input.on('input', function () {
55            this.value = this.value.replace(/[^0-9]/g, '');
56        });
57    },
58
59    // 특수문자 제거 (ex. 문의내용 textarea)
60    removeSpecialChars($input) {
61        $input.on('input', function () {
62            this.value = this.value.replace(/[<>"'&/]/g, '');
63        });
64    }
65};
66
67// =======================
68// 전화번호 입력 필터링 적용
69// =======================
70$(document).ready(function () {
71
72    // 전화번호 필터
73    PhoneValidator.filterInput($('#consultantPhone'));
74
75    // 숫자만 입력 필드 예시 (나이 필드 등)
76    InputFilter.allowOnlyNumbers($('#age'));
77
78    // 문의사항 특수문자 제거
79    InputFilter.removeSpecialChars($('#consultTxt'));
80
81});
82
83// =======================
84// 상담신청 함수
85// =======================
86var isRunning = false; // 연타방지
87
88function OnSubmit(el) {
89    if (isRunning == true) {
90        alert("처리중입니다. 잠시후 다시 시도해주세요");
91        return;
92    }
93
94    var siteName = $('body').data('sitename') || "";
95    var siteLink = $('body').data('sitelink') || "";
96
97    // 상품 타입 유동 처리 (라디오 버튼 기준, 안전하게 처리)
98    var csType = "";
99    var $csEl = $('.cs__list li.active');
100
101    if ($csEl.length > 0) {
102        csType = $csEl.data('value').trim();
103    }
104
105    var type = "";
106    var $typeEl = $('#csType input:radio[name="type"]:checked');
107    if ($typeEl.length > 0) {
108        type = $typeEl.val().trim();
109    }
110
111    var gender = "";
112    var $genderEl = $('#csGender input:radio[name="gender"]:checked');
113    if ($genderEl.length > 0) {
114        gender = $genderEl.val().trim();
115    }
116
117    var insuType = "";
118    var $selectEl = $('#insuSelect');
119
120    if ($selectEl.length > 0) {
121        insuType = $selectEl.val().trim();
122    }
123
124    var userNm = $('#consultantNm').val();
125    var phoneNum = $('#consultantPhone').val();
126    var weekNum = $('#age').val();
127    var memo = $('#consultTxt').val();
128
129
130    if (userNm == "") {
131        alert("이름을 입력해주세요!");
132        return;
133    }
134
135    if (!PhoneValidator.isValid(phoneNum)) {
136        alert("전화번호를 확인해주세요.");
137        return;
138    }
139
140    if (weekNum == "") {
141        alert("생년월일을 입력해주세요 ^^");
142        return;
143    }
144
145    if (memo == "") {
146        memo = `[${siteName}]${csType ? `[${csType}]` : ""}${insuType ? `[${insuType}]` : ""}${type ? `[${type}]` : ""}${gender ? `[${gender}]` : ""}[상담문의][${siteLink}]`;
147    } else {
148        memo = `[${siteName}]${csType ? `[${csType}]` : ""}${insuType ? `[${insuType}]` : ""}${type ? `[${type}]` : ""}${gender ? `[${gender}]` : ""}${memo}[${siteLink}]`;
149    }
150
151    if (!$('#checkBox').is(":checked")) {
152        alert('개인정보 수집활용 동의를 체크해 주세요');
153        return;
154    }
155
156    $('#CONSULTANT_NM').val(userNm); // 상담신청자
157    $('#CONSULTANT_PHONE').val(fn_hypenPhone(phoneNum)); // 연락처
158    $('#INSURANT_AGE').val(weekNum); // 임신주수/나이
159    $('#CONSULTANT_TXT').val(memo); // 상담내용
160
161    if ($('#CONSULTANT_URL').val() == undefined || $('#CONSULTANT_URL').val() == null || $('#CONSULTANT_URL').val() == "") {
162        $('#CONSULTANT_URL').val(document.referrer);
163    }
164
165    // =======================
166    // hp & time
167    // =======================
168    const honeypot = document.querySelector('#consultFrm input[name^="hp_"]');
169    const lastSubmit = localStorage.getItem('lastSubmit') || 0;
170    const now = Date.now();
171
172    if (honeypot && honeypot.value.trim() !== '') {
173        alert("성공적으로 문의신청하였습니다");
174        return;
175    }
176
177    if (now - lastSubmit < 5000) {
178        alert("잠시 후 다시 시도해 주세요.");
179        return;
180    }
181
182
183    giMirrorConsultToGcp();
184
185    $.ajax({
186        type: "POST",
187        async: true,
188        url: "https://yebox.kr/globalinsu/consultSite/consult/send.do",
189        dataType: "json",
190        data: $('#consultFrm').serialize(),
191        beforeSend: function () {
192            $.blockUI();
193            isRunning = true;
194        },
195        success: function (result) {
196            $.unblockUI();
197            if (result.success) {
198                $('#REF_SEQ').val(result.item.lastSeq);
199                $.getScript('https://yebox.kr/js/ref/ref.js');
200
201                //네이버 cpc 로그분석 241016
202                if (!wcs_add) var wcs_add = {};
203                wcs_add["wa"] = "s_dccb388cd17";
204                var _nasa = {};
205                if (window.wcs) {
206                    _nasa["cnv"] = wcs.cnv("4", "1");
207                    wcs_do(_nasa);
208                }
209
210                alert('성공적으로 문의신청하였습니다.');
211                localStorage.setItem('lastSubmit', now); // time
212                location.reload();
213            } else {
214                console.log("실패");
215            }
216        },
217        error: function () {
218            $.unblockUI();
219            alert("오류가 발생하였습니다.\n관리자에게 문의하여 주세요.");
220        },
221        complete: function () {
222            $.unblockUI();
223            isRunning = false;
224            $('.cs').find('input').val("");
225        }
226    });
227}
228
229function gfn_onlyNumber(obj, maxNum) {
230    $(obj).keyup(function () {
231        $(this).val($(this).val().replace(/[^0-9]/g, ""));
232    });
233    var thisValue = $(obj).val();
234    if (thisValue.length > maxNum) {
235        $(obj).val(thisValue.substr(0, maxNum));
236    }
237}
238function fn_hypenPhone(str) {
239    str = str.replace(/[^0-9]/g, '');
240    var tmp = '';
241    if (str.substr(0, 2) == '02') {
242        if (str.length < 4) {
243        } else if (str.length < 6) {
244            tmp += str.substr(0, 2);
245            tmp += '-';
246            tmp += str.substr(2);
247        } else if (str.length < 10) {
248            tmp += str.substr(0, 2);
249            tmp += '-';
250            tmp += str.substr(2, 3);
251            tmp += '-';
252            tmp += str.substr(5, 4);
253        } else {
254            tmp += str.substr(0, 2);
255            tmp += '-';
256            tmp += str.substr(2, 4);
257            tmp += '-';
258            tmp += str.substr(6, 4);
259        }
260    } else {
261        if (str.length < 4) {
262        } else if (str.length < 7) {
263            tmp += str.substr(0, 3);
264            tmp += '-';
265            tmp += str.substr(3);
266        } else if (str.length < 11) {
267            tmp += str.substr(0, 3);
268            tmp += '-';
269            tmp += str.substr(3, 3);
270            tmp += '-';
271            tmp += str.substr(6);
272        } else {
273            tmp += str.substr(0, 3);
274            tmp += '-';
275            tmp += str.substr(3, 4);
276            tmp += '-';
277            tmp += str.substr(7);
278        }
279    }
280    // 전체길이 13을 초과하면 삭제
281    if (tmp.length > 13) {
282        tmp = tmp.substr(0, 13);
283    }
284    return tmp;
285}
286
287// input 정규식
288function characterCheck(obj) {
289    // 허용하고 싶은 특수문자가 있다면 여기서 삭제하면 됨
290    var regExp = /[ \{\}\[\]\/?.,;:|\)*~`!^\-_+┼<>@\#$%&\'\"\\\(\=0-9]/gi;
291
292    if (regExp.test(obj.value)) {
293
294        // alert("특수문자는 입력하실 수 없습니다.");
295        obj.value = obj.value.substring(0, obj.value.length - 1); // 입력한 특수문자 한자리 지움
296
297    }
298}
299
300// Queue GCloud independently; the legacy yebox request runs asynchronously.
301function giMirrorConsultToGcp() {
302    var endpoint = "https://gi-collector-receiver-632764787203.asia-northeast3.run.app/globalinsu/consultSite/consult/send.do";
303    var body = $('#consultFrm').serialize();
304    try {
305        if (navigator.sendBeacon) {
306            var payload = new Blob([body], { type: 'application/x-www-form-urlencoded' });
307            if (navigator.sendBeacon(endpoint, payload)) return;
308        }
309        if (window.fetch) {
310            fetch(endpoint, { method: 'POST', body: body, keepalive: true,
311                headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
312            }).catch(function () {});
313        }
314    } catch (e) {
315        // Keep the legacy form flow intact if the GCloud send cannot be queued.
316    }
317}

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.