-
Notifications
You must be signed in to change notification settings - Fork 19
/
wakatime-status-board.php
99 lines (77 loc) · 1.73 KB
/
wakatime-status-board.php
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
<?php header("refresh: 900;"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<style type="text/css">
body, * {
}
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td {
margin: 0;
padding: 0;
}
fieldset,img {
border: 0;
}
/* Settin up the page */
html, body, #main {
overflow: hidden;
}
body {
font-size: 24px;
line-height: 28px;
}
tr {
height: 32px;
}
td {
font-size: 28px;
line-height: 32px;
text-align: center;
}
body, html, #main {
background: transparent !important;
}
h2 {
color: #7e7e7e;
font-size: 30px;
line-height: 18px;
margin: 0px auto;
padding-top: 20px;
text-align: center;
text-transform: uppercase;
}
</style>
<title></title>
</head>
<body>
<h2>Wakatime Projects</h2>
<table>
<tr>
<th>Project</th>
<th>Recorded Time</th>
</tr>
<?php
function secondsToTime($seconds) {
$dtF = new DateTime("@0");
$dtT = new DateTime("@$seconds");
return $dtF->diff($dtT)->format('%h:%i:%s');
}
$apikey = "a5e2dca9-b9b7-41b5-80b4-32774b2ca724";
$contents = file_get_contents('https://wakatime.com/api/v1/users/current/stats/last_7_days?api_key='.$apikey);
$wakatime_api = json_decode($contents);
$projects = $wakatime_api->data->projects;
if (count($projects)) {
// Cycle through the array
foreach ($projects as $idx => $project) {
$time = secondsToTime($project->total_seconds);
// Output a row
echo "<tr>";
echo "<td>$project->name</td>";
echo "<td>$time</td>";
echo "</tr>";
}
}
?>
</table>
</body>
</html>