var calendar_year, calendar_month; function generatecalendar(year, month){ var today = new date(); // year, month labels $("#calendar_pc_year").html(year); $("#calendar_sp_year").html(year); $("#calendar_pc_month").html(month); $("#calendar_sp_month").html(month); // contain cells for calendar var calendar_cells = []; // set date for looping var loop_date = new date(year, month - 1, 1); // empty cells to fill the row for (var i = 0; i < loop_date.getday(); i++){ calendar_cells.push(" "); } // loop for the dates while (loop_date.getmonth() == (month - 1)){ var cell_content = ""; // wednesday except'2015-2-18' if (loop_date.getday() == 2 && loop_date.getfullyear() == today.getfullyear() && loop_date.getmonth() == today.getmonth() && loop_date.getdate() == today.getdate()){ cell_content += ""; } else if (loop_date.getday() == 2 && ((loop_date.getfullyear() + '-' + (loop_date.getmonth()+1) + '-' + loop_date.getdate()) != '2015-2-18')){ cell_content += ""; } else if (loop_date.getfullyear() == today.getfullyear() && loop_date.getmonth() == today.getmonth() && loop_date.getdate() == today.getdate()){ cell_content += ""; } else { cell_content += ""; } //if(cell_content==''){//鎴戝姞鐨?涓轰簡闃叉涓や釜鑺傛棩鍦ㄤ竴璧?瀵艰嚧鍗曞厓鏍兼媺闀垮彉涓? // 2, 20 cell_content += loop_date.getdate() == 20 || loop_date.getdate() == 30 ? "" : ""; // 5, 15,25 cell_content += loop_date.getdate() == 5 || loop_date.getdate() == 15 || loop_date.getdate() == 25 ? "" : ""; // 11 cell_content += loop_date.getdate() == 11 ? "" : ""; // special dates /*cell_content += "";*/ // } // date cell_content += loop_date.getdate(); // close tags cell_content += ""; calendar_cells.push(cell_content); loop_date.setdate(loop_date.getdate() + 1); } // empty cells to fill the last row for (var i = loop_date.getday(); i <= 6; i++){ calendar_cells.push(" "); } // group the td var trs = ""; for (var i = 0; i < calendar_cells.length; i++){ // new tr if one week is finished if (i != 0 && i % 7 == 0){ trs += ""; } trs += calendar_cells[i]; } trs += ""; // update the table $('#currcalendar').html(trs); // $(".calendar_sp .calendar_table tbody").html('a'); $(".calendar_sp td a, .calendar_sp .thickbox_slide").on("click",function(){ $(".thickbox_sp").slidedown(400); var baseurl = $(this).attr("href"); $("#calendar_sp").remove(); $(".thickbox_sp").append("
"); return false; }) // apply thickbox //tb_init('a.thickbox, area.thickbox, input.thickbox'); } function calendarprevmonth(){ var d = new date(calendar_year, calendar_month - 2, 1); calendar_year = d.getfullyear(); calendar_month = d.getmonth() + 1; generatecalendar(calendar_year, calendar_month); } function calendarnextmonth(){ var d = new date(calendar_year, calendar_month, 1); calendar_year = d.getfullyear(); calendar_month = d.getmonth() + 1; generatecalendar(calendar_year, calendar_month); } $(document).ready(function(){ });