Skip to content

Commit e67b77c

Browse files
author
xss
committed
add query
1 parent 5666b00 commit e67b77c

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,14 @@ <h2><i class="icon-car rfloat"></i>Chase Mode</h2>
268268
<div id="prediction_settingsbox" style="display: none" class="flatpage">
269269
<div class="slimContainer">
270270
<h2>Prediction Settings</h2>
271-
Only use this tab if your the operator of a balloon launch.
271+
<p id="prediction_settings_message">
272+
Login to configure per-payload flight path prediction parameters.
273+
</p>
272274
<hr>
273275
<div id="update-flightdocs" style="display: none">
274276
<form action="javascript:;">
275277
Callsign (case sensitive):<br /> <input id="flight_doc_payload_callsign" type="text"><br />
278+
<button type="button" onclick="query_flight_doc()">Query</button><br />
276279
Peak altitude:<br /> <input id="flight_doc_peak_altitude" type="text"><br />
277280
Descent rate:<br /> <input id="flight_doc_descent_rate" type="text"><br />
278281
Ascent rate:<br /> <input id="flight_doc_ascent_rate" type="text"><br />

js/flight_doc.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,31 @@ AWS.config.credentials.get(function(){
2727
document.getElementById("login_url").innerText = "Logout"
2828
document.getElementById("login_url").href="javascript:logout()"
2929
document.getElementById("update-flightdocs").style.display = "block"
30+
document.getElementById("prediction_settings_message").innerText = "Use this form to configure predictions for your launch. Please only use this for your own launches. Callsigns must match your payload callsigns exactly (case sensitive)."
3031
}
3132
});
32-
33+
function query_flight_doc(){
34+
var payload_callsign = document.getElementById("flight_doc_payload_callsign").value
35+
fetch("https://api.v2.sondehub.org/amateur/flightdoc/"+payload_callsign).then(
36+
function(response){
37+
if (response.ok) {
38+
response.text().then(function(x) {
39+
var data = JSON.parse(x)
40+
if (data.float_expected) {
41+
document.getElementById("flight_doc_float_expected").checked = true
42+
} else {
43+
document.getElementById("flight_doc_float_expected").checked = false
44+
}
45+
document.getElementById("flight_doc_peak_altitude").value = data.peak_altitude
46+
document.getElementById("flight_doc_descent_rate").value = data.descent_rate
47+
document.getElementById("flight_doc_ascent_rate").value = data.ascent_rate
48+
})
49+
} else {
50+
document.getElementById("payload-update-results").textContent = "Could not load payload data"
51+
}
52+
}
53+
)
54+
}
3355
function logout(){
3456
logout_url = "https://auth.v2.sondehub.org/logout?client_id=21dpr4kth8lonk2rq803loh5oa&response_type=token&logout_uri=" + window.location.protocol + "//" + window.location.host
3557
sessionStorage.removeItem("id_token")

0 commit comments

Comments
 (0)