span,
input {
vertical-align: middle;
}
.boxTop {
width: 96%;
height: 48px;
margin: auto;
line-height: 48px;
font-size: 18px;
border: 1px solid grey;
margin-top: 30px;
}
.boxTop div {
float: left;
text-align: center;
}
.boxTop .lastMonth {
width: 30%;
cursor: pointer;
color: blue;
}
.boxTop .lastMonth:hover {
color: red;
}
.boxTop .nowDate {
width: 40%;
}
.boxTop .nextMonth {
width: 30%;
cursor: pointer;
color: blue;
}
.boxTop .nextMonth:hover {
color: red;
}
.boxBottom {
width: 96%;
margin: auto;
text-align: center;
border-collapse: collapse;
line-height: 32px;
}
table,
table tr th,
table tr td {
border: 1px solid grey;
border-top: none;
font-weight: bold;
}
table tr td {
width: 14%;
}
.boxBottom .dLeft {
float: left;
height: 88px;
width: 29%;
border-right: 1px dashed #6E6E6E;
}
.boxBottom .dLeft .p1 {
margin: auto;
font-size: 15px;
height: 40px;
line-height: 40px;
margin-top: 5px;
margin-bottom: 5px;
}
.boxBottom .dLeft .p2 {
margin: auto;
font-size: 13px;
height: 24px;
line-height: 24px;
}
.boxBottom .dRight {
float: left;
height: 88px;
width: 66%;
padding: 0 2%;
text-align: left;
font-size: 10px;
cursor: pointer;
overflow: hidden;
text-overflow: ellipsis;
line-height: 21px;
white-space: pre;
color: #EB1C27;
}
.today {
color: #fff;
max-width: 40px;
border-radius: 40px;
background-color: #23C092;
}
var today; //获取当前日期
$(function() {
GetCreateDate(0);
});
function GetCreateDate(index) {
if(index == 0) {
today = new Date(); //获取当前日期
} else {
today = new Date(today.setMonth(today.getMonth() + index));
}
var i, k;
var y = today.getFullYear(); //获取日期中的年份
var m = today.getMonth(); //获取日期中的月份(需要注意的是:月份是从0开始计算,获取的值比正常月份的值少1)
var d = today.getDate(); //获取日期中的日(方便在建立日期表格时高亮显示当天)
var firstday = new Date(y, m, 1); //获取当月的第一天
var dayOfWeek = firstday.getDay(); //判断第一天是星期几(返回[0-6]中的一个,0代表星期天,1代表星期一,以此类推)
var days_per_month = new Array(31, 28 + isLeap(y), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); //创建月份数组
var str_nums = Math.ceil((dayOfWeek + days_per_month[m]) / 7); //确定日期表格所需的行数
var nowDateStr = '' + y + '年' + (m + 1) + '月';
$('.nowDate').html(nowDateStr);
var html = '';
for(i = 0; i < str_nums; i += 1) { //二维数组创建日期表格
html += '
';for(k = 0; k < 7; k++) {
var idx = 7 * i + k; //为每个表格创建索引,从0开始
var date = idx - dayOfWeek + 1; //将当月的1号与星期进行匹配
(date <= 0 || date > days_per_month[m]) ? date = '': date = idx - dayOfWeek + 1; //索引小于等于0或者大于月份最大值就用空表格代替
if(date == '') {
html += '
' + date + '';} else {
var lunar = calendar.solar2lunar(y, (m + 1), date);
html += '
'
' + date + '
' +'
' + (lunar.IDayCn == '初一' ? lunar.IMonthCn : lunar.IDayCn) + '
'
'; //高亮显示当天}
}
html += '
';}
$('#tDate').html(html);
var startDay = y + '-' + (m + 1) + '-' + '1';
var endDay = y + '-' + (m + 1) + '-' + days_per_month[m];
LoadContent(startDay, endDay);
}
//判断当前年份是否是闰年(闰年2月份有29天,平年2月份只有28天)
function isLeap(year) {
return year % 4 == 0 ? (year % 100 != 0 ? 1 : (year % 400 == 0 ? 1 : 0)) : 0;
}
function LoadContent(startDay, endDay) {
console.log(startDay + '--------->' + endDay);
}
function SetContent(obj) {
//alert($(obj).attr('ymd'));
layer.prompt({
title: '活动备录',
value: $(obj).html(),
formType: 2
}, function(text, index) {
var lines = text.split("\n");
var flag = false;
for (var i = 0; i < lines.length; i++) {
if (lines[i].length > 15) {
flag = true;
}
}
if (flag) {
alert('每行文字限制15字以内!');
return;
}
layer.close(index);
$(obj).html(text);
});
}
< 上一月
周日周一周二周三周四周五周六
一键复制
编辑
Web IDE
原始数据
按行查看
历史