-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdashboard-api-example.html
32 lines (24 loc) · 1.08 KB
/
dashboard-api-example.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
<script type="text/javascript">
// FILL IN THE SESSION ID BELOW
const SESSION_ID = ''; // received after login
let dashboardUrl = 'https://api.blaulichtsms.net/blaulicht/api/alarm/v1/dashboard/' + SESSION_ID;
const displayParticipationMessage = function (dashboardJSON) {
const dashboard = JSON.parse(dashboardJSON);
dashboard.alarms.forEach(function (alarm) {
alarm.recipients.forEach(function (recipient) {
document.write(recipient.name + ' ' + recipient.participation + ' ' + recipient.participationMessage + '<br>');
});
document.write('<hr>');
});
};
const loadDashboard = function (url, callback) {
const xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
callback(xmlHttp.responseText);
};
xmlHttp.open("GET", url, true); // true for asynchronous
xmlHttp.send(null);
};
loadDashboard(dashboardUrl, displayParticipationMessage);
</script>