山东科技大学校历 代码分析 获得以前学期学年的老版校历

校历-山东科技大学网络安全与信息化办公室http://tech.sdust.edu.cn/wlfw/xl.htm        

JavaScript


var studyStart = new Date(2021, 8-1, 30);//8-1 -1没有意义,30代表30号,2021年8月30号开始这个学期
var commonWeeks = 19;//这个学期有多少周
var smallWeeks = 0;
var vocationWeeks = 6;//寒暑假有多少周

var start = new Date(studyStart.toUTCString());
start.add("d", -28);

var studyWeeks = commonWeeks + smallWeeks;
var totalWeeks = studyWeeks + vocationWeeks;

var div = $("#NavContainer");
var html = '<table border="0" cellspacing="0" cellpadding="0" align="center"><tr class="nav"><td>周次</td><td>一</td><td>二</td><td>三</td><td>四</td><td>五</td><td>六</td><td>日</td></tr>';
var lastStyle = "m2";
var now = new Date();
now.setHours(0, 0, 0, 0);
var type = start.getMonth() > 5 ? "寒":"暑";
var monthChanged = true;
var i = -1;
while (i<totalWeeks) {
    
    var weekStart = new Date(start.toUTCString());
    weekStart.add("d", 7);
    //alert(weekStart.toString());
    var isCurrentWeek = (now>=start && now<weekStart);
    var vocation = studyWeeks < (i+1);
    html += "<tr class=\"" + (studyWeeks < (i+1) ? "vocation" : "") + 
        "\"><td class=\"weekCount "+ (isCurrentWeek ? "weekCurrent" : "" ) + 
        "\">" + (vocation ? type + (i+1-studyWeeks) : (i>-1?i+1:'')) + "</td>";
    
    for(j=0; j<7; j++) {
        var d = start.getDate();
        var firstStyle = "";
        if (d<2) {
            lastStyle = lastStyle=="m1"?"m2":"m1";
            firstStyle = "firstDay";
            monthChanged = 1; 
            d = "1/" + "<strong>" + (start.getMonth() + 1) + "</strong>";
        }
        html += "<td class=\"" + 
            lastStyle + " " + 
            (isCurrentWeek ? "dayCurrentWeek" : "") + " " +
            "\"><div class=\""+ 
            (now > start ? "pastDate" : "") + " " +
            firstStyle + " " + 
            (!(now < start) && !(now > start) ? "today" : "") + " " +
            (j>4 || vocation? "vocation" : "") + " " +
            "\">" + d + "</div>" + "</td>";
        start.add("d", 1);
    }
    html += monthChanged ? "<td rowspan='2' class=\"month\">" + (start.getMonth()==0?start.getFullYear()+'<br />':'') + GetMonthName(start.getMonth() + 1) + "月</td>" : "<td></td>";
    monthChanged = false;
    html += "</tr>";
    
    if (start>=studyStart) {
        i++;
    }
}
html += "</table>";
//alert(html);
div.html(html).css("opacity", 1);
// $(".pastDate").css("opacity", 0.3);
 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值