203 lines
5.6 KiB
JavaScript
203 lines
5.6 KiB
JavaScript
|
|
|
|
$("#jqueryBtn").click(function(){
|
|
$(".quiz-text").text("Javascript");
|
|
$(".quiz-text").css('color', 'blue');
|
|
});
|
|
|
|
|
|
$(document).on('click', '#addMajorBtn', function (){
|
|
getEditModal(null)
|
|
})
|
|
|
|
$(document).on('click', '.tr', function (){
|
|
$(".trChkBox").prop("checked", false);
|
|
$(this).find(".trChkBox").prop("checked", true);
|
|
getViewModal(Number($(this).find(".majorKey").val()));
|
|
})
|
|
|
|
// $(document).on('click', '.tr', function (event){
|
|
// const target = event.target;
|
|
// if(!(target.className === "cpChk" ||$(target).parents("td").length>0)){
|
|
// const phoneKey = (Number($(this).find(".phoneKey").val()));
|
|
// showModal(phoneKey);
|
|
// }
|
|
// });
|
|
|
|
$(document).on('click', '#saveBtn', function (){
|
|
saveContent("MajorEditForm")
|
|
})
|
|
|
|
$(document).on('click', '#editBtn', function (){
|
|
$("#MajorViewModal").modal('hide')
|
|
getEditModal($(this).attr("data-majorkey"));
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
$(function(){
|
|
$("#dateSelectorDiv").datepicker({
|
|
format: "yyyy-mm-dd",
|
|
language: "ko",
|
|
autoclose: true
|
|
});
|
|
})
|
|
|
|
|
|
$(document).on('click', '#deleteMajorBtn', function (){
|
|
const majorKey = $('input[name=majorKey]').val();
|
|
console.log(majorKey);
|
|
if(confirm("삭제하시겠습니까?")){
|
|
//contentFade("in");
|
|
$.ajax({
|
|
type : 'POST',
|
|
url : "/ivsgt/deleteContent",
|
|
data : JSON.stringify({majorKey:majorKey}),
|
|
contentType: 'application/json',
|
|
beforeSend: function (xhr){
|
|
xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val());
|
|
},
|
|
success : function(data) {
|
|
alert("삭제 처리되었습니다.");
|
|
//contentFade("out");
|
|
location.reload();
|
|
},
|
|
error : function(xhr, status) {
|
|
alert("삭제 처리에 실패하였습니다");
|
|
//contentFade("out");
|
|
}
|
|
})
|
|
}
|
|
})
|
|
|
|
// $(document).on('click', '#delectMajorBtn', function (){
|
|
// if(confirm("선택한 대상을 삭제처리 하시겠습니까?")){
|
|
// const checkArr = [];
|
|
// $('input:checkbox[name=equChk]:checked').each(function (idx, el){
|
|
// checkArr.push({});
|
|
// const target = $(el);
|
|
// checkArr[idx].equKey = Number(target.parents('tr').find('.majorKey').val());
|
|
// })
|
|
// deleteMajor(checkArr);
|
|
//
|
|
// }
|
|
// })
|
|
|
|
// function deleteMajor(checkArr){
|
|
// $.ajax({
|
|
// type : 'POST',
|
|
// url : "/ivsgt/deleteContent",
|
|
// data : JSON.stringify(checkArr),
|
|
// contentType: 'application/json',
|
|
// beforeSend: function (xhr){
|
|
// xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val());
|
|
// },
|
|
// success : function() {
|
|
// alert("삭제처리 되었습니다.");
|
|
// location.reload();
|
|
// },
|
|
// error : function(xhr, status) {
|
|
// alert("삭제처리에 실패하였습니다");
|
|
// }
|
|
// })
|
|
// }
|
|
|
|
function getEditModal(majorKey){
|
|
$.ajax({
|
|
url: '/ivsgt/majorEditModal',
|
|
data: {majorKey: majorKey},
|
|
type: 'GET',
|
|
dataType:"html",
|
|
success: function(html){
|
|
$("#editContent").empty().append(html);
|
|
setUploadDiv();
|
|
setEditor('editor', '570');
|
|
$("#MajorEditModal").modal('show');
|
|
|
|
},
|
|
error:function(){
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
function getViewModal(majorKey){
|
|
$.ajax({
|
|
url: '/ivsgt/majorViewModal',
|
|
data: {majorKey: majorKey},
|
|
type: 'GET',
|
|
dataType:"html",
|
|
success: function(html){
|
|
$("#viewContent").empty().append(html)
|
|
$("#MajorViewModal").modal('show');
|
|
},
|
|
error:function(){
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
function saveContent(contentStatus){
|
|
if(confirm("저장하시겠습니까?")){
|
|
let flag = true;
|
|
if(contentStatus === "DST007"){
|
|
flag = contentCheck();
|
|
}
|
|
if(flag){
|
|
contentFade("in");
|
|
const MajorEditForm = $("#MajorEditForm");
|
|
MajorEditForm.find("contentStatus").val(contentStatus);
|
|
const formData = new FormData(MajorEditForm[0]);
|
|
for(const file of files) {
|
|
if(!file.isDelete)
|
|
formData.append('uploadFiles', file, file.name);
|
|
}
|
|
$(".text-decoration-line-through").each(function (idx, el){
|
|
formData.append('fileSeq', $(el).attr("data-fileseq"));
|
|
})
|
|
formData.append('contentInfo', CrossEditor.GetBodyValue());
|
|
$.ajax({
|
|
type : 'POST',
|
|
data : formData,
|
|
url : "/ivsgt/saveContent",
|
|
processData: false,
|
|
contentType: false,
|
|
success : function(result) {
|
|
alert("저장되었습니다.");
|
|
contentFade("out");
|
|
$("#MajorEditModal").modal('hide');
|
|
getViewModal(result);
|
|
},
|
|
error : function(xhr, status) {
|
|
alert("저장에 실패하였습니다.")
|
|
contentFade("out");
|
|
}
|
|
})
|
|
}
|
|
}
|
|
}
|
|
|
|
function contentCheck(formId){
|
|
let flag = true;
|
|
if(!$("#contentTitle").val()){
|
|
alert("제목을 입력해주세요.")
|
|
flag = false;
|
|
}
|
|
|
|
flag = fileCheck(flag, files);
|
|
return flag;
|
|
}
|
|
|
|
function commentFormReset(){
|
|
const commentForm = $("#commentForm");
|
|
commentForm[0].reset();
|
|
$("#childFormRemoveBtn").hide();
|
|
$("#parentComment").val('');
|
|
$("#commentFormHome").append(commentForm)
|
|
}
|
|
|
|
|
|
|