PageSourceSearch

https://sell.chutcha.net/js/sub/main_v2.js?smc_v=001&t=1790256121_v_1

js chutcha.net collected 2026-09-24 13:22:48 UTC 18,812 bytes, 525 lines download raw bytes

1// js querystring 가져오기
2function scriptQuery() {
3    var script = document.getElementsByTagName('script');
4    script = script[script.length-1].src
5       .replace(/^[^\?]+\?/, '')
6       .replace(/#.+$/, '')
7       .split('&');
8     var queries = {}
9       , query;
10     while(script.length){
11          query = script.shift().split('=');
12          queries[query[0]] = query[1];
13     }
14     return queries;
15}
16// js url querystring 가져오기
17function getQueryStringObject() {
18    var a = window.location.search.substr(1).split('&');
19    if (a == "") return {};
20    var b = {};
21    for (var i = 0; i < a.length; ++i) {
22        var p = a[i].split('=', 2);
23        if (p.length == 1)
24            b[p[0]] = "";
25        else
26            b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
27    }
28    return b;
29}
30
31// API 버전 가져오기
32var _SMC_API_VER = scriptQuery('smc_v').smc_v;
33
34$(document).ready(function(event){
35
36    var param_np = getQueryStringObject().number_plate;
37    if(typeof param_np == "undefined"){
38        param_np = "";
39    }else{
40        $(".float_reg_form .regcar_submit_btn").addClass("on");
41    }
42
43    // 초기 페이지 차량번호입력란 focus
44    if($("input[name='number_plate']").length > 0){
45        $("input[name='number_plate']").focus();
46        $("input[type='text'][name='number_plate']").val(param_np);
47    }
48
49    
50
51
52    var main_banner_swiper = new Swiper('.main_banner_slide', {
53        autoplay: {
54            delay: 5000,
55        },
56        loop: true,
57        pagination: {
58            el: '.main_banner_slide .swiper-pagination',
59        },
60    });
61
62
63    // 광고 모달 실행    
64    ad_landing_modal();
65});
66
67
68// 뒤로가기시 도착 페이지 작동
69window.onpageshow = function (event){
70    if(event.persisted || (window.performance && window.performance.navigation.type == 2)){        
71        // 초기 페이지 차량번호입력란 focus
72        if($("input[name='number_plate']").length > 0){
73            $("input[name='number_plate']").focus();
74            var npchk = numberPlateValidation($("input[type='text'][name='number_plate']").val());
75            if (npchk[0] === null && npchk[1] === null && npchk != "") {
76                $(this).addClass("error");
77                $(".regcar_submit_btn").removeClass("on");
78            }else{
79                if($("input[type='text'][name='number_plate']").val() != ""){
80                    $(".regcar_submit_btn").addClass("on");
81                }
82                $(this).removeClass("error");
83            }
84        }
85    }
86}
87
88// 스크롤시 상단 영역 고정기능
89$(window).scroll(function(e){
90    if($(".main_header .login_btn").length > 0){
91        if($(".main_header").outerHeight() < $(window).scrollTop()){
92            $(".main_header").addClass("sticky");
93            $(".reg_car_cont").addClass("sticky");
94        }else{
95            $(".main_header").removeClass("sticky");
96            $(".reg_car_cont").removeClass("sticky");
97        }
98    }
99});
100
101// 차량번호 입력시 정상여부 확인
102$(document).on("keyup keypress",".float_reg_form input[name='number_plate']",function(e){
103    var number_plate = $(this).val();
104    var plate_vali = numberPlateValidation(number_plate);
105
106    if (plate_vali[0] === null && plate_vali[1] === null && number_plate != "") {
107        $(this).addClass("error");
108        $(".regcar_submit_btn").removeClass("on");
109    }else{
110        if(number_plate != ""){
111            $(".regcar_submit_btn").addClass("on");
112        }
113        $(this).removeClass("error");
114    }
115});
116
117// 차량번호 입력시 넘기기
118$(document).on("submit",".float_reg_form form",function(e){
119    if(!$(".regcar_submit_btn").hasClass("on")){
120        regCarAlertModal('','올바른 차량번호를 입력해주세요.');
121        return false;
122    }
123});
124
125/** 차량 번호 submit전에 확인 후 차량등록 페이지로 이동 */
126function beforeSubmitRegForm() {
127    if(!$(".regcar_submit_btn").hasClass("on")){
128        regCarAlertModal('','올바른 차량번호를 입력해주세요.');
129        regCarFormGAEvent(false); // GA4 이벤트 전송
130        return false;
131    }else{
132        var number_plate = $("input[name='number_plate']").val();
133        $.ajax({
134            async: false,
135            url: "/apiv"+_SMC_API_VER+"/Smc/checkNumberplate",
136            type: 'POST',
137            dataType: 'JSON',
138            data: {number_plate : number_plate},
139            success: function (data)
140            {
141                if(data.code == 200){
142                    regCarFormGAEvent(true); // GA4 이벤트 전송
143                    // $(".float_reg_form form").submit();
144                    location.href = "/regcar/renew_regcar?number_plate="+number_plate;
145                }else{
146                    regCarFormGAEvent(false); // GA4 이벤트 전송
147                    regCarAlertModal('',data.msg);
148                    return false;
149                }
150            }
151        });
152    }
153}
154// 견적신청 버튼 클릭시 - 차량번호 확인 후 submit
155$(document).on("click",".regcar_submit_btn", beforeSubmitRegForm);
156// 차량번호 입력란 엔터 이벤트 발생시 - 차량번호 확인 후 submit
157$(document).on("keyup",".float_reg_form input[name='number_plate']", function(e) {
158    if(e.keyCode == 13) {
159        beforeSubmitRegForm();
160    }
161});
162
163
164// 메인 FAQ 열고닫기
165$(document).on("click",".main_faq_dt",function(e){
166    if($(this).parents("dt").hasClass('on')){
167        $(".main_faq_cont dl dt").removeClass("on");
168        $(".main_faq_cont dl dd").removeClass("on");
169    }else{
170        $(".main_faq_cont dl dt").removeClass("on");
171        $(".main_faq_cont dl dd").removeClass("on");
172        $(this).parents("dt").addClass("on");
173        $(this).parents("dt").next().addClass("on");
174    }
175});
176
177// 로그아웃
178$(document).on("click",".logout_btn",function(){
179    $('#confirm_modal .inner_wrap .modal_msg').text('로그아웃 하시겠습니까?'); //모달 문구 변경
180    $("#confirm_modal").modal({ // 모달 open
181        escapeClose: false,
182        clickClose: false,
183        showClose: false
184    });
185    $('#confirm_modal .confirm_btn').addClass("logout");
186    $('#confirm_modal .confirm_btn').attr("data-gotourl",$(this).attr("href"));
187    return false;
188});
189
190// 모달 이미지 삭제 확인 버튼 클릭 시 미리보기 이미지 삭제
191$(document).on('click','#confirm_modal .confirm_btn.logout', function() {
192    console.log('logout button');
193    
194    // GA4 이벤트 전송
195    try { logoutGAEvent(); } catch(err) { console.warn('GA event function :: ', err); }
196
197    location.href  = $(this).attr("data-gotourl");
198});
199
200// 모달 취소 버튼 누를 때 모달 확인 창 attribute 값 삭제
201$(document).on("click", "#confirm_modal .cancel_btn.logout", function() {
202    $('#confirm_modal .confirm_btn').removeClass("logout");
203    $('#confirm_modal .confirm_btn').removeAttr("data-gotourl");
204});
205
206// 모달 닫기
207$(document).on('click', '.cancel_btn', function(){
208    $.modal.close();
209});
210
211//  ajax를 활용한 내차팔기 메인 견적데이터 새로고침
212var timeCall = "";
213var reloadLimitDate = function()
214{
215    var time_cnt = 0;
216    clearInterval(timeCall);
217    timeCall = setInterval(function(){
218        var host = '/main/reloadCarData';
219        var smcIds = $('input:hidden[name="smc_ids"]').val();
220
221        $(".reg_car_list_wrap li.status_biding").each(function (i, v) {
222            var this_ele = $(this);
223            var smcId = $(this).data('smc_id');
224            var reserveDate =  this_ele.data("reserve_date");
225            var plusHours =  this_ele.data("plus_hours");
226            var isEnd =  this_ele.data("is_end");
227            var smcStatus =  this_ele.data("smc_status");
228            var estnCnt =  this_ele.data("estn_cnt");
229            var deadLine = getTimeDeadLine(reserveDate, plusHours);
230            timeElementUpdate(smcId, deadLine, isEnd, smcStatus, estnCnt);
231        });
232
233        if(time_cnt == 7){
234            $.ajax({
235                cache: false,
236                async: false,
237                url: host,
238                type: 'POST',
239                dataType: 'JSON',
240                data: {smcIds : smcIds},
241                success: function (data)
242                {
243                    if (data.success) {
244
245                        if(data.totalCnt > 0) {
246
247                            for(var i in data.return)
248                            {
249                                var r = data.return[i];
250                                var deadLine = getTimeDeadLine(r.reserveData, r.plusHours);
251                                timeElementUpdate(r.smc_id, deadLine, r.is_end, r.smc_status, r.estn_cnt);
252                                clearInterval(timeCall);
253                                reloadLimitDate();
254                            }
255                        }
256                        return false;
257                    } else if (data.error) {
258                        clearInterval(timeCall);
259                        return false;
260                    }
261                }
262            });
263            time_cnt = 0;
264        }
265
266        time_cnt++;
267    }, 1000); // 7초마다 한번씩
268
269};
270
271// 목록 견적데이터 새로고침
272function timeElementUpdate(smcId, updateDate, isEnd, smc_status, estn_cnt)
273{
274    if(!smcId || !smc_status || isEnd){
275        return false;
276    }
277    var estn_cnt = (estn_cnt || 0);
278
279    var html = "";
280    var statusStr_1 = "";
281    var statusStr_2 = "";
282    var statusTimeStr = "";
283    var target = $("#smc_car_"+smcId);
284    target.find('.bid_indicator').empty();
285    target.find('.status_indicator').empty();
286    target.find('.remain_time').empty();
287    if(smc_status == 1002 && !isEnd){
288        if(estn_cnt <= 0){
289            statusStr_1 = ('첫 견적 대기 중');
290            statusStr_2 = "견적진행 중";
291        }else{
292            statusStr_1 = ('<span>'+estn_cnt+'건</span>의 견적이 도착했습니다.');
293            statusStr_2 = "견적진행 중";
294        }
295    }else if(smc_status == 1003 || estn_cnt >= 20){
296        statusStr_1 = ('견적을 선택해주세요.');
297        statusStr_2 = "견적진행 완료";
298    }else if(smc_status == 1004){
299        statusStr_1 = ('견적 유효기간 만료');
300        statusStr_2 = "견적만료";
301    }else if(smc_status == 1005 || smc_status == 1006){
302        statusStr_1 = ('거래 진행 중');
303        statusStr_2 = ('거래 진행 중');
304    }else if(smc_status == 1007 && (isEnd && smc_status != 2001)){
305        statusStr_1 = ('거래 최종 완료');
306        statusStr_2 = "거래완료";
307    }else if(smc_status == 1008){
308        statusStr_1 = ('거래 취소');
309        statusStr_2 = "거래취소";
310    }else if(smc_status == 2001){
311        statusStr_1 = ("승인대기 중");
312        statusStr_2 = "현재 승인대기 중";
313    }else if(smc_status == 1001){
314        statusStr_1 = "등록을 완료해주세요.";
315        statusStr_2 = ("임시저장 중");
316    }
317    if(smc_status == 1002){
318        statusTimeStr = "견적";
319    }else{
320        statusTimeStr = "선택";
321    }
322    target.find('.status_indicator').html(statusStr_2);
323    target.find('.bid_indicator').html(statusStr_1);
324
325    if(smc_status == 1001){
326        html += "<dt>차량등록</dt>";
327        html += "<dd>10% 완료</dd>";
328    }else if(smc_status == 2001){
329        html += "<dt>차량등록</dt>";
330        html += "<dd>100% 완료</dd>";
331    }else{
332        html += "<dt>" + statusTimeStr + "마감 시간</dt>";
333        if (!isEnd && $.inArray(smc_status, [1002, 1003, 1005, 1006]) > -1) {
334            html += '<dd>';
335            html += ((updateDate.left_hours ? updateDate.left_hours : '00') + ":");
336            html += ((updateDate.left_min ? updateDate.left_min : '00') + ":");
337            html += ((updateDate.left_sec ? updateDate.left_sec : '00'));
338            html += '</dd>';
339        } else {
340            html += "<dd>종료</dd>";
341        }
342    }
343    target.find('.remain_time').html(html);
344
345    // smcId, updateDate, isEnd, smc_status, estn_cnt
346    $(".reg_car_list_wrap li.status_biding").each(function (i, v) {
347        var $this = $(this);
348        $this.data('smc_id', smcId);
349        $this.data("is_end", isEnd);
350        $this.data("smc_status", smc_status);
351        $this.data("estn_cnt", estn_cnt);
352    });
353    return false;
354}
355
356// 견적만료시간 구하기
357var getTimeDeadLine = function(startDate, plusHour)
358{
359    startDate_split =  startDate.split(" ");
360    startDate_split[0] = startDate_split[0].split("-")[0]+"/"+startDate_split[0].split("-")[1]+"/"+startDate_split[0].split("-")[2]
361    startDate_split = startDate_split[0]+" "+startDate_split[1];
362
363    var result = new Array();
364    result['now_time'] = Math.floor(new Date().getTime()/1000);
365    result['start_time'] = Math.floor(new Date(startDate_split).getTime()/1000);
366    result['end_time'] = result['start_time'] + (plusHour * 3600);
367    result['end'] = false;
368
369    if(result['now_time'] < result['end_time'])
370    {
371        result['left_seconds'] = (result['end_time'] - result['now_time']);
372
373        result['left_days'] = Math.floor(result['left_seconds'] / (86400 * (plusHour / 24)));
374        result['left_hours'] = Math.floor((result['left_seconds'] / 3600) - (24*result['left_days']));
375        result['diff'] = result['left_seconds'] - (result['left_hours'] * 3600) - (24 * result['left_days'] * 3600);
376        result['left_min'] = Math.floor(result['diff'] / 60);
377        result['left_sec'] =  Math.floor(result['diff'] - (result['left_min'] * 60));
378
379        result['left_hours'] = (result['left_hours'] < 10) ? '0' + result['left_hours'] : result['left_hours'];
380        result['left_min'] = (result['left_min'] < 10) ? '0' + result['left_min'] : result['left_min'];
381        result['left_sec'] = (result['left_sec'] < 10) ? '0' + result['left_sec'] : result['left_sec'];
382
383        result['limitDaySec'] = (result['end_time'] - result['start_time']);
384        result['per'] = Math.abs(Math.ceil(100 - ((result['limitDaySec'] - result['left_seconds']) / result['limitDaySec']) * 100));
385
386        if(result['day'] < 0){
387            result['left_days'] = 0;
388            result['left_hours'] = 0;
389            result['left_min'] = 0;
390            result['left_sec'] = 0;
391            result['limitDaySec'] = 0;
392            result['end'] = true;
393        }
394    }
395
396    $(".reg_car_list_wrap li.status_biding").each(function (i, v) {
397        var $this = $(this);
398        $this.data("reserve_date", startDate);
399        $this.data("plus_hours", plusHour);
400    });
401
402    return result;
403};
404
405// 첫차 앱 다운로드
406var gotoDownloadLink = function()
407{
408    var gotoUrl = "";
409    var android_marketUrl = "https://app.adjust.com/jsr?url=https%3A%2F%2Fhc8a.adj.st%2f%3fadjust_t=tnsnf3q%26adjust_deeplink_js=1%26adjust_deeplink=chutcha%3a%2f%2fgoto%3Ftype%3dsmcmain%26adjust_campaign=smc%26adjust_adgroup=main_bottom%26adjust_creative=app%20icon";
410    var ios_appstoreUrl = "https://app.adjust.com/jsr?url=https%3A%2F%2Fhc8a.adj.st%2f%3fadjust_t=tnsnf3q%26adjust_deeplink_js=1%26adjust_deeplink=chutcha%3a%2f%2fgoto%3Ftype%3dsmcmain%26adjust_campaign=smc%26adjust_adgroup=main_bottom%26adjust_creative=app%20icon";
411
412    if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
413        if (navigator.userAgent.match(/iPhone|iPad|iPod/i)) {
414            gotoUrl = ios_appstoreUrl;
415        } else if (navigator.userAgent.match(/Android/i)) {
416            gotoUrl = android_marketUrl;
417        }
418    }else{
419        gotoUrl = android_marketUrl;
420    }
421    var win = window.open(gotoUrl, '_blank');
422    win.focus();
423};
424
425// 사업자 정보 자세히보기
426$(document).on("click",".legal_cont_wrap .agreement_link button",function(){
427    var flag = $(this).hasClass("on");
428    if(flag){
429        $(this).removeClass("on");
430        $(".legal_cont_wrap .company_info").removeClass("on");
431    }else{
432        $(this).addClass("on");
433        $(".legal_cont_wrap .company_info").addClass("on");
434    }
435});
436
437// 차량이 없을 때 견적 조회 클릭시
438$(document).on("click",".reg_cnt_zero",function(){
439    $('#basic_modal .inner_wrap .modal_title').text(''); //모달 문구 변경
440    $('#basic_modal .inner_wrap .modal_msg').html('등록된 견적 요청이 없습니다.<br />견적 요청 후 조회하실 수 있습니다.'); //모달 문구 변경
441    $("#basic_modal").modal({ // 모달 open
442        escapeClose: false,
443        clickClose: false,
444        showClose: false
445    });
446    return false;
447});
448
449
450// 차량 상세보기 버튼을 눌렀을 때 
451$(document).on("click",".smc_view_a",function(e){
452    e.preventDefault();
453
454    var smc_id = $(this).parents("li").data("smc_id");
455    var href = $(this).attr("href");
456
457
458    $.ajax({
459        type : 'POST',
460        url	: "/apiv"+_SMC_API_VER+"/smc/getCarViewUrl/"+smc_id,
461        dataType : 'json',
462        async: false,
463        success :function(data){
464            if(data.code == "200"){
465                herf = "/car?key="+data.keys;
466                location.href=href;
467            }else{
468                alert("오류가 발생했습니다. 다시 시도해주세요.");
469                location.reload();
470            }
471        }
472    });
473    return false;
474});
475
476
477// 광고 랜딩 모달 띄우기
478function ad_landing_modal(){         
479    var flag = getParameterByName("ad_landing_flag");
480
481
482    // 모달 띄우기
483    var ad_landing_modal = $("#ad_landing_modal");
484
485    // 특정 플래그가 있을 때만 띄우기
486    if(flag == 1){
487        // 모바일에서 접근할 때만 띄우기
488        if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
489                 
490            gtag('event', '팝업_뷰', {'event_category': '분기'});
491
492            ad_landing_modal.modal({
493                showClose: false,
494                clickClose: false,
495                escapeClose: false,
496                blockerClass : 'ad_landing_modal_blocker'
497            });
498        }
499    }    
500}
501
502// 광고 랜딩 모달 앱에서 보기 버튼 클릭
503$(document).on("click","#ad_landing_modal .app_link",function(){
504    gtag('event', '팝업_열기', {'event_category': '다운로드'});
505
506    if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {        
507        // 모바일일 경우
508        if (navigator.userAgent.match(/iPhone|iPad|iPod/i)) {
509            // iOS일때
510            parent.location.href='https://apps.apple.com/kr/app/id982096152';
511        }else{
512            // 안드로이드 일때
513            parent.location.href='https://play.google.com/store/apps/details?id=com.mrpic.chutcha&hl=ko';
514        }
515    }else{        
516        // PC일 경우
517        $.modal.close();
518    }
519});
520
521// 광고 랜딩 모달 웹에서 보기 버튼 클릭
522$(document).on("click","#ad_landing_modal .close_btn",function(){        
523    gtag('event', '팝업_취소', {'event_category': '웹랜딩'});
524    $.modal.close();
525});

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.