Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move recovery reporting to ballon tab. Add planned recovery option, a…
…nd handling of planned tag
  • Loading branch information
Mark Jessop authored and Mark Jessop committed Jan 26, 2025
commit 7c11aa7aca42f452dd2147933d4bb9747bbac761
107 changes: 58 additions & 49 deletions index.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,66 @@

<div id="recoveriesbox" style="display: none" class="flatpage">
<div class="slimContainer">
<h2><i class="icon-habhub rfloat"></i>Recoveries</h2>
<h3><i class="icon-habhub rfloat"></i>Report Recovery</h3>
<hr/>
<p>Recovery reports can be added on the Chase-Car pane.</p>
<div class="row">
<span>You can report a recovery here. Enter the serial number (e.g. 'S1234567'), tick recovered/not recovered, and add some notes. <a href="https://github.com/projecthorus/sondehub-infra/wiki/Radiosonde-Serial-Numbers" target="_blank" rel="noopener">Click here</a> for information on how to locate a sonde's serial number.</a> If the sonde is not on the map, type its serial into the top-left search box (may require landscape mode on mobile) and press enter to retrieve historical data. You can then mark it as recovered or planned. Optionally, you can use your location instead of the sonde's last location.</span>
</div>
<div class="row">
<span><b>Serial</b></span>
<span class="r"><input type="text" id="pr_serial" style="width: 140px;"/></span>
</div>
<div class="row">
<span><b>Recovered By</b></span>
<span class="r"><input type="text" id="recovery_callsign" style="width: 140px;" maxlength="15"/></span>
</div>
<div class="row option">
<span><b>Recovery Success</b></span>
<div class="switchyn on" id="sw_recovery_ok">
<span class="thumb"></span>
<input type="checkbox" id="recovery_ok">
</div>
</div>
<div class="row option">
<span><b>Recovery Planned</b></span>
<div class="switchyn off" id="sw_recovery_planned">
<span class="thumb"></span>
<input type="checkbox" id="recovery_planned">
</div>
</div>
<div class="row option">
<span><b>Use Car Position</b></span>
<div class="switch off" id="sw_use_car_pos">
<span class="thumb"></span>
<input type="checkbox" id="use_car_pos">
</div>
</div>
<div class="row">
<span><b>Notes</b></span>
</div>
<div class="row">
<span>
<!--<input type="text" id="pr_notes" style="width: 140px;"/>-->
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented out code

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

<textarea name="pr_notes" id="pr_notes" style="width:280px;height:60px;"></textarea>
</span>
</div>
<div class="row">
<span><b>Report Result</b></span>
<span class="r" id="pr_last_report">none</span>
</div>
<div class="row">
<div class="g-recaptcha" data-sitekey="6LcEkBUbAAAAABTgn2lktm6UPeP0lbyqIDBBujSF"></div>
</div>
<div class="row">
<span class="r"><input type="button" value="Submit" id="pr_submit" onclick="ChaseCar.markRecovered();"/></span>
</div>
<hr/>
<div id="recovery-list"><img style="width:90px;height:30px;display:block;margin:auto;" src="img/hab-spinner.gif"/><br></div>
</div>
<div class="slimContainer">
<h2>Statistics</h2>
<h3>Statistics</h3>
<hr/>
<div id="leaderboard-list"><img style="width:90px;height:30px;display:block;margin:auto;" src="img/hab-spinner.gif"/><br></div>
<hr/>
<h3>Recoveries</h3>
<div id="recovery-list"><img style="width:90px;height:30px;display:block;margin:auto;" src="img/hab-spinner.gif"/><br></div>
</div>
</div>
<div id="aboutbox" style="display: none" class="flatpage">
Expand All @@ -119,7 +169,7 @@ <h4>Radiosondes?</h4>
<br/>

<h4>Found a Radiosonde?</h4>
Click the 'car' icon on the top-right to submit a recovery notification.
<b>Please click the 'balloon' icon on the top-right to submit a recovery notification!</b>

<h4>Support Us!</h4>
If you use SondeHub regularly, please consider <a href="https://www.patreon.com/sondehub" target="_blank" rel="noopener">supporting us on Patreon</a>, or with a <a href="https://sondehub.org/go/donate" target="_blank" rel="noopener">donation on Paypal</a>.</br>
Expand Down Expand Up @@ -351,48 +401,7 @@ <h2><i class="icon-car rfloat"></i>Chase Mode</h2>
<span class="r" id="cc_speed">none</span>
</div>
<hr>
<h3>Report Recovery</h3>
<hr>
<div class="row">
<span>You can report a recovery here. Enter the serial number (e.g. 'S1234567'), tick recovered/not recovered, and add some notes. <a href="https://github.com/projecthorus/sondehub-infra/wiki/Radiosonde-Serial-Numbers" target="_blank" rel="noopener">Click here</a> for information on how to locate a sonde's serial number.</a> If the sonde is not on the map, type its serial into the top-left search box and press enter to retrieve historical data. You can then mark it as recovered. Optionally, you can use your location instead of the sonde's last location.</span>
</div>
<div class="row">
<span><b>Serial</b></span>
<span class="r"><input type="text" id="pr_serial" style="width: 140px;"/></span>
</div>
<div class="row option">
<span><b>Recovery Success</b></span>
<div class="switchyn on" id="sw_recovery_ok">
<span class="thumb"></span>
<input type="checkbox" id="recovery_ok">
</div>
</div>
<div class="row option">
<span><b>Use Car Position</b></span>
<div class="switch off" id="sw_use_car_pos">
<span class="thumb"></span>
<input type="checkbox" id="use_car_pos">
</div>
</div>
<div class="row">
<span><b>Notes</b></span>
</div>
<div class="row">
<span>
<!--<input type="text" id="pr_notes" style="width: 140px;"/>-->
<textarea name="pr_notes" id="pr_notes" style="width:280px;height:60px;"></textarea>
</span>
</div>
<div class="row">
<span><b>Report Result</b></span>
<span class="r" id="pr_last_report">none</span>
</div>
<div class="row">
<div class="g-recaptcha" data-sitekey="6LcEkBUbAAAAABTgn2lktm6UPeP0lbyqIDBBujSF"></div>
</div>
<div class="row">
<span class="r"><input type="button" value="Submit" id="pr_submit" onclick="ChaseCar.markRecovered();"/></span>
</div>
Recovery reporting is now on the recoveries tab! (Balloon icon)

</div>
</div>
Expand Down
27 changes: 27 additions & 0 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,23 @@ $(window).ready(function() {
// turning the switch on
} else {
e.removeClass('off').addClass('on');
// Remove any planned recovery check.
$("#sw_recovery_planned").removeClass('on').addClass('off');
}
});
// Logic to switch the recovery Planned button
$("#sw_recovery_planned").click(function() {
var e = $(this);

// turning the switch off
if(e.hasClass('on')) {
e.removeClass('on').addClass('off');

// turning the switch on
} else {
e.removeClass('off').addClass('on');
// Set recovery OK to false.
$("#sw_recovery_ok").removeClass('on').addClass('off');
}
});
// Logic to switch the use car position button
Expand All @@ -768,11 +785,21 @@ $(window).ready(function() {
callsign = $(this).val().trim();
offline.set('callsign', callsign); // put in localStorage
CHASE_listenerSent = false;
$('#recovery_callsign').val(callsign);
});

$("#recovery_callsign").on('change keyup', function() {
callsign = $(this).val().trim();
offline.set('callsign', callsign); // put in localStorage
CHASE_listenerSent = false;
$('#cc_callsign').val(callsign);
});


// load value from localStorage
callsign = offline.get('callsign');
$('#cc_callsign').val(callsign);
$('#recovery_callsign').val(callsign);

// settings page

Expand Down
20 changes: 13 additions & 7 deletions js/chasecar.lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ ChaseCar.updatePosition = function(callsign, position) {

ChaseCar.markRecovered = function(){

// Distance limits reinstated 2021-12-04
_run_checks = true;
// Remove range checks - 2025-01-24
_range_check = false;
_range_limit = 500000; // 200 km

// Get the serial number to be marked recovered
Expand All @@ -55,15 +55,15 @@ ChaseCar.markRecovered = function(){
_notes = $("#pr_notes").val().trim();

// Check it exists.
if(_serial.includes("chase") && _run_checks){
if(_serial.includes("chase")){
$('#pr_last_report').text("Invalid sonde callsign.");
return;
}

_callsign = $("#cc_callsign").val().trim();
_callsign = $("#recovery_callsign").val().trim();
if (_callsign == "" || _callsign == undefined || _callsign.length == 0)
{
$('#pr_last_report').text("Enter a callsign in the chase-car section above!");
$('#pr_last_report').text("Enter a callsign/name in the 'Recovered by' field!");
return;
}

Expand Down Expand Up @@ -109,7 +109,7 @@ ChaseCar.markRecovered = function(){
// Calculate the distance from the sonde
_lookangles = calculate_lookangles(_chaser, _sonde);

if( (_lookangles.range > _range_limit ) && _run_checks){
if( (_lookangles.range > _range_limit ) && _range_check){
$('#pr_last_report').text("Outside distance limit (500km).");
return;
}
Expand All @@ -120,13 +120,18 @@ ChaseCar.markRecovered = function(){
}
}

// Logic to make recovery & planned mutually exclusive is in app.js
_recovered = $("#sw_recovery_ok").hasClass('on');
_planned = $("#sw_recovery_planned").hasClass('on');


var _doc = {
"serial": _serial,
"lat": _recov_lat,
"lon": _recov_lon,
"alt": 0.0,
"recovered": $("#sw_recovery_ok").hasClass('on'),
"recovered": _recovered,
"planned": _planned,
"recovered_by": _callsign,
"description": _notes
};
Expand All @@ -142,6 +147,7 @@ ChaseCar.markRecovered = function(){

$('#pr_last_report').text("Submitting report...");


$.ajax({
type: "PUT",
url: ChaseCar.recovery_uri,
Expand Down
23 changes: 21 additions & 2 deletions js/sondehub.js
Original file line number Diff line number Diff line change
Expand Up @@ -4699,8 +4699,17 @@ function updateRecoveryMarker(recovery) {

div = document.createElement('div');

_recovered_text = recovery.recovered ? " Recovered" : " Not Recovered";

// Override text is planned field exists and is true
if(recovery.hasOwnProperty('planned')){
if(recovery.planned == true){
_recovered_text = " Recovery Planned";
}
}

html = "<div style='line-height:16px;position:relative;'>";
html += "<div><b>"+recovery.serial+(recovery.recovered ? " Recovered" : " Not Recovered")+"</b></div>";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

html += "<div><b>"+recovery.serial+_recovered_text+"</b></div>";
html += "<hr style='margin:5px 0px'>";
html += "<div style='margin-bottom:5px;'><b><i class='icon-location'></i>&nbsp;</b>"+format_coordinates(recovery.lat, recovery.lon, recovery.serial)+"</div>";

Expand Down Expand Up @@ -4755,6 +4764,7 @@ function updateRecoveryMarker(recovery) {
recovery.recovered = r[i].recovered;
recovery.description = r[i].description;
recovery.datetime = r[i].datetime;
recovery.planned = r[i].planned;
recovery.fresh = true;
updateRecoveryMarker(recovery);

Expand Down Expand Up @@ -4808,8 +4818,17 @@ function updateRecoveryPane(r){
recoveries[r_index] = {marker: null, infobox: null};
}

_recovered_text = r[i].recovered ? " Recovered by " : " Not Recovered by ";

// Override text is planned field exists and is true
if(r[i].hasOwnProperty('planned')){
if(r[i].planned == true){
_recovered_text = " Recovery Planned by ";
}
}

html += "<div style='line-height:16px;position:relative;'>";
html += "<div><b><u>"+r[i].serial+(r[i].recovered ? " Recovered by " : " Not Recovered by ")+r[i].recovered_by+"</u></b></div>";
html += "<div><b><u>"+r[i].serial+(_recovered_text)+r[i].recovered_by+"</u></b></div>";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same xss here

html += "<div style='margin-bottom:5px;'><b><button style='margin-bottom:0px;' onclick='panToRecovery(\"" + r[i].serial + "\")'><i class='icon-location'></i></button>&nbsp;</b>"+format_coordinates(lat, lon, r[i].serial)+"</div>";

var imp = offline.get('opt_imperial');
Expand Down
11 changes: 10 additions & 1 deletion js/station.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,16 @@ function drawHistorical (data, station) {
html += "<hr style='margin:0px;margin-top:5px'>";

if (recovered) {
html += "<div><b>"+(recovery_info.recovered ? "Recovered by " : "Not Recovered by ")+recovery_info.recovered_by+"</u></b></div>";
_recovered_text = recovery_info.recovered ? "Recovered by " : "Not Recovered by ";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is xss vuln here. We shouldn't put user data into innerhtml.


// Override text is planned field exists and is true
if(recovery_info.hasOwnProperty('planned')){
if(recovery_info.planned == true){
_recovered_text = "Recovery Planned by ";
}
}

html += "<div><b>"+(_recovered_text)+recovery_info.recovered_by+"</u></b></div>";
html += "<div><b>Recovery time:&nbsp;</b>"+formatDate(stringToDateUTC(recovery_info.datetime))+"</div>";
html += "<div><b>Recovery location:&nbsp;</b>"+recovery_info.position[1]+", "+recovery_info.position[0] + "</div>";
html += "<div><b>Recovery notes:&nbsp;</b>"+recovery_info.description+"</div>";
Expand Down