-
Notifications
You must be signed in to change notification settings - Fork 1
/
dev_getBasicData_CREST2.html
45 lines (38 loc) · 1.77 KB
/
dev_getBasicData_CREST2.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
<html>
<head>
<script src="./config.js" charset="utf-8"></script>
<script type="text/javascript">
function RequestData(URL){
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", URL, false);
xmlhttp.send(null);
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
var myArr = JSON.parse( xmlhttp.responseText );
var strData = "";
// output complete Shared Memory data to browser developer console
console.log(myArr);
// Show basic data
strData = "Trackname for Refpoint: \"" + myArr.eventInformation.mTrackLocation + " " + myArr.eventInformation.mTrackVariation + "\"" +
"<br>Trackname for GUI - Name/Variation: \"" + myArr.eventInformation.mTranslatedTrackLocation + "\" / \"" + myArr.eventInformation.mTranslatedTrackVariation + "\"" +
"<br>Car: \"" + myArr.vehicleInformation.mCarName + "\"" +
"<br>Car Class: \"" + myArr.vehicleInformation.mCarClassName + "\"" +
"<br><br>All Participant Cars:<br>";
for (var i = 0;i<myArr.participants.mNumParticipants;i++) {
strData = strData + i + " - Car: \"" + myArr.participants.mParticipantInfo[i].mCarNames + "\" / Car Class: \"" + myArr.participants.mParticipantInfo[i].mCarClassNames + "\"<br>";
}
document.getElementById("data").innerHTML = strData;
}
}
</script>
</head>
<body>
<p id="request"></p>
<p id="data"></p>
<script type="text/javascript">
// Built polling URL using CREST2 URL and Port from config
var URL = "http://" + CREST2ServerURL + ":" + CREST2Port + "/crest2/v1/api";
//Request Link
document.getElementById("request").innerHTML = "<a href=\"#\" onClick=\"RequestData('" + URL + "');\">Request</a>";
</script>
</body>
</html>