PageSourceSearch

https://reservationbox.kr/share/js/inplus.util.js

js reservationbox.kr collected 2026-10-02 02:00:11 UTC 20,797 bytes, 653 lines download raw bytes

1// 모바일 브라우저 체크
2var browserType = "pc";
3var mobileKeyWords = new Array('iPhone', 'iPod', 'BlackBerry', 'Android', 'Windows CE', 'LG', 'MOT', 'SAMSUNG', 'SonyEricsson');
4for (var word in mobileKeyWords) {
5    if (navigator.userAgent.match(mobileKeyWords[word]) != null) {
6        browserType = "mobile";
7    }
8}
9
10$(function() {
11    /* 준비중 */
12    $("a.btn_no_complete, button.btn_no_complete").on("click", function(e) {
13        alert("해당 메뉴는 준비중입니다.");
14        e.preventDefault();
15    });
16
17    /* 삭제 */
18    $("#btn_delete").on("click", function(e) {
19        if (!confirm("정말 삭제하시겠습니까?")) {
20            e.preventDefault();
21        }
22    });
23
24    $(document).on("click", ".btn_delete", function(e) {
25        if (!confirm("정말 삭제하시겠습니까?")) {
26            e.preventDefault();
27        }
28    });
29
30    /* 전체선택 */
31    $("#all_check").on("click", function(e) {
32        if ($(this).is(":checked")) {
33            $("input.list_check").attr("checked", true);
34        } else {
35            $("input.list_check").removeAttr("checked");
36        }
37    });
38
39    /* 한글 ime mode */
40    $("input.text, textarea.textarea").not("#login_id").css("ime-mode", "active");
41
42    /* 숫자 처리 관련 : S */
43    $("input.number, input.money, input.double").css("ime-mode", "disabled");
44    $(document).on("keydown", "input.number", function(e) {
45        if (e.keyCode !== 8 && e.keyCode !== 9 && e.keyCode !== 13 && e.keyCode !== 35 && e.keyCode !== 36 && e.keyCode !== 37 && e.keyCode !== 39 && e.keyCode != 46 && !(e.keyCode > 47 && e.keyCode < 58) && !(e.keyCode > 95 && e.keyCode < 106)) {
46            e.preventDefault();
47        }
48    }).on("focus", "input.number", function(e) {
49        if ($(this).val() === 0) {
50            $(this).val("").attr("value", "");
51        }
52    }).on("blur", "input.number", function(e) {
53        if ($(this).val() === "" && $(this).hasClass("not_null")) {
54            $(this).val("0").attr("value", "0");
55        }
56    });
57    /* 숫자 처리 관련 : E */
58
59    /* 금액 처리 관련 : S */
60    if (browserType.indexOf('mobile') > -1) {
61        onClassMoneyMobile();
62    } else {
63        onClassMoney();
64    }
65    /* 금액 처리 관련 : E */
66
67    /* readonly : S */
68    $(document).on("click", "input.readonly", function(e) {
69        var title = getInputTitle($(this));
70        var msg = title;
71        if (getLastChar(title)) {
72            msg += "은";
73        } else {
74            msg += "는";
75        }
76        msg += " 직접 작성할 수 없는 항목입니다.";
77        alert(msg);
78        e.preventDefault();
79    });
80    /* readonly : E */
81
82    /* a tag to ajax or popup : S */
83    $(document).on("click", "a.btn_ajax", function(e) {
84        getContentsbyAjax(this);
85        e.preventDefault();
86    }).on("click", "a.btn_open_popup", function(e) {
87        openPopup(this);
88        e.preventDefault();
89    }).on("click", "a.btn_confirm", function(e) {
90        var result = confirmByButton(this);
91        if (!result) {
92            e.preventDefault();
93        }
94    }).on("click", "a.btn_quick_date", function(e) {
95        changeQuickDate(this);
96        e.preventDefault();
97    });
98    /* a tag to ajax or popup : E */
99
100    /* placeholder : S */
101    $(document).on("focus", "input.placeholder, textarea.placeholder", function() {
102        $(this).addClass("no_placeholder");
103    }).on("blur", "input.placeholder, textarea.placeholder", function() {
104        checkPlaceholder(this);
105    });
106    checkAllPlaceholder(document);
107    /* placeholder : E */
108});
109
110/* 금액 필드 이벤트(PC) */
111function onClassMoney() {
112    $(document).on("focus", "input.money", function(e) {
113        var money = $(this).val();
114        if (money == 0) {
115            $(this).val("").attr("value", "");
116        } else {
117            money = delComma(money);
118            $(this).val(money).attr("value", money);
119        }
120    }).on("keydown", "input.money", function(e) {
121        if (e.keyCode !== 8 && e.keyCode !== 9 && e.keyCode !== 13 && e.keyCode !== 35 && e.keyCode !== 36 && e.keyCode !== 37 && e.keyCode !== 39 && e.keyCode != 46 && e.keyCode != 188 && !(e.keyCode > 47 && e.keyCode < 58) && !(e.keyCode > 95 && e.keyCode < 106)) {
122            e.preventDefault();
123        }
124    }).on("blur", "input.money", function(e) {
125        var money = $(this).val();
126        money = setComma(delComma(money));
127        $(this).val(money).attr("value", money);
128    });
129}
130
131/* 금액 필드 이벤트(모바일) */
132function onClassMoneyMobile() {
133    $(document).on("focus", "input.money", function(e) {
134        var money = $(this).val();
135        if (money == 0) {
136            $(this).val("").attr("value", "");
137        } else {
138            money = delComma(money);
139            $(this).val(money).attr("value", money);
140        }
141    });
142}
143
144/* 사용자 컨펌 */
145function confirmByButton(obj) {
146    var obj = $(obj);
147    var title = obj.attr("title");
148    var flag_change = obj.hasClass("btn_change");
149    var msg = title;
150
151    if (flag_change) {
152        msg += " 상태로 변경하시겠습니까?";
153    } else {
154        msg += " 페이지로 이동하시겠습니까?";
155    }
156    return confirm(msg);
157}
158
159/* 팝업창 열기 */
160function openPopup(obj) {
161
162    obj = $(obj);
163    var url = obj.attr("href");
164    var title = obj.attr("title");
165    var popup_size = "size_640x480";
166
167    var class_arr = obj.attr("class").split(" ");
168    var size_fmt = /^size_\d{3,4}x\d{3,4}$/;
169    for (var i = 0; i < class_arr.length; i++) {
170        if (size_fmt.test(class_arr[i])) {
171            popup_size = class_arr[i];
172            break;
173        }
174    }
175    size_arr = popup_size.replace("size_", "").split("x");
176    var popup_width = size_arr[0];
177    var popup_height = size_arr[1];
178
179    try {
180        window.open(url, title, "scrollbars=yes,width=" + popup_width + ",height=" + popup_height + ",top=10,left=20");
181    } catch (e) {
182        window.open(url, "", "scrollbars=yes,width=" + popup_width + ",height=" + popup_height + ",top=10,left=20");
183    }
184}
185
186/* Layer Popup */
187function openLayerPopup() {
188    $("#layer_back, #layer_popup").show();
189}
190
191function closeLayerPopup() {
192    $("#layer_back, #layer_popup").hide();
193    $("#layer_content").html("");
194}
195
196function resizeLayerPopup(layer_width, layer_height, title) {
197    var layer_margin_top = (layer_height / 2) * (-1);
198    var layer_margin_left = (layer_width / 2) * (-1);
199    var layer_content_height = layer_height;
200
201    if (layout === "user" || layout === "staff") {
202        //layer_content_height -= 110;
203        layer_content_height -= 60;
204    } else if (layout === "front") {
205        if (title !== '입점문의') {
206            layout_content_height -= 100;
207        } else {
208            layout_content_height -= 150;
209        }
210    } else {
211        //layer_content_height -= 250;
212        layer_content_height -= 100;
213    }
214    $("#layer_popup").css({
215        width: layer_width + "px",
216        height: layer_height + "px",
217        marginTop: layer_margin_top + "px",
218        marginLeft: layer_margin_left + "px"
219    });
220    $("#layer_content").css("height", layer_content_height + "px");
221
222    // layer title
223    if (title) {
224        $("#layer_popup h1").text(title);
225    }
226}
227
228function getLayerPopupSize(class_name) {
229
230    var layer_size = "size_600x600";
231    if (class_name) {
232        var class_arr = class_name.split(" ");
233        var size_fmt = /^size_\d{3,4}x\d{3,4}$/;
234
235        for (var i = 0; i < class_arr.length; i++) {
236            if (size_fmt.test(class_arr[i])) {
237                layer_size = class_arr[i];
238                break;
239            }
240        }
241    }
242    var size_arr = layer_size.replace("size_", "").split("x");
243
244    return size_arr;
245}
246
247/* get Contents by Ajax */
248function getContentsbyAjax(obj) {
249    obj = $(obj);
250    var href = obj.attr("href");
251    var target = obj.attr("target");
252    var title = obj.attr("title");
253
254    var layer_width = 600;
255    var layer_height = 600;
256
257    if (target === "#layer_popup") {
258        var layer_size = "size_600x600";
259        var class_arr = obj.attr("class").split(" ");
260        var size_fmt = /^size_\d{3,4}x\d{3,4}$/;
261        for (var i = 0; i < class_arr.length; i++) {
262            if (size_fmt.test(class_arr[i])) {
263                layer_size = class_arr[i];
264                break;
265            }
266        }
267
268        size_arr = layer_size.replace("size_", "").split("x");
269        layer_width = size_arr[0];
270        layer_height = size_arr[1];
271    }
272
273    $.post("/ajax_error.php", {'href': href});
274
275    $.ajax({
276        url: href,
277        type: "GET",
278        dataType: "json",
279        data: "flag_json=1",
280        cache: false,
281        async: false,
282        success: function(result) {
283            if (result.code === "error") {
284                alert(result.msg);
285            } else if (result.code === "ok") {
286                if (target === "#layer_popup") {
287                    target = "#layer_content";
288
289                    // resize layer layout
290                    var layer_margin_top = (layer_height / 2) * (-1);
291                    var layer_margin_left = (layer_width / 2) * (-1);
292                    var layer_content_height = layer_height;
293
294                    if (layout === "user" || layout === "staff") {
295                        layer_content_height -= 60;
296                    } else if (layout === "front") {
297                        layer_content_height -= 100;
298                    } else {
299                        layer_content_height -= 100;
300                    }
301
302                    $("#layer_popup").css({
303                        width: layer_width + "px",
304                        height: layer_height + "px",
305                        marginTop: layer_margin_top + "px",
306                        marginLeft: layer_margin_left + "px"
307                    });
308                    $("#layer_content").css("height", layer_content_height + "px");
309
310                    // layer title
311                    if (title) {
312                        $("#layer_popup h1").text(title);
313                        $("#layer_popup h2").text(title);
314                    }
315
316                    openLayerPopup();
317                }
318
319                if (target) {
320                    insertContent($(target), result.content);
321                    // 출력할 메시지가 있으면 alert 알림창 호출 yllee 180920
322                    if (result.msg) {
323                        alert(result.msg);
324                    }
325                }
326            }
327        },
328        error: function(request, status, error) {
329            $.post("/ajax_error.php", {'code': request.status, 'message': request.responseText, 'error': error});
330            alert(msg_arr["ajax_error"]);
331            location.reload();
332        }
333    });
334}
335
336/* check placeholder */
337function checkPlaceholder(obj) {
338    var value = $(obj).val();
339    if (value) {
340        $(obj).addClass("no_placeholder");
341    } else {
342        $(obj).removeClass("no_placeholder");
343    }
344}
345
346function checkAllPlaceholder(obj) {
347    var obj_placeholder = $("input.placeholder, textarea.placeholder", $(obj));
348    for (var i = 0; i < obj_placeholder.length; i++) {
349        checkPlaceholder(obj_placeholder.eq(i));
350    }
351}
352
353/* 한글 처리 관련 : S */
354function iSound(a) {
355    var r = ((a.charCodeAt(0) - parseInt("0xac00", 16)) / 28) / 21;
356    var t = String.fromCharCode(r + parseInt("0x1100", 16));
357    return t;
358}
359
360function mSound(a) {
361    var r = ((a.charCodeAt(0) - parseInt("0xac00", 16)) / 28) % 21;
362    var t = String.fromCharCode(r + parseInt("0x1161", 16));
363    return t;
364}
365
366function tSound(a) {
367    var r = (a.charCodeAt(0) - parseInt("0xac00", 16)) % 28;
368    var t = "";
369    if (r + parseInt("0x11A8") - 1 !== 4516 && r + parseInt("0x11A8") - 1 !== 4519) {
370        var t = String.fromCharCode(r + parseInt("0x11A8") - 1);
371    }
372    return t;
373}
374
375function getLastChar(str) {
376    return tSound(str.substr(str.length - 1, 1));
377}
378/* 한글 처리 관련 : E */
379
380/* 콤마 : S */
381function setComma(str) {
382    var result = str.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
383    return result;
384}
385
386function delComma(str) {
387    var result = str;
388    try {
389        result = str.toString().replace(/,/g, "");
390    } catch (e) {
391    }
392
393    return result;
394}
395/* 콤마 : E */
396
397/**
398 * Submit Form by Ajax
399 */
400function ajaxSubmit(f, func) {
401    var f_action = f.action;
402    var f_data = $(f).serialize();
403    var f_method = f.method;
404    var f_target = f.target;
405    var f_title = f.title;
406
407    var layer_width = 0;
408    var layer_height = 0;
409
410    if (f_target === "#layer_popup") {
411        var size_arr = getLayerPopupSize($(f).attr("class"));
412        layer_width = size_arr[0];
413        layer_height = size_arr[1];
414    }
415
416    if ($(f).attr("enctype") === "multipart/form-data") {
417        $ifm = $("<iframe />");
418        $ifm.css({
419            width: "300px",
420            height: "300px"
421        }).attr({
422            id: "ajax_iframe",
423            name: "ajax_iframe"
424        }).appendTo($(f));
425
426        f.target = "ajax_iframe";
427        setTimeout(function() {
428
429            $("#ajax_iframe").on("load", function() {
430                var result = JSON.parse($("#ajax_iframe").contents().text());
431                if (result.code === "error") {
432                    alert(result.msg);
433                } else {
434                    if (f_target && result.content) {
435                        insertContent($(f_target), result.content);
436                    }
437                    if (typeof func === "function") {
438                        func(result);
439                    }
440                }
441                //$("#ajax_iframe").remove();
442            });
443            f.submit();
444            f.target = f_target;
445        }, 100);
446    } else {
447        /*
448        console.log(f_action);
449        console.log(f_data);
450        console.log(f_method);
451        console.log(f_target);
452        console.log(f_title);
453        console.log(f);
454        console.log(func);
455        */
456        $.ajax({
457            url: f_action,
458            type: f_method,
459            dataType: "json",
460            data: f_data,
461            cache: false,
462            async: false,
463            success: function(result) {
464                if (result.code === "error") {
465                    alert(result.msg);
466                } else {
467                    if (f_target && result.content) {
468                        if (f_target === "#layer_popup") {
469                            f_target = "#layer_content";
470                            resizeLayerPopup(layer_width, layer_height, f_title);
471                            openLayerPopup();
472                        }
473                        insertContent($(f_target), result.content);
474                        // 게시판 댓글 기능 & 응답 메시지 출력 yllee 190624
475                        if (f_target === "#comment_list" && result.msg) {
476                            var obj = $("div.board");
477                            //console.log(obj);
478                            //console.log(obj.height());
479                            obj.parent("div").animate({scrollTop: obj.height() + 100});
480                            obj.parent("div").parent("div").scrollTop(obj.height() + 100);
481                            alert(result.msg);
482                        }
483                    }
484                    if (typeof func === "function") {
485                        func(result);
486                    }
487                }
488            },
489            error: function(request, status, error) {
490                $.post("/ajax_error.php", {'code': request.status, 'message': request.responseText, 'error': error});
491                alert(msg_arr["ajax_error"]);
492                //console.log(request);
493            },
494            complete: function() {
495            }
496        });
497    }
498}
499
500/**
501 * Insert Content
502 */
503function insertContent(obj, content) {
504    obj.html(content);
505    initContent(obj);
506    // scrollTop
507    $(obj).scrollTop(0);
508}
509
510/* initContent */
511function initContent(obj) {
512    if (layout === "user" || layout === "staff") {
513        if (typeof initLayerSelect==='function') {
514            setTimeout(function(){
515                initLayerSelect();
516            },100);
517        }
518        return false;
519    }
520    // readonly
521    $("input.readonly", obj).prop("readonly", true);
522    $("select.readonly > option", obj).not(":selected").prop("disabled", true).trigger("change");
523
524    // uniform
525    $("select.select", obj).uniform().filter(".readonly").parent("div.selector").addClass("disabled");
526
527    // sButton
528    setButtonStyle(obj);
529
530    // datepicker
531    $.datepicker.regional["ko"] = {
532        closeText: "닫기",
533        prevText: "이전달",
534        nextText: "다음달",
535        currentText: "오늘",
536        changeMonth: true,
537        changeYear: true,
538        showButtonPanel: false,
539        yearRange: "c-99:c+99",
540        maxDate: "+" + 365 * 10 + "d",
541        minDate: "-" + 365 * 10 + "d",
542        monthNames: ["1월", "2월", "3월", "4월", "5월", "6월",
543            "7월", "8월", "9월", "10월", "11월", "12월"],
544        monthNamesShort: ["1월", "2월", "3월", "4월", "5월", "6월",
545            "7월", "8월", "9월", "10월", "11월", "12월"],
546        dayNames: ["일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일"],
547        dayNamesShort: ["일", "월", "화", "수", "목", "금", "토"],
548        dayNamesMin: ["일", "월", "화", "수", "목", "금", "토"],
549        weekHeader: "Wk",
550        dateFormat: "yy-mm-dd",
551        firstDay: 0,
552        isRTL: false,
553        showMonthAfterYear: true,
554        yearSuffix: "",
555        showOn: "button",
556        buttonImage: "/share/js/jquery-ui-1.11.1.custom/images/btn_calendar.gif",
557        buttonImageOnly: true,
558        buttonText: "Select date"
559    };
560    $.datepicker.setDefaults($.datepicker.regional["ko"]);
561
562    $("input.date", obj).datepicker();
563
564    $("input.birth").datepicker({
565        maxDate: "+" + 365 * 0 + "d",
566        minDate: "-" + 365 * 100 + "d"
567    });
568
569    // placeholder
570    checkAllPlaceholder(obj);
571}
572
573/* change quick date */
574function changeQuickDate(obj) {
575
576    var obj = $(obj);
577    var obj_a = $("a.btn_quick_date");
578
579    var sch_s_date = "";
580    var sch_e_date = "";
581    var idx = obj_a.length - 1;
582
583    var arr = obj.attr("href").split("sch_s_date=");
584
585    if (arr.length > 1) {
586        arr = arr[1].split("&sch_e_date=");
587        sch_s_date = arr[0];
588
589        arr = arr[1].split("&");
590        sch_e_date = arr[0];
591
592        idx = obj_a.index(obj);
593    }
594
595    $("#sch_s_date").val(sch_s_date).attr("value", sch_s_date);
596    $("#sch_e_date").val(sch_e_date).attr("value", sch_e_date);
597    obj_a.not(":eq(" + idx + ")").removeClass("active").end().eq(idx).addClass("active");
598    //obj_a.find(">span").not(":eq(" + idx + ")").removeClass("on").end().eq(idx).addClass("on");
599    //obj_a.parent("li").not(":eq(" + idx + ")").removeClass("on").end().eq(idx).addClass("on");
600}
601
602/**
603 * sButton
604 */
605function setButtonStyle(obj) {
606
607    /* sButton */
608    $("a.sButton, button.sButton", obj).each(function() {
609        var content = "<span class='sButton-container'><span class='sButton-bg'>";
610        if ($(this).hasClass("icon")) {
611            content += "<span class='icon'></span>";
612        }
613        content += "<span class='text'>" + $(this).text() + "</span></span></span>";
614
615        $(this).html(content);
616    });
617}
618
619/**
620 * responsive div
621 */
622function addResponsiveDiv(obj) {
623    /* sButton */
624    $("table", obj).each(function() {
625        var tmp_obj = $(this).clone();
626        $(this).after("<div class='table-responsive'></div>");
627    });
628}
629
630/**
631 * 반응형 레이아웃 (사용 안함)
632 */
633function resizeLayout() {
634    var win_width = $(window).width();
635    var device_class = "wide,normal,tablet,mobile".split(",");
636    var width_class = "1300,900,700,0".split(",");
637    var device_idx = null;
638
639    for (var i = 0; i < width_class.length; i++) {
640        if (win_width > width_class[i]) {
641            device_idx = i;
642            break;
643        }
644    }
645
646    for (var i = 0; i < width_class.length; i++) {
647        if (i == device_idx) {
648            $("body").addClass(device_class[i]);
649        } else {
650            $("body").removeClass(device_class[i]);
651        }
652    }
653}

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.