Сообщение от jack3dm
|
показать только первый логин и последний логаут за день.
|
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
body {
background-color: #ccc;
}
table {
border-collapse: collapse;
}
td {
border: 1px solid black;
}
.login td{
background-color: #cfc;
}
.logout td{
background-color: orange;
}
</style>
<script>
window.addEventListener("DOMContentLoaded", function() {
var obj = {},
trs = [].slice.call(document.querySelectorAll("tr"), 0);
trs.forEach(function(tr, i) {
var td = tr.cells;
var data = td[0].textContent.split(" ")[0];
var login = !!~td[1].textContent.indexOf("Login");
if (!obj[data] && login) {
tr.classList.add("login");
obj[data] = tr
} else if (obj[data] && !login) {
obj[data].classList.remove("logout");
obj[data] = tr;
tr.classList.add("logout")
}
})
});
</script>
</head>
<body>
<table>
<tr>
<td>7/26/16 11:13:46 AM</td>
<td>Login</td>
</tr>
<tr>
<td>7/26/16 11:24:14 AM</td>
<td>Logout</td>
</tr>
<tr>
<td>7/26/16 12:24:03 PM</td>
<td>Login</td>
</tr>
<tr>
<td>7/26/16 1:19:05 PM</td>
<td>Logout</td>
</tr>
<tr>
<td>7/28/16 1:31:41 PM</td>
<td>Login</td>
</tr>
<tr>
<td>7/28/16 1:41:48 PM</td>
<td>Logout</td>
</tr>
<tr>
<td>7/28/16 3:08:14 PM</td>
<td>Login</td>
</tr>
<tr>
<td>7/28/16 3:13:21 PM</td>
<td>Logout</td>
</tr>
<tr>
<td>7/29/16 3:17:25 PM</td>
<td>Login</td>
</tr>
<tr>
<td>7/29/16 3:51:40 PM</td>
<td>Logout</td>
</tr>
</table>
</body>
</html>