Skip to content

Commit 998449e

Browse files
Mark JessopMark Jessop
authored andcommitted
Add recovery warning popup when at zoom >=13
1 parent 7c11aa7 commit 998449e

File tree

3 files changed

+72
-9
lines changed

3 files changed

+72
-9
lines changed

index.template.html

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,13 @@
9191
<div class="slimContainer">
9292
<h3><i class="icon-habhub rfloat"></i>Report Recovery</h3>
9393
<hr/>
94-
<div class="row">
95-
<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>
94+
<div class="row">
95+
<span><b>Please report recovered radiosondes! Don't waste others time and effort with a frustrating failed recovery!</b></span>
96+
<span>Enter the serial number, select recovered / planned, and add some notes. If marking as planned, please add contact information!</span>
97+
<span>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.</span>
9698
</div>
9799
<div class="row">
98-
<span><b>Serial</b></span>
100+
<span><b>Serial</b> <a href="https://github.com/projecthorus/sondehub-infra/wiki/Radiosonde-Serial-Numbers" target="_blank" rel="noopener">(Help)</a></span>
99101
<span class="r"><input type="text" id="pr_serial" style="width: 140px;"/></span>
100102
</div>
101103
<div class="row">
@@ -117,7 +119,7 @@ <h3><i class="icon-habhub rfloat"></i>Report Recovery</h3>
117119
</div>
118120
</div>
119121
<div class="row option">
120-
<span><b>Use Car Position</b></span>
122+
<span><b>Use Browser Position</b></span>
121123
<div class="switch off" id="sw_use_car_pos">
122124
<span class="thumb"></span>
123125
<input type="checkbox" id="use_car_pos">
@@ -411,6 +413,9 @@ <h2><i class="icon-car rfloat"></i>Chase Mode</h2>
411413
<div id="zoom_warning" class="lfloat slickbox" style="width:250px; bottom: 0px; left: 50%; transform: translate(-50%, -50%);">
412414
<div style="width:250px">Zoom in for realtime data!</div>
413415
</div>
416+
<div id="recovery_notice" class="lfloat slickbox" onclick="show_recoveries();" style="width:270px; bottom: 0px; left: 50%; transform: translate(-50%, -50%); display:none;">
417+
<div style="width:270px"><b>Please report radiosonde recoveries!<b/></div>
418+
</div>
414419
</div>
415420
<div id="timebox" class="present slickbox animate" style="display: none">
416421
<svg width="40" height="40" viewbox="0 0 200 200" xmlns="http://www.w3.org/2000/svg" version="1.1" version="1.1" class="lfloat">
@@ -450,8 +455,8 @@ <h2><i class="icon-car rfloat"></i>Chase Mode</h2>
450455
</div>
451456
</div>
452457

453-
<div id="reload_warning">This version of SondeHub is out of date. <a href="javascript:window.location.reload(true)">Click here to reload</a>. Page will reload automatically in <span id="reload_timer"></span>
454-
</div>
458+
<div id="reload_warning">This version of SondeHub is out of date. <a href="javascript:window.location.reload(true)">Click here to reload</a>. Page will reload automatically in <span id="reload_timer"></span></div>
459+
455460

456461
<!-- Was 3.31-->
457462

js/app.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -684,9 +684,9 @@ $(window).ready(function() {
684684
} else {
685685
wvar.box = null
686686
}
687-
console.log("aaa")
688-
console.log(wvar.box)
689-
console.log("bbbb")
687+
//console.log("aaa")
688+
//console.log(wvar.box)
689+
//console.log("bbbb")
690690
lhash_update(true);
691691
checkSize();
692692
});

js/sondehub.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,7 @@ function load() {
10581058
}
10591059
}
10601060
updateZoom();
1061+
recoveryPopup();
10611062
});
10621063

10631064
map.on('movestart', function() {
@@ -1497,6 +1498,63 @@ function drawLOSPaths(vcallsign) {
14971498
});
14981499
}
14991500

1501+
var recovery_popup = true;
1502+
function recoveryPopup(){
1503+
// Conditions for showing this are:
1504+
// Zoom level >= 13
1505+
// A sonde is in the map view area. (Use the subscribed sondes for this)
1506+
// If a user position is available, that position is within 500km of the sonde.
1507+
recovery_popup_limit = 500000;
1508+
1509+
if( (map.getZoom() >= 13) && (clientTopic.length >= 2)){
1510+
if(recovery_popup == true){
1511+
// Logic to not show a popup if the centre of the map is > 500km from the viewer location,
1512+
_viewer_lat = parseFloat($('#cc_lat').text())
1513+
_viewer_lon = parseFloat($('#cc_lon').text())
1514+
1515+
if ( (_viewer_lat != 0.0) && (_viewer_lon != 0.0) ){
1516+
1517+
_map_centre = {
1518+
'lat':map.getCenter().lat,
1519+
'lon':map.getCenter().lng,
1520+
'alt':0.0
1521+
};
1522+
_viewer = {
1523+
'lat': _viewer_lat,
1524+
'lon': _viewer_lon,
1525+
'alt': 0.0
1526+
};
1527+
1528+
// Calculate the distance from the sonde
1529+
_lookangles = calculate_lookangles(_viewer, _map_centre);
1530+
1531+
if(_lookangles.range > recovery_popup_limit){
1532+
return;
1533+
}
1534+
}
1535+
1536+
// If we're here, then we either don't have a valid viewer location,
1537+
// Or the viewer is within 500km. Show the popup.
1538+
console.log("Triggering Recovery Popup.")
1539+
document.getElementById("recovery_notice").style.display = "block";
1540+
// Don't re-activate the popup again
1541+
recovery_popup = false;
1542+
return;
1543+
}
1544+
}
1545+
document.getElementById("recovery_notice").style.display = "none";
1546+
}
1547+
1548+
function show_recoveries(){
1549+
if ($("#recoveriesbox").is(':visible') == false){
1550+
$('.nav .recoveries').click();
1551+
}
1552+
1553+
document.getElementById("recovery_notice").style.display = "none";
1554+
recovery_popup = false;
1555+
}
1556+
1557+
15001558
function focusVehicle(vcallsign, ignoreOpt) {
15011559
if(!offline.get('opt_hilight_vehicle') && ignoreOpt === undefined) return;
15021560

0 commit comments

Comments
 (0)