52 lines
1.2 KiB
JavaScript
52 lines
1.2 KiB
JavaScript
let curDate = new Date();
|
|
|
|
function printDate(date) {
|
|
return date.getFullYear() + "年" + (date.getMonth() + 1) + "月" + date.getDate() + "日";
|
|
}
|
|
|
|
function render() {
|
|
$("#date").text(printDate(curDate));
|
|
const daysAfter = (curDate - groupStartDate) / 86400000;
|
|
$("#group").text("值日生房间号:" + ((daysAfter % 5) * 2 + 1) + "、" + ((daysAfter % 5) * 2 + 2));
|
|
let projects = "项目:";
|
|
let first = true;
|
|
project.forEach((x, _) => {
|
|
const daysAfter = (curDate - x.startDate) / 86400000;
|
|
if (daysAfter % x.interval === 0) {
|
|
if (!first) {
|
|
projects += "、";
|
|
}
|
|
first = false;
|
|
projects += x.name;
|
|
}
|
|
});
|
|
if (projects.length === 3) {
|
|
projects += "无";
|
|
}
|
|
$("#content").text(projects);
|
|
}
|
|
|
|
$(document).ready(() => {
|
|
$("#prev").click(() => {
|
|
curDate = new Date(curDate.getTime() - 86400000);
|
|
render();
|
|
});
|
|
|
|
$("#next").click(() => {
|
|
curDate = new Date(curDate.getTime() + 86400000);
|
|
render();
|
|
});
|
|
|
|
$("#datepicker").datepicker({
|
|
showOtherMonths: true,
|
|
selectOtherMonths: true
|
|
});
|
|
$("#datepicker").change(function() {
|
|
curDate = new Date($(this).val());
|
|
render();
|
|
});
|
|
|
|
curDate = new Date();
|
|
curDate.setHours(0, 0, 0, 0);
|
|
render();
|
|
}); |