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.