Skip to content

Commit d2f550f

Browse files
committed
Externalise @speedcurve
1 parent f25f97a commit d2f550f

File tree

2 files changed

+31
-28
lines changed

2 files changed

+31
-28
lines changed

_layouts/default.html

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -106,31 +106,4 @@
106106
}
107107
</script>
108108

109-
<script type=module>
110-
111-
(() => {
112-
// Bail out if SpeedCurve is not available.
113-
if (!window.LUX || typeof window.LUX.addData !== 'function') return;
114-
115-
const obs = window.obs || Object.create(null);
116-
117-
// Keys we intend to send. Keep in sync with obs.js
118-
const keys = [
119-
'dataSaver',
120-
'rttBucket',
121-
'rttCategory',
122-
'downlinkBucket',
123-
'downlinkMax',
124-
'batteryCritical',
125-
'batteryLow',
126-
'batteryCharging',
127-
];
128-
129-
for (const key of keys) {
130-
if (Object.prototype.hasOwnProperty.call(obs, key)) {
131-
window.LUX.addData(key, obs[key]);
132-
}
133-
}
134-
})();
135-
136-
</script>
109+
<script src=/js/speedcurve.js type=module></script>

js/speedcurve.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* All the data previously captured by Obs.js is now sent to SpeedCurve!
3+
*
4+
* I ❤️ SpeedCurve!
5+
*/
6+
7+
(() => {
8+
// Bail out if SpeedCurve is not available.
9+
if (!window.LUX || typeof window.LUX.addData !== 'function') return;
10+
11+
const obs = window.obs || Object.create(null);
12+
13+
// Keys we intend to send. Keep in sync with obs.js
14+
const keys = [
15+
'dataSaver',
16+
'rttBucket',
17+
'rttCategory',
18+
'downlinkBucket',
19+
'downlinkMax',
20+
'batteryCritical',
21+
'batteryLow',
22+
'batteryCharging',
23+
];
24+
25+
for (const key of keys) {
26+
if (Object.prototype.hasOwnProperty.call(obs, key)) {
27+
window.LUX.addData(key, obs[key]);
28+
}
29+
}
30+
})();

0 commit comments

Comments
 (0)