-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
202 lines (173 loc) · 7.94 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
<py-env>
- pandas
- altair
</py-env>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<!-- Font Awesome -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet" />
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet" />
<link href='https://fonts.googleapis.com/css?family=Rock+Salt' rel='stylesheet' type='text/css'>
<!-- MDB -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/mdb-ui-kit/4.3.0/mdb.dark.min.css" rel="stylesheet" />
<link href="style.css" rel="stylesheet" type="text/css">
<title>Tracking Runs 🏃 with MiBand (MiFit)</title>
</head>
<body>
<div class="container">
<h2>Tracking Runs 🏃 <small class="text-muted text-sm">with MiBand (MiFit)</small></h2>
<div class="d-flex align-items-center">
<a class="btn btn-danger me-3" href="https://youtu.be/3mfqTGs05cE" target="_blank">
<i class="fab fa-youtube"></i>
Watch how I build this
</a>
<a
class="btn btn-dark px-3"
href="https://github.com/onlyphantom/miband"
role="button"
><i class="fab fa-github"></i
></a>
</div>
<hr class="divider-horizontal-blurry" />
<h4>Key Statistics <i class="fas fa-person-running"></i></h4>
<p class="text-muted">
<i class="fas fa-calendar-days mr-2"></i>
<small id="from"></small>
<i class="fas fa-arrow-right mx-2"></i>
<small id="to"></small>
</p>
<div id="topstats" class="row">
<div class="col-xl-3 col-sm-6 col-12 mb-4">
<div class="card">
<div class="card-body">
<div class="d-flex justify-content-between px-md-1">
<div class="align-self-center">
<i class="fas fa-stopwatch-20 text-info fa-3x"></i>
</div>
<div class="text-end">
<h5 id="total_num_runs"></h5>
<p class="mb-0">Total Num. of Runs</p>
</div>
</div>
</div>
</div>
</div>
<div class="col-xl-3 col-sm-6 col-12 mb-4">
<div class="card">
<div class="card-body">
<div class="d-flex justify-content-between px-md-1">
<div class="align-self-center">
<!-- <i class="fas fa-map-signs text-danger fa-3x"></i> -->
<i class="fas fa-person-walking text-danger fa-3x"></i>
</div>
<div class="text-end">
<h5 id="walk_dist"></h5>
<p class="mb-0">Walk Distance (km)</p>
</div>
</div>
</div>
</div>
</div>
<div class="col-xl-3 col-sm-6 col-12 mb-4">
<div class="card">
<div class="card-body">
<div class="d-flex justify-content-between px-md-1">
<div class="align-self-center">
<i class="fas fa-person-running text-warning fa-3x"></i>
</div>
<div class="text-end">
<h5 id="run_dist"></h5>
<p class="mb-0">Run Distance (km)</p>
</div>
</div>
</div>
</div>
</div>
<div class="col-xl-3 col-sm-6 col-12 mb-4">
<div class="card">
<div class="card-body">
<div class="d-flex justify-content-between px-md-1">
<div class="align-self-center">
<i class="fa-solid fa-flag-checkered text-success fa-2x"></i>
</div>
<div class="text-end">
<h5 id="run_walk_dist"></h5>
<p class="mb-0">Walk + Run Dist. (km)</p>
</div>
</div>
</div>
</div>
</div>
</div>
<hr class="divider-horizontal-blurry" />
<h4>Notable Runs <i class="fas fa-table"></i></h4>
<!-- if you rather pass in json and parse it in js, you can use
https://mdbootstrap.com/docs/standard/plugins/data-parser/ -->
<div id="notable" class="table-responsive"></div>
<hr class="divider-horizontal-blurry" />
<h4>Trends <i class="fas fa-arrow-trend-up"></i></h4>
<div id="dashboard" class="text-center"></div>
</div>
<py-script output="notable" src="./scripts/getstats.py">
</py-script>
<py-script output="dashboard" src="./scripts/dashboard.py">
</py-script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.14.7/dist/umd/popper.min.js"
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/js/bootstrap.min.js"
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
crossorigin="anonymous"></script>
<!-- MDB -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mdb-ui-kit/4.3.0/mdb.min.js"></script>
<script>
function waitForElm(selector) {
return new Promise(resolve => {
if (document.querySelector(selector)) {
return resolve(document.querySelector(selector));
}
const observer = new MutationObserver(() => {
if (document.querySelector(selector)) {
resolve(document.querySelector(selector));
observer.disconnect();
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
});
}
waitForElm('#notable-3').then((elm) => {
console.log('Notable3 is ready');
// hide #notable-3
elm.style.display = 'none';
var stats = JSON.parse(elm.textContent)
// mount stats to global variable on windows
// window.stats = stats;
console.log(stats);
$(document).ready(function () {
$('#total_num_runs').text(stats[0]);
$('#walk_dist').text(stats[1]);
$('#run_dist').text(stats[2]);
$('#run_walk_dist').text(stats[3]);
$('#from').text(stats[4][0]);
$('#to').text(stats[4][1]);
});
});
</script>
</body>
</html>