-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
69 lines (65 loc) · 2.45 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<script src="./jquery.js"></script>
<title>BunnyTime</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style> /*easy table styling*/
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 40%;
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
tr:nth-child(even) {
background-color: #dddddd;
}
</style>
</head>
<body>
<h1>Bunny Table</h1>
<div>
<table>
<thead>
<tr>
<th>Zeitstempel</th>
<th>Aktion</th>
</tr>
</thead>
<tbody id="tablebody">
</tbody>
</table>
</div>
<script>
$(document).ready(function () {
$.get("./sth/file.txt", function (data) { //insert path to your .txt.
var stringArray = data.split("\n").reverse(); //reverse to show latest entry.
console.log(stringArray); //test purpose only.
var bdy = $('#tablebody');
bdy.html("");
$.each(stringArray, function (index, value) {
var akt = value.substring(20, 21); //substring for action
var dat = value.substring(0, 19); // and timestamp.
switch (akt) { //the cases are strings, so they are set in "".
case "0":
akt = "Stall cleaned";
break;
case "4":
akt = "Beasts treated";
break;
case "5":
akt = "Beasts feeded";
break;
}
bdy.append("<tr><td>" + dat + "</td><td>" + akt + "</td></tr>"); //.append to display in table
});
});
});
</script>
</body>
</html>