$(document).ready(function(){
	$(".table_id").each(function(){
		var rows = $(".table_id:contains('"+$(this).text()+"')");
		
		if(rows.length > 1){
			rows.eq(0).attr("rowspan", rows.length);
			rows.not(":eq(0)").remove();
		}
	})
	
});
	


$(document).on('click', '#addEquip', function (){
   $.ajax({
    url: '/equip/equipEditModal',
    type: 'GET',
    dataType:"html",
    success: function(html){
      $("#equipEditModalContent").empty().append(html)
      $("#equipEditModal").modal('show')
    },
    error:function(){

    }
  });
})

$(document).on('change', '#equType', function (){
	const equType = $(this).val();
	
	$.ajax({
    url: '/equip/equipTypeSelecBox',
    data: {
			equType,
			},
    type: 'GET',
    dataType:"html",
    success: function(html){
	console.log(html);
      $("#detailType").empty().append(html)
    },
    error:function(){

    }
  });
  
$(document).on('click', '#saveEquip', function (){
	if(confirm("저장하시겠습니까?")){
      let ajaxUrl = "/equip/saveEquip";
      const formData = new FormData($("#equipEditForm")[0]);
      contentFade("in");
      $.ajax({
        type : 'POST',
        data : formData,
        url : ajaxUrl,
        processData: false,
        contentType: false,
        success : function() {
            alert("저장되었습니다.");
            location.reload();
            contentFade("out");
        },
        error : function(xhr, status) {
          alert("저장에 실패하였습니다.")
          contentFade("out");
        }
      })
    }
   
})

});