增加作业倒计时显示

This commit is contained in:
sw 2014-11-18 16:00:04 +08:00
parent 2de2355e5c
commit d0e549fc85
1 changed files with 24 additions and 5 deletions

View File

@ -1,4 +1,23 @@
<!--modified by huang-->
<script type="text/javascript">
function ShowCountDown(year,month,day,divname)
{
var now = new Date();
var endDate = new Date(year, month-1, day);
var leftTime=endDate.getTime()-now.getTime();
var leftsecond = parseInt(leftTime/1000);
var day1=Math.floor(leftsecond/(60*60*24));
var hour=Math.floor((leftsecond-day1*24*60*60)/3600);
var minute=Math.floor((leftsecond-day1*24*60*60-hour*3600)/60);
var second=Math.floor(leftsecond-day1*24*60*60-hour*3600-minute*60);
$("#"+divname).html("<span style='color: #acaeb1;'>作业提交还剩&nbsp;:</span>&nbsp;<span style='color: red;'>"
+day1+"&nbsp;</span><span style='color: #acaeb1;'>天</span><span style='color: red;'>&nbsp;"
+hour+"&nbsp;</span><span style='color: #acaeb1;'>时</span><span style='color: red;'>&nbsp;"
+minute+"&nbsp;</span><span style='color: #acaeb1;'>分</span><span style='color: red;'>&nbsp;"
+second+"&nbsp;</span><span style='color: #acaeb1;'>秒</span>");
}
</script>
<% if bids.blank? %>
<%#= l(:label_uncommit_homework) %>
暂无作业!
@ -100,11 +119,11 @@
<%= l(:label_commit_limit)%>
</span>
<% else %>
<% if betweentime(bid.deadline) < 3 %>
<span style="color: red">
<%= l(:label_commit_ar) %>
</span>
<% end %>
<script type="text/javascript">
window.setInterval(function(){ShowCountDown(<%= bid.deadline.year%>,<%= bid.deadline.month%>,<%= bid.deadline.day + 1%>,"show_deadtime_span_<%= bid.id%>");},1000)
</script>
<span id="show_deadtime_span_<%= bid.id%>" style="float: right">
</span>
<% end %>
</span>
</td>