1 line
1.4 KiB
JavaScript
1 line
1.4 KiB
JavaScript
function init_life_time(){function e(){let e=+new Date,r=new Date((new Date).toLocaleDateString()).getTime(),s=(e-r)/1e3/60/60,t=s/24*100;$("#dayProgress .date-text span").html(parseInt(s)),$("#dayProgress .progress .progress-bar").css("width",parseInt(t)+"%"),$("#dayProgress .progress .progress-bar").html(parseInt(t)+"%");let o={0:7,1:1,2:2,3:3,4:4,5:5,6:6},a=o[(new Date).getDay()],l=a/7*100;$("#weekProgress .date-text span").html(a),$("#weekProgress .progress .progress-bar").css("width",parseInt(l)+"%"),$("#weekProgress .progress .progress-bar").html(parseInt(l)+"%");let g=(new Date).getFullYear(),n=(new Date).getDate(),h=(new Date).getMonth()+1,p=new Date(g,h,0).getDate(),i=n/p*100;$("#monthProgress .date-text span").html(n),$("#monthProgress .progress .progress-bar").css("width",parseInt(i)+"%"),$("#monthProgress .progress .progress-bar").html(parseInt(i)+"%");let w=h/12*100;$("#yearProgress .date-text span").html(h),$("#yearProgress .progress .progress-bar").css("width",parseInt(w)+"%"),$("#yearProgress .progress .progress-bar").html(parseInt(w)+"%")}e(),setInterval(()=>{e()},1e3)}if(init_life_time(),now=new Date,hour=now.getHours(),hour<6)var hello="凌晨好";else if(hour<9)hello="早上好";else if(hour<12)hello="上午好";else if(hour<14)hello="中午好";else if(hour<17)hello="下午好";else if(hour<19)hello="傍晚好";else if(hour<22)hello="晚上好";else hello="夜深了"; |