묻고답하기
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
ret_obj 걸려있는 함수를 분리해서 핵심만 반복 실행 하는 법
2017.09.14 02:34
설명이 길거같은데 일단 스킨의 js 파일에 해당 부분 함수 두개만 추출하여 아래에 넣어 놨습니다.
우선 setCurrentCalendar 함수는 잘 모르겠지만 어딘가에 숨겨져서 호출 되는거 같은데,
다른 스킨 js파일에서 호출되는건 getCurrentDay 이더라구요.
제가 하고자하는건 setCurrentCalendar에서 '전체마감' 이라는 키워드가 있는 부분을 별도로 분리해서
총 31번을 반복 실행 시키려고 합니다.
근데 getCurrentDay를 반복 실행시키려하니깐 여러 충돌이 나네요. setCurrentCalendar 자체에 단순 실행이 아닌
소스 생성이 다 포함되어있다보니..
근데 setCurrentCalendar 를 별로도 실행 하려하니 setCurrentCalendar(ret_obj)를 해줘야하는데
이부분은 잘 모르겠습니다...
질문 정리 : setCurrentCalendar에서 '전체마감' 이라는 키워드가 있는 부분을 별도로 분리해서 함수를 만든뒤 다른 함수에서
반복해서 호출하고 싶습니다.
function getCurrentDay(srl, year, month, day, module_srl, week) { var week = String(week); // var room_boy = jQuery('.room_boy_'+srl+' option:selected').val(); // var room_girl = jQuery('.room_girl_'+srl+' option:selected').val(); // var currentYear = jQuery('.currentYear').text(); // var currentMonth = jQuery('.currentMonth').text(); // var currentDate = jQuery('.currentDate').text(); var currentYear = year; var currentMonth = month; var currentDate = day; t_day = day var week = week; if(month<10){ month='0'+month } //day = leadingZeros(day,2); var params = new Array(); params['module_srl'] = module_srl; // params['room_boy'] = room_boy; // params['room_girl'] = room_girl; params['current_year'] = currentYear; params['current_month'] = currentMonth; params['current_date'] = currentDate; params['week'] = week; var response_tags = new Array('error','message','selected_info'); exec_xml('reservation', 'getCurrentDay', params, setCurrentCalendar, response_tags); jQuery('#kCalendar table td').removeClass('selected'); jQuery('.'+day).addClass('selected'); jQuery('.currentYear').text(year); jQuery('.currentMonth').text(leadingZeros(month,2)); jQuery('.currentDate').text(leadingZeros(day,2)); } function setCurrentCalendar(ret_obj){ var total_rs=0; var res_mg = 0; var rsrl; //alert(ret_obj[selected_info]); if(ret_obj['message']!='success') { jQuery('a.modalAnchor').trigger('close.mw'); } var selected_info = ret_obj['selected_info']; var room_info=''; jQuery('.room_info tbody tr').remove(); var res_money; var items = selected_info.data.item; if(!selected_info.data.item[0]) items = selected_info.data; if(selected_info.sale) { var sales = selected_info.sale; if(selected_info.sale.item[0]) sales = selected_info.sale.item; } jQuery.each(items, function(index, val) { var add_money = ''; var moneyNoformat; var yesdateLang =''; if(val.res_bigyesmoney){ moneyNoformat = val.res_bigyesmoney; res_money = val.res_bigyesmoney.format(); yesdateLang = "극성수기 "+val.revDays+" "; }else if(val.res_yesmoney){ moneyNoformat = val.res_yesmoney; res_money = val.res_yesmoney.format(); yesdateLang = "성수기 "+val.revDays+" "; }else{ moneyNoformat = val.res_nomoney; res_money = val.res_nomoney.format(); yesdateLang ="비수기 "+val.revDays+" "; } jQuery('.yesdateLang').html(yesdateLang); if(val.room_count2 == 0){ var selt = ''; }else{ var selt = '선택'; } if(val.reser_block == 1){ if(val.room_count2 <= 0){ var reser_block = '<span id="rmg'+val.reservation_srl+'" class="bed'+val.reservation_srl+'" value="0" style="color:red">예약 마감</span>'; var rmc_img = 'style="display:none"'; }else{ var reser_block = '<p style="margin:0 0 5px 0;" class="bed'+val.reservation_srl+'">객실수 : <select name="room"><option value="0">선택</option>'; for(var i =1; i <= val.room_count2; i++){ reser_block += '<option value="'+i+'">'+i+'개</option>'; } reser_block += '</select></p>'; if(val.add_member > 0){ reser_block += '<p style="margin:0px" class="bed_add'+val.reservation_srl+'">추가인원 : <select name="plusMan"><option value="0">없음</option>'; for(var i =1; i <= val.add_member/* * val.room_count2*/; i++){ reser_block += '<option value="'+i+'">'+i+'명</option>'; } reser_block += '</select></p>'; } //add_money = "<span class='cuga'>추가금액 : "+val.add_money.format()+"원</span>"; } } else{ var reser_block = '<div class="b'+val.reservation_srl+'"><p class="sb'+val.reservation_srl+'" style="margin:0 0 5px 0;"></p><p style="margin:0px"class="sg'+val.reservation_srl+'"></p></div>' if(val.room_count2 <= 0){ rmc_img = 'style="display:none"'; } } var title = "'"+val.title+"'"; //room_info = '<tr class="'+val.reservation_srl+'"><td><a style="cursor: pointer;color:#0088cc" " data-toggle="modal" data-target="#myModal" onClick="getRoomInfo('+val.document_srl+', '+val.module_srl+')">'+val.title+'</a></td><td>'+reser_block+'</td><td>'+res_money+' 원 <br>'+add_money+'</td><td><div class="my-select"></div></td><td><a class="room_chk room_chk_'+val.reservation_srl+''+val.current_year+''+val.current_month+''+val.current_date+'" value="'+val.reservation_srl+'" onclick="doSelectReservation('+val.reservation_srl+', '+val.current_year+','+val.current_month+','+val.current_date+','+val.module_srl+','+title+')">'+selt+'</a></td></tr><input type="hidden" id="money_'+val.reservation_srl+'" value="'+moneyNoformat+'"/>'; room_info = '<tr class="'+val.reservation_srl+'"><td><a style="cursor: pointer;color:#0088cc" " data-toggle="modal" data-target="#myModal" onClick="getRoomInfo('+val.document_srl+', '+val.module_srl+');">'+val.title+'</a></td><td id="r'+val.reservation_srl+'">'+reser_block+'</td><td>'+res_money+' 원 <br>'+add_money+'</td><td><div id="my-select'+val.reservation_srl+'" class="my-select"></div></td><td><a '+rmc_img+' class="room_chk room_chk_'+val.reservation_srl+''+val.current_year+''+val.current_month+''+val.current_date+'" value="'+val.reservation_srl+'" onclick="doSelectReservation('+val.reservation_srl+', '+val.current_year+','+val.current_month+','+val.current_date+','+val.module_srl+','+title+')"><img src="/modules/reservation/skins/default/img/roomchk.png"></a></td></tr>'; jQuery('.room_info tbody').append(room_info); if(val.room_count2 <= 0){ jQuery('.b'+val.reservation_srl).html('<span id="rmg'+val.reservation_srl+'" value="0" style="color:red">예약 마감</span>'); }else{ if(val.sex_block == 0){ var manCnt = val.select_number-val.room_countMan; var womanCnt = val.select_number-val.room_countWoman; var womanMinus = 0; var manMinus = 0; if(manCnt > 0){ var manRoomPercent = manCnt/val.main_member; manRoomPercent = Math.ceil(manRoomPercent); womanMinus = manRoomPercent * val.main_member; } val.room_countWoman -= womanMinus; if(womanCnt > 0){ var manRoomPercent = womanCnt/val.main_member; manRoomPercent = Math.ceil(manRoomPercent); manMinus = manRoomPercent * val.main_member; } val.room_countMan -= manMinus; if(val.room_countMan > 0) jQuery('.sb'+val.reservation_srl).html('남 : <select class="room_boy_'+val.reservation_srl+'"><select>'); for(var i=0;i<=val.room_countMan;i++){ if(i == 0){ var opt = '<option value="0">선택</option>'; }else{ var opt = '<option value="'+i+'">'+i+'명</option>'; } jQuery('.room_boy_'+val.reservation_srl+'').append(opt); } if(val.room_countWoman > 0) jQuery('.sg'+val.reservation_srl).html(' 여 : <select class="room_girl_'+val.reservation_srl+'"><select>'); for(var i=0;i<=val.room_countWoman;i++){ if(i == 0){ var opt = '<option value="0">선택</option>'; }else{ var opt = '<option value="'+i+'">'+i+'명</option>'; } jQuery('.room_girl_'+val.reservation_srl+'').append(opt); } if(val.room_countWoman <= 0 && val.room_countman <= 0){ jQuery('.b'+val.reservation_srl).html('<span id="rmg'+val.reservation_srl+'" value="0" style="color:red">예약 마감</span>'); } } if(val.sex_block == 1){ jQuery('.sb'+val.reservation_srl).html('남 : <select class="room_boy_'+val.reservation_srl+'"><select>'); for(var i=0;i<=val.room_count2;i++){ if(i == 0){ var opt = '<option value="0">선택</option>'; }else{ var opt = '<option value="'+i+'">'+i+'명</option>'; } jQuery('.room_boy_'+val.reservation_srl+'').append(opt); } } if(val.sex_block == 2){ jQuery('.sg'+val.reservation_srl).html(' 여 : <select class="room_girl_'+val.reservation_srl+'"><select>'); for(var i=0;i<=val.room_count2;i++){ if(i == 0){ var opt = '<option value="0">선택</option>'; }else{ var opt = '<option value="'+i+'">'+i+'명</option>'; } jQuery('.room_girl_'+val.reservation_srl+'').append(opt); } } } rsrl = val.reservation_srl; }); if(selected_info.sale) { var sales = selected_info.sale; if(selected_info.sale.item[0]) sales = selected_info.sale.item; for(var j=1;j<=rsrl;j++){ res_mg = document.getElementById('r'+j).innerHTML.indexOf("예약 마감"); if(res_mg == -1){ jQuery.each(sales, function(index2, val2) { iHtml = '<div class="checkbox"><label><input type="checkbox" name="sale_chk[]" class="sale_chk" value="'+val2.sale_srl+'"> '+val2.title+'</label></div>'; jQuery('#my-select'+j).append(iHtml); }); }else{ total_rs++; } } if(total_rs == rsrl){ //alert(t_day); //alert("전체마감" + total_rs + " / " + rsrl); document.getElementById("magam"+t_day).innerHTML = "마감"; } } // jQuery('.rs tbody').append(roomHtml); var cck = jQuery('.cck').text(); var res = cck.split("-"); if(res){ for (var i = 0; i < res.length; i++) { var res2 = res[i]; jQuery('.room_chk_'+res2).text(''); } } }