$(document).ready(function(){ // 페이징 처리 $("#btnPageFirst, #btnPagePrevious, #btnPageNext, #btnPageLast, a[name='btnPageMove']").click(function(){ var intPage = $(this).attr('strA'); if (parseInt(intPage) > 0){ $('#intPage').val(intPage); $("#theForm").attr("action","/html/?pmode="+$('#pmode').val()+"&smode=list&page="+intPage); $("#theForm").submit(); } }); // 리스트 페이지로 이동 $('#btnList').click(function(){ $(location).attr("href","/html/?pmode="+$('#pmode').val()+"&smode=list"); }); // 뷰페이지로 이동 $('#btnView').click(function(){ if ($('#mode').val()=="modify"){ $("#writeForm").attr("action","/html/?pmode="+$('#pmode').val()+"&smode=view&seq="+$('#seq').val()); $("#writeForm").submit(); }else{ $("#rewriteForm").attr("action","/html/?pmode="+$('#pmode').val()+"&smode=view&seq="+$('#seq').val()); $("#rewriteForm").submit(); } }); /************************************ 리스트 ************************************/ // 글쓰기 페이지로 이동 $('#btnWrite').click(function(){ if ($(this).attr('strA')=="ok"){ $('#seq').val(''); $("#theForm").attr("action","/html/?pmode="+$('#pmode').val()+"&smode=write"); $("#theForm").submit(); }else{ if ($(this).attr('bitSession')==""){ alert("로그인 후 이용해 주세요."); return false; }else{ alert("접속권한이 없습니다."); return false; } } }); // 제목 링크 (게시글 보기) $("a[name*='linkView']").click(function(){ var readAuth = $(this).attr('strAuth'); // 권한관련 var bitSession = $(this).attr('bitSession'); // 로그인 여부 var secretAuth = $(this).attr('strSecret'); // 비밀글 관련 $('#mode').val('view'); $("#seq").val($(this).attr('strA')); if (readAuth=="ok"){ if (secretAuth=="ok"){ $("#theForm").attr("action","/html/?pmode="+$('#pmode').val()+"&smode=view&seq="+$(this).attr('strA')); $("#theForm").submit(); }else if (secretAuth=="no"){ alert("열람권한이 없습니다."); return false; //$('#theForm').attr("action","/html/?pmode="+$('#pmode').val()+"&smode=pwd&seq="+$(this).attr('strA')); //$('#theForm').submit(); }else if (secretAuth=="none"){ alert("열람권한이 없습니다."); return false; } }else if (readAuth=="no"){ if (bitSession==""){ alert("로그인 후 이용해 주세요."); }else{ alert("열람권한이 없습니다."); } return false; } }); $("a[name*='linkWrite']").click(function(){ var writeAuth = $(this).attr('strAuth'); // 권한관련 var bitSession = $(this).attr('bitSession'); // 로그인 여부 var secretAuth = $(this).attr('strSecret'); $('#mode').val('view'); $("#seq").val($(this).attr('strA')); if (writeAuth=="ok"){ if (secretAuth=="ok"){ $("#theForm").attr("action","/html/?pmode="+$('#pmode').val()+"&smode=write&seq="+$(this).attr('strA')); $("#theForm").submit(); }else if (secretAuth=="no"){ //$('#theForm').attr("action","/html/?pmode="+$('#pmode').val()+"&smode=pwd&seq="+$(this).attr('strA')); //$('#theForm').submit(); alert("열람권한이 없습니다."); return false; }else if (secretAuth=="none"){ alert("접속권한이 없습니다."); return false; } }else if (writeAuth=="no"){ if (bitSession==""){ alert("로그인 후 이용해 주세요."); }else{ alert("접속권한이 없습니다."); } return false; } }); // 페이지 크기 $("#intPageSize").change(function(){ $("#theForm").attr("action","/html/?pmode="+$('#pmode').val()+"&smode=list"); $("#theForm").submit(); }); // 게시글 검색 $("#btnSearch").click(function(){ $("#theForm").attr("action","/html/?pmode="+$('#pmode').val()+"&smode=list"); $("#theForm").submit(); }); // 선택삭제 $('#btnSelRemove').click(function(){ if ($("input[name*='chk']:checked").length==0){ alert("삭제할 게시물을 선택해주세요."); return false; } $("#mode").val("selremove"); var theForm = $("#theForm").serialize(); if (confirm("선택하신 게시물을 삭제하시겠습니까?")){ $('#loading').css("display",""); $.ajax({type: "GET", url: "/html/board/board.proc.php", data: theForm, dataType: "html", success: function(responseText){ $('#loading').css("display","none"); //alert(responseText); return false; if (responseText == "SUCCESS01"){ alert("정상적으로 처리되었습니다."); location.reload(); }else{ alert("데이터 처리중 오류가 발생하였습니다."); return false; } }, error: function(response){alert('error\n\n' + response.responseText); return false;} }); } }); /************************************ 글쓰기 ************************************/ // 글저장 $('#btnWriteSave').click(function(){ ckeditorInIt(); if (doWebFormCheck() == true){ chkCtext($('#strContent').val()); /* // 확장필드 체크 if (arrExtForm.config.length != 0){ for (var i = 0; i < arrExtForm.config.length; i++) { if (arrExtForm.config[i].use == "1" && arrExtForm.config[i].required == "1"){ if (doBoardAddFieldCheck(arrExtForm.config[i].formtype, arrExtForm.config[i].field, arrExtForm.config[i].message) == false){ return false; } } } } */ // 자동등록방지 if ($('#authCaptcha').val()=="filter"){ if ($('#writekey') != 'undefined'){ if (hex_md5($('#writekey').val()) != md5_norobot_key) { alert('자동등록방지용 글자가 제대로 입력되지 않았습니다.'); $('#writekey').select().focus(); return false; } } } /* // 확장필드 값 재할당 if (arrExtForm.config.length != 0){ for (var i = 0; i < arrExtForm.config.length; i++) { if (arrExtForm.config[i].use == "1"){ doBoardAddFieldInput(arrExtForm.config[i].field, arrExtForm.config[i].field + "_", arrExtForm.config[i].formtype); } } } */ //alert($('#strAddData1_').val()); return false; $("#btnWriteSave").css("display", "none"); $('#loading').css("display",""); $("#writeForm").ajaxSubmit({ success: function(responseText){ $('#loading').css("display","none"); //alert(responseText);console.log(responseText); return false; if (responseText == "SUCCESS01"){ alert("정상적으로 처리되었습니다."); if ($('#mode').val()=="insert" || $('#mode').val()=="sinsert" || $('#mode').val()=="rewrite"){ location.href="/html/?pmode="+$('#pmode').val()+"&smode=list"; }else if ($('#mode').val()=="modify" || $('#mode').val()=="smodify"){ $("#writeForm").attr("action","/html/?pmode="+$('#pmode').val()+"&smode=list&seq="+$('#seq').val()); $("#writeForm").submit(); } }else if (responseText == "replyOver"){ alert("답변글의 그룹은 10개까지만 가능합니다."); return false; }else if (responseText == "ERROR"){ alert("데이터 처리중 오류가 발생하였습니다."); return false; }else if (responseText == "NOMATCH"){ alert("비밀번호가 일치하지 않습니다."); return false; }else if (responseText.substring(0, 15)=="FILEUPLOAD-FAIL"){ // 파일업로드 실패 alert(responseText.split('|||')[1]); return false; }else{ alert("데이터 처리중 오류가 발생하였습니다. 관리자에게 문의해 주세요."); return false; } }, error:function(response){alert('error\n\n' + response.responseText);}, type: 'post', url: '/html/board/board.proc.php'}); return false; }else{ return false; } }); // 답글저장 $('#btnReWriteSave').click(function(){ ckeditorInIt(); if (doWebFormCheck() == true){ chkCtext($('#strContent').val()); /* // 확장필드 체크 if (arrExtForm.config.length != 0){ for (var i = 0; i < arrExtForm.config.length; i++) { if (arrExtForm.config[i].use == "1" && arrExtForm.config[i].required == "1"){ if (doBoardAddFieldCheck(arrExtForm.config[i].formtype, arrExtForm.config[i].field, arrExtForm.config[i].message) == false){ return false; } } } } */ // 자동등록방지 if ($('#authCaptcha').val()=="filter"){ if ($('#writekey') != 'undefined'){ if (hex_md5($('#writekey').val()) != md5_norobot_key) { alert('자동등록방지용 글자가 제대로 입력되지 않았습니다.'); $('#writekey').select().focus(); return false; } } } /* // 확장필드 값 재할당 if (arrExtForm.config.length != 0){ for (var i = 0; i < arrExtForm.config.length; i++) { if (arrExtForm.config[i].use == "1"){ doBoardAddFieldInput(arrExtForm.config[i].field, arrExtForm.config[i].field + "_", arrExtForm.config[i].formtype); } } } */ //alert($('#strAddData1_').val()); return false; $('#loading').css("display",""); $("#rewriteForm").ajaxSubmit({ success: function(responseText){ $('#loading').css("display","none"); //alert(responseText); return false; if (responseText == "SUCCESS01"){ alert("정상적으로 처리되었습니다."); location.href="/html/?pmode="+$('#pmode').val()+"&smode=list"; }else if (responseText == "ERROR01"){ alert("데이터 처리중 오류가 발생하였습니다."); return false; }else if (responseText.substring(0, 15)=="FILEUPLOAD-FAIL"){ // 파일업로드 실패 alert(responseText.split('|||')[1]); return false; }else{ alert("데이터 처리중 오류가 발생하였습니다. 관리자에게 문의해 주세요."); return false; } }, error:function(response){alert('error\n\n' + response.responseText);}, type: 'post', url: '/html/board/board.proc.php'}); return false; }else{ return false; } }); // 파일 삭제 $('#btnFileFieldRemove').click(function(){ if ($('#intMemberSrl').val()=="" || $(this).attr('strA')=="none"){ // 비회원이거나 로그인한 회원이 관리자가 아닌 경우... if ($('#strPassword').val()==""){ alert("비밀번호를 입력해 주세요."); $('#strPassword').focus(); return false; } } if($("input:checkbox[name*='strFileDel']:checked").length < 1) { alert("삭제할 파일을 선택하세요"); return; } if (confirm("선택하신 파일을 삭제하시겠습니까?")){ var arrFileSeq = "0"; $("input[name*='strFileDel']").each(function(){ if ($(this)[0].checked){ arrFileSeq += ","+$(this).val(); } }); $('#arrFileSeq').val(arrFileSeq); $('#mode').val('fileremove'); var theForm = $("#writeForm").serialize(); $('#loading').css("display",""); $.ajax({type: "POST", url: "/html/board/board.proc.php", data: theForm, dataType: "html", success: function(responseText){ $('#loading').css("display","none"); //alert(responseText); return false; if (responseText == "SUCCESS01"){ alert("정상적으로 처리되었습니다.."); location.reload(); }else if (responseText == "NOMATCH"){ alert("비밀번호가 일치하지 않습니다."); return false; }else{ alert("데이터 처리중 오류가 발생하였습니다."); return false; } }, error: function(response){alert('error\n\n' + response.responseText); return false;} }); }else{ return false; } }); /************************************ 글보기 ************************************/ // 게시글 이동 $("#btnMove").click(function(){ if ($(this).attr('strA')=="0"){ window.open("/html/board/board.move.pop.php?pmode=" + $("#pmode").val() + "&seq=" + $("#seq").val(), "boardArticleMove", "width=400,height=160"); }else{ alert("답변 게시물은 이동할 수 없습니다.\n\n원문의 글을 이동시키면 답글도 함께 이동됩니다."); return false; } }); // 파일 다운로드 $("a[name='btnFileDownload']").click(function(){ var downloadAuth = $(this).attr('strAuth'); if (downloadAuth=="ok"){ $('#intFseq').val($(this).attr('strA')); if ($('#mode').val()=="insert" || $('#mode').val()=="modify"){ $('#writeForm').attr("action","/html/board/board.file.download.php?pmode="+$('#pmode').val()); $('#writeForm').submit(); }else{ $('#theForm').attr("action","/html/board/board.file.download.php?pmode="+$('#pmode').val()); $('#theForm').submit(); } }else{ alert("다운로드권한이 없습니다."); return false; } }); // 게시글 답변 $('#btnRewrite').click(function(){ $("#theForm").attr("action","/html/?pmode="+$('#pmode').val()+"&smode=rewrite&seq="+$('#seq').val()); $("#theForm").submit(); }); // 게시글 수정 $('#btnModify').click(function() { var pod = $(this).attr('strA'); // 비번 필요없이 삭제 가능여부 $('#mode').val('modify'); if (pod=="ok") { $('#theForm').attr("action", "/html/?pmode=" + $('#pmode').val() + "&smode=write&seq=" + $('#seq').val()); $('#theForm').submit(); } else { $('#theForm').attr("action", "/html/?pmode=" + $('#pmode').val() + "&smode=pwd&seq=" + $('#seq').val()); $('#theForm').submit(); } }); // 게시글 삭제 $('#btnDelete').on("click", function(){ var pod = $(this).attr('strA'); // 비번 필요없이 삭제 가능여부 $('#mode').val('remove'); if (pod=="ok"){ if (confirm("본 게시물을 삭제하시겠습니까?")){ $('#loading').css("display",""); $("#theForm").ajaxSubmit({type: "POST", url: "/html/board/board.proc.php", dataType: "html", success: function(responseText){ $('#loading').css("display","none"); //alert(responseText); console.log(responseText); return false; if (responseText == "SUCCESS01"){ alert("정상적으로 처리되었습니다."); location.href="/html/?pmode="+$('#pmode').val()+"&smode=list"; }else{ alert("데이터 처리중 오류가 발생하였습니다."); return false; } }, error: function(response){alert('error\n\n' + response.responseText); return false;} }); }else{ return false; } }else{ // 비번이 필요하다.. $('#theForm').attr("action","/html/?pmode="+$('#pmode').val()+"&smode=pwd"); $('#theForm').submit(); } }); // 게시글 삭제 비회원(비밀번호 입력) $("#btnPwdRemove").on("click", function() { $('#mode').val('pwdremove'); if (confirm("본 게시물을 삭제하시겠습니까?")){ $('#loading').css("display",""); $("#theForm").ajaxSubmit({type: "POST", url: "/html/board/board.proc.php", dataType: "html", success: function(responseText){ $('#loading').css("display","none"); //alert(responseText); console.log(responseText); return false; if (responseText == "SUCCESS01") { alert("정상적으로 처리되었습니다."); location.href = "/html/?pmode=" + $('#pmode').val() + "&smode=list"; } else if(responseText == "100") { alert("비밀번호를 입력해주십시오."); return false; } else if(responseText == "200") { alert("비밀번호를 정확히 입력해주십시오"); return false; } else { alert("데이터 처리중 오류가 발생하였습니다."); return false; } }, error: function(response){alert('error\n\n' + response.responseText); return false;} }); }else{ return false; } }); // 게시글 비밀글 $('#btnBoardPwdProc').click(function(){ if ($('#strBoardPwd').val()==""){ alert("비밀번호를 입력해 주세요."); $('#strBoardPwd').focus(); return false; } $('#loading').css("display",""); $("#theForm").ajaxSubmit({type: "POST", url: "/html/board/board.proc.php", dataType: "html", success: function(responseText){ $('#loading').css("display","none"); //alert(responseText); return false; if (responseText == "SUCCESS01"){ var mode = $("#mode").val(); $("#strPwdAuth").val('ok'); // 비번 확인이 완료 되었는지 상태. // form에 smode textBox가 있어서 get으로 넘어간 smode를 인식 안함. 그래서 직접 넣어줌. // smode로 비번확인을 함. if(mode == 'view') { $('#smode').val('view'); $("#theForm").attr("action", "/html/?pmode=" + $('#pmode').val() + "&smode=view&seq=" + $('#seq').val()); $("#theForm").submit(); } else if(mode == 'modify') { $('#smode').val('write'); $("#theForm").attr("action", "/html/?pmode=" + $('#pmode').val() + "&smode=write&seq=" + $('#seq').val()); $("#theForm").submit(); } else if(mode == 'remove') { if (confirm("본 게시물을 삭제하시겠습니까?")){ $('#smode').val('remove'); $('#loading').css("display",""); $('#theForm').ajaxSubmit({type: "POST", url: "/html/board/board.proc.php", dataType: "html", success: function(responseText){ $('#loading').css("display","none"); //alert(responseText); return false; if (responseText == "SUCCESS01"){ alert("정상적으로 처리되었습니다."); location.href="/html/?pmode="+$('#pmode').val()+"&smode=list"; }else{ alert("데이터 처리중 오류가 발생하였습니다."); return false; } }, error: function(response){alert('error\n\n' + response.responseText); return false;} }); } } }else if (responseText == "NOMATCH"){ alert("비밀번호가 일치하지 않습니다."); return false; }else{ alert("데이터 처리중 오류가 발생하였습니다."); return false; } }, error: function(response){alert('error\n\n' + response.responseText); return false;} }); }); // 비밀번호 페이지에서 뷰 페이지로 이동하기.. $('#btnPwdToView').click(function(){ $("#theForm").attr("action","/html/?pmode="+$('#pmode').val()+"&smode=view&seq="+$('#seq').val()); $("#theForm").submit(); }); // 주소검색 $("#btnZip").click(function(){ window.open('/html/?pmode=zipcode&mode=board','주소검색','scrollbars=yes,width=450,height=550'); }); //schedule/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $("a[name*='linkYear']").click(function(){ $('#intSyear').val($(this).attr('strA')); $("#theForm").submit(); }); $("a[name*='linkMonth']").click(function(){ $('#intSmonth').val($(this).attr('strA')); $("#theForm").submit(); }); $("a[name*='linkDay']").click(function(){ var readAuth = $(this).attr('strAuth'); // 권한관련 var readAuthUrl = $(this).attr('strAuthUrl'); // 권한관련 이동페이지 var secretAuth = $(this).attr('strSecret'); // 비밀글 관련 if (readAuth=="ok"){ $('#mode').val('view'); if (secretAuth=="ok"){ $("#theForm").attr("action","/html/?pmode="+$('#pmode').val()+"&smode=view&seq="+$(this).attr('strA')); $("#theForm").submit(); }else if (secretAuth=="no"){ $("#theForm").attr("action","/html/?pmode="+$('#pmode').val()+"&smode=pwd&seq="+$(this).attr('strA')); $('#theForm').submit(); }else if (secretAuth=="none"){ alert("접근권한이 없습니다."); return false; } }else if (readAuth=="no"){ alert("접근권한이 없습니다."); if (readAuthUrl=="return"){ return false; }else{ location.href = readAuthUrl; } } }); $(".board-title").click(function () { $(".board-title").removeClass("active"); $(".board-content").slideUp("normal"); if ($(this).next().is(":hidden") == true) { $(this).addClass("active"); $(this).next().slideDown("normal"); } }); $(".board-content").hide(); }); var fileCount = 0; // 파일 필드 카운트 // 파일 필드 추가 function addFileField(){ var objTbl = document.all["variableFiles"]; var objRow = objTbl.insertRow(objTbl.rows.length); var objCell = objRow.insertCell(0); objCell.innerHTML = ""; fileCount++; } // 파일 필드 제거 function delFileField(fileLength){ //alert(fileLength); // fileLength 이하로는 필드가 삭제되지 않도록 한다. var objTbl = document.all["variableFiles"]; if (objTbl.rows.length - 1 > fileLength){ objTbl.deleteRow(objTbl.rows.length - 1); fileCount--; } } // 확장필드 타입에 따른 체크 function doBoardAddFieldCheck(formType, field, message){ switch (formType){ case "text" : case "textarea" : if ($("#" + field).val().replace(/\s/g, "").length == 0){ alert(message); $("#" + field).focus(); return false; } break; case "email" : if ($("#" + field).val().replace(/\s/g, "").length == 0){ alert(message); $("#" + field).focus(); return false; } if (cValidator.email($("#" + field).val()) == false){ alert(message); $("#" + field).focus(); return false; } break; case "tel" : case "corpnum" : if ($("#" + field + "1").val().length == 0){ alert(message); $("#" + field + "1").focus(); return false; } if (cValidator.number($("#" + field + "1").val()) == false){ alert(message); $("#" + field + "1").focus(); return false; } if ($("#" + field + "2").val().length == 0){ alert(message); $("#" + field + "2").focus(); return false; } if (cValidator.number($("#" + field + "2").val()) == false){ alert(message); $("#" + field + "2").focus(); return false; } if ($("#" + field + "3").val().length == 0){ alert(message); $("#" + field + "3").focus(); return false; } if (cValidator.number($("#" + field + "3").val()) == false){ alert(message); $("#" + field + "3").focus(); return false; } break; case "checkbox" : if ($("input[name*=" + field + "]:checked").length == 0){ alert(message);$("input[name=" + field + "]")[0].focus();return false; } break; case "radio" : if ($("input[name=" + field + "]:checked").length == 0){ alert(message);$("#" + field).focus();return false; } break; case "select" : if ($("#" + field).val() == 0){ alert(message);$("#" + field).focus();return false; } break; case "addr" : if ($("#address_list_" + field + " option").length == 0){ alert(message);$("#krzip_address1_" + field).focus();return false; } if ($("#krzip_address2_" + field).val().length == 0){ alert(message);$("#krzip_address2_" + field).focus();return false; } break; case "date" : if ($("#" + field).val().length == 0){ alert(message);$("#" + field).focus();return false; } break; } return true; } // 확장필드 값 셋팅 function doBoardAddFieldInput(obj1, obj2, fieldtype){ switch (fieldtype){ case "text" : $("#" + obj2).val($("#" + obj1).val()); break; case "email" : $("#" + obj2).val($("#" + obj1).val()); break; case "date" : $("#" + obj2).val($("#" + obj1).val()); break; case "tel" : $("#" + obj2).val($("#" + obj1 + "1").val() + "-" + $("#" + obj1 + "2").val() + "-" + $("#" + obj1 + "3").val()); break; case "corpnum" : $("#" + obj2).val($("#" + obj1 + "1").val() + "-" + $("#" + obj1 + "2").val() + "-" + $("#" + obj1 + "3").val()); break; case "textarea" : $("#" + obj2).val($("#" + obj1).val()); break; case "checkbox" : $("#" + obj2).val(""); var obj2chkval = ""; $("input[name*=" + obj1 + "]").each(function(index){ if( $("input[name*=" + obj1 + "]:eq("+index+")").attr("checked") ){ obj2chkval += "$$$" + $(this).val(); } }); $("#" + obj2).val(obj2chkval); break; case "select" : $("#" + obj2).val($("#" + obj1).val()); break; case "radio" : $("#" + obj2).val($("input[name=" + obj1 + "]:checked").val()); break; case "addr" : if ($("#address_list1_" + obj1).val() != "" && $("#address_list1_" + obj1).val()!= null) $("#" + obj2).val($("#address_list1_" + obj1).val() + "$$$" + $("#address_list2_" + obj1).val()); break; } } function chkCtext(ctext){ var str = ""; if (ctext.indexOf("/pds/userfiles/images/") > 0){ var tmpCimg = ctext.split("/pds/userfiles/images/")[1]; $('#strListImg').val(tmpCimg.split('"')[0]); str = "ok"; }else{ str = "alert"; } return str; } function ckeditorInIt(){ for (instance in CKEDITOR.instances) { CKEDITOR.instances[instance].updateElement(); } } function answer_show(no) { if ($('#answer_'+no).css("display")=="none"){ for (var i = 1; i <= 100 ; i++ ){ $('#answer_'+i).css("display","none"); } $('#answer_'+no).css("display",""); }else{ $('#answer_'+no).css("display","none"); } }