优雅转身

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  65 随笔 :: 0 文章 :: 25 评论 :: 34万 阅读
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<%@page import="com.util.SessionUtil"%>
<%@page import="com.util.Pagination"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.List"%>
<%@page import="com.util.DbUtil"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="../js/js.js"></script>
<style type="text/css">
<!--
body {
    margin-left: 3px;
    margin-top: 0px;
    margin-right: 3px;
    margin-bottom: 0px;
}
.STYLE1 {
    color: #e1e2e3;
    font-size: 12px;
}
.STYLE6 {color: #000000; font-size: 12; }
.STYLE10 {color: #000000; font-size: 12px; }
.STYLE19 {
    color: #344b50;
    font-size: 12px;
}
.STYLE21 {
    font-size: 12px;
    color: #3b6375;
}
.STYLE22 {
    font-size: 12px;
    color: #295568;
}
-->
</style>
<script type="text/javascript">
    function add() {
        window.location.href = "course_add.jsp";
    }
</script>
</head>
<%
    String sid = SessionUtil.getUserInfo(request, response).getId();
    String role = SessionUtil.getUserInfo(request, response).getRole();
%>
<body>
<button onclick="start()">签到</button>
<button onclick="end()">签退</button>
<select id="courseselect">
    <option value="">请选择课程。。。</option>
    <option value="数学">数学</option>
    <option value="英语">英语</option>
    <option value="语文">语文</option>
    <option value="政治">政治</option>
</select>
<form action="StuKaoQinServlet?method=add" method="post" name="form" id="form">
    <input type="hidden" id="account" name="account" value="${userInfo.account }"/>
    <input type="hidden" id="course" name="course"/>
    <input type="hidden" id="startTime" name="startTime"/>
    <input type="hidden" id="endTime" name="endTime"/>
    <input type="hidden" id="longTime" name="longTime"/>
</form>
<div>
<span>当前时间:</span><span id="timer"></span>
<span style="margin-left: 50px;">上课时间:</span><span id="timer2"></span>
</div>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="24" bgcolor="#353c44"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="6%" height="19" valign="bottom"><div align="center"><img src="../images/tb.gif" width="14" height="14" /></div></td>
                <td width="94%" valign="bottom"><span class="STYLE1"> 基本信息列表</span></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td>
    <form name="form" id="form">
    <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#a8c7ce">
      <tr>
        <td height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">编号</span></div></td>
        <td height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">学生</span></div></td>
        <td height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">课程名称</span></div></td>
        <td height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">签到时间</span></div></td>
        <td height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">签退时间</span></div></td>
        <td height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">时长</span></div></td>
      </tr>
     <%
        String sql = "select * from t_stu_kaoqin";
        List<Map<String, Object>> list = DbUtil.find(sql);
        Map<String, Object> map = null;
        for (int i = 0; i < list.size(); i++) {
            map = (Map<String, Object>)list.get(i);
    %>
      <tr>
        <td height="20" bgcolor="#FFFFFF" class="STYLE6"><div align="center"><span class="STYLE19"><%=map.get("id") %></span></div></td>
        <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center"><%=map.get("account") %></div></td>
        <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center"><%=map.get("course") %></div></td>
        <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center"><%=map.get("startTime") %></div></td>
        <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center"><%=map.get("endTime") %></div></td>
        <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center"><%=map.get("longTime") %></div></td>
      </tr>
   <%
    }
   %>
    </table>
    </form>
    </td>
  </tr>
</table>
<script type="text/javascript">
var time = 0;
var sh;
var flag = false;
function start() {
     
    var obj=document.getElementById('courseselect');
    var index=obj.selectedIndex; //序号,取当前选中选项的序号
    var courseval = obj.options[index].value;
    if(!courseval) {
        alert('请选择课程');
        return;
    }
    document.getElementById('startTime').value = getnow();
    document.getElementById('course').value = courseval;
    setInterval(function(){
        flag = true;
        var now = new Date();
        var year = now.getFullYear(); //得到年份
        var month = now.getMonth() + 1;//得到月份
        var date = now.getDate();//得到日期
        // var day = now.getDay();//得到周几
        var hour = now.getHours();//得到小时数
        var minute = now.getMinutes();//得到分钟数
        var second = now.getSeconds();//得到秒数
        var html = year + "年" + month + "月" + date + "日 " + hour + "时"
                + minute + "分" + second + "秒";
        document.getElementById('timer').innerHTML=html;
         
        /*vm.datetime = html;
        vm.username = localStorage.getItem("username");
         if(lem) {
            $("#username").html("").append(lem)
        } else {
            $("#username").html("");
        } */
    },1000)
     
    sh=setInterval(function(){
        time=time+1;
        document.getElementById('timer2').innerHTML= formatSecond(time);
    },1000)
}
 
function end() {
    flag = false;
    document.getElementById('endTime').value = getnow();
    document.getElementById('longTime').value = formatSecond(time);;
    clearInterval(sh);
    document.getElementById("form").submit();
}
 
function getnow() {
    var now = new Date();
    var year = now.getFullYear(); //得到年份
    var month = now.getMonth() + 1;//得到月份
    var date = now.getDate();//得到日期
    // var day = now.getDay();//得到周几
    var hour = now.getHours();//得到小时数
    var minute = now.getMinutes();//得到分钟数
    var second = now.getSeconds();//得到秒数
    var html = year + "年" + month + "月" + date + "日 " + hour + "时"
            + minute + "分" + second + "秒";
    return html;
}
 
 
function formatSecond(second) {
    const days = Math.floor(second / 86400);
    const hours = Math.floor((second % 86400) / 3600);
    const minutes = Math.floor(((second % 86400) % 3600) / 60);
    const seconds = Math.floor(((second % 86400) % 3600) % 60);
    const forMatDate = {
      days: days,
      hours: hours,
      minutes: minutes,
      seconds: seconds
    };
    return forMatDate.hours + " 时 " + forMatDate.minutes + " 分 " + forMatDate.seconds + " 秒" ;
  }
 
</script>
</body>
</html>

  

posted on   优雅转身  阅读(41)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
点击右上角即可分享
微信分享提示