Skip to content

Commit 87ed532

Browse files
Mark JessopMark Jessop
authored andcommitted
Enable multi-payload filtering, re-add embed tab
1 parent 8a35367 commit 87ed532

File tree

4 files changed

+67
-16
lines changed

4 files changed

+67
-16
lines changed

embed-preview.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@
9797
// filter
9898
$("#opt_filter").on('keyup', function() {
9999
updateCode();
100+
// Force iframe refresh
101+
var ifr = document.getElementsByName('embed_iframe')[0];
102+
ifr.contentWindow.location.reload(true);
100103
});
101104

102105
// vehicle list
@@ -215,7 +218,7 @@
215218
<h1>Embed SondeHub-Amateur tracker on your page</h1>
216219
<h2>1. Options</h1>
217220
<fieldset>
218-
<label for="opt_filter">Vehicle filter (;)</label>
221+
<label for="opt_filter">Vehicle filter (, separated. Note: Filtering will not take effect in preview below.)</label>
219222
<input type="input" value="" id="opt_filter" size="40" />
220223
<br />
221224
<input type="checkbox" value="1" id="opt_list" />
@@ -244,7 +247,7 @@ <h2>3. HTML code</h1>
244247

245248
<h2>4. Live preview</h1>
246249
<div id="iframe-box">
247-
<iframe width="400px" height="500px" src="index.html?&preview=1" style="border:1px solid #00A3D3;border-radius:20px;"></iframe>
250+
<iframe name="embed_iframe" width="400px" height="500px" src="index.html?&preview=1" style="border:1px solid #00A3D3;border-radius:20px;"></iframe>
248251
</div>
249252
</div>
250253
</body>

index.html

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,38 @@
5050
<path style="fill:#ffffff;" d="M 18.28125,5 C 17.665689,5.1577701 18.03897,6.072102 17.9375,6.6048171 17.961629,7.7933649 17.891319,9.0210305 17.96875,10.1875 18.260664,10.655295 18.988694,10.16755 19.495121,10.179003 19.915569,10.180314 20.482932,9.9817615 20.218593,9.5070668 19.685242,8.0689805 19.166647,6.5372411 18.625,5.15625 18.528924,5.0654291 18.420762,5.0014609 18.28125,5 z M 28.15625,6.78125 C 27.636383,7.0532274 27.291342,7.7650855 26.831767,8.2022559 26.183602,9.0036626 25.432231,9.7753304 24.84375,10.59375 24.760617,11.249334 25.657959,11.271078 26.078986,11.644576 26.390422,11.953835 26.933703,11.952146 27.000157,11.538317 27.50744,10.067568 28.117357,8.594139 28.5625,7.125 28.492656,6.9017107 28.410263,6.7690543 28.15625,6.78125 z M 9.5,10 C 9.0954231,10.135594 9.2373811,10.695886 9.5795967,10.908518 10.537018,12.015516 11.460558,13.256267 12.4375,14.28125 13.029751,14.410245 13.239648,13.580555 13.666521,13.22967 13.9948,13.00156 14.131018,12.482443 13.78125,12.375 12.489706,11.554805 11.012447,10.783392 9.71875,10 9.6458333,10 9.5729167,10 9.5,10 z M 20.84375,11.84375 C 18.371908,11.824599 15.919598,13.01633 14.4375,15 11.081301,15.152911 7.9058815,17.160924 6.28125,20.09375 2.2666586,20.646663 -0.69921244,24.862902 0.11714748,28.826804 0.69396943,32.528614 4.3500351,35.295394 8.0531848,35 13.498142,34.979277 18.945738,35.041925 24.389003,34.967703 28.012052,34.706771 30.775569,30.845122 29.836019,27.330847 29.833738,25.300645 26.765497,24.336816 28.355407,22.48894 29.815113,18.665861 27.745092,13.988203 23.952748,12.472903 22.972942,12.055889 21.908328,11.842683 20.84375,11.84375 z M 20.21875,13.59375 C 23.527165,13.23952 26.784739,15.868299 27.030581,19.205159 27.115191,20.410269 26.970056,22.322167 26.040039,22.926528 23.85825,22.779121 24.34015,19.916014 22.792045,18.711734 21.278161,16.832506 19.06924,15.524713 16.6875,15.125 17.664583,14.25896 18.917452,13.711132 20.21875,13.59375 z M 34.53125,14.5 C 32.976676,14.79175 31.359523,14.999412 29.84375,15.34375 29.432201,15.70465 29.988892,16.309044 30.057328,16.768486 30.153946,17.218356 30.409976,17.817605 30.892161,17.453583 32.226329,16.650798 33.669292,15.884461 34.9375,15.0625 35.138066,14.780605 34.838029,14.456276 34.53125,14.5 z M 15,16.75 C 18.527258,16.691328 21.880457,19.184293 22.875,22.5625 21.79535,22.747412 19.681154,23.400321 19.66679,24.380589 20.173956,24.71003 20.627331,25.845369 21.195407,25.029384 23.413999,23.416094 26.91018,24.431242 27.896354,26.999192 29.087621,29.561636 27.239462,32.866375 24.435283,33.198105 21.16923,33.314717 17.892696,33.218673 14.62245,33.25 11.957151,33.213512 9.2843705,33.327734 6.6243627,33.183689 3.2643734,32.772467 0.9055326,29.012617 2.003206,25.808244 2.6850371,23.482227 4.9843514,21.775323 7.40625,21.78125 8.6597695,18.794322 11.749593,16.71468 15,16.75 z M 30.46875,22.1875 C 30.056841,22.438736 30.028318,23.215643 29.779714,23.682554 29.505486,24.023058 29.684998,24.517691 30.15025,24.501295 31.642521,24.753547 33.129447,25.065901 34.625,25.28125 35.096754,25.222871 35.037983,24.560567 34.590363,24.47021 33.258254,23.721082 31.923603,22.888061 30.59375,22.1875 30.552083,22.1875 30.510417,22.1875 30.46875,22.1875 z"></path>
5151
</svg>
5252
</li>
53+
<li class="embed">
54+
<svg width="100%" height="100%" viewbox="0 0 35 40" xmlns="http://www.w3.org/2000/svg" version="1.1" version="1.1">
55+
<path style="fill:#ffffff;" d="m19.188,4.0378c-1.698,10.6-3.396,21.2-5.094,31.8,1.478,0.9,2.037-0.6,2.024-1.7,1.607-10.1,3.213-20.1,4.82-30.1h-1.75zm-6.469,5.3c-3.9064,3-7.8129,6-11.719,9v3.7c3.9045,3,7.8143,6,11.719,9v-3.9c-3.0949-2.3-6.1868-4.6-9.2815-7,3.0937-2.3,6.1875-4.6,9.2815-6.9v-3.9zm9.562,0v3.9c3.094,2.3,6.188,4.6,9.281,6.9-3.093,2.4-6.187,4.7-9.281,7v3.9c3.905-3,7.814-6,11.719-9v-3.7c-3.906-3-7.813-6-11.719-9z"></path>
56+
</svg>
57+
</li>
5358
<li class="about last"><i class="icon-question"></i></li>
5459
</ol>
5560
<span id="locate-me" style="display: none"><i class="icon-target"></i></span>
5661
<span id="app_name"><b>no<br/>location</b></span>
5762
</div>
5863
</header>
5964

65+
<div id="embedbox" style="display: none" class="flatpage">
66+
<div class="slimContainer">
67+
<h2>Embed tracker
68+
<svg width="35" height="40" viewbox="0 0 35 40" xmlns="http://www.w3.org/2000/svg" version="1.1" version="1.1" class="rfloat">
69+
<path style="fill:#666666;" d="m19.188,4.0378c-1.698,10.6-3.396,21.2-5.094,31.8,1.478,0.9,2.037-0.6,2.024-1.7,1.607-10.1,3.213-20.1,4.82-30.1h-1.75zm-6.469,5.3c-3.9064,3-7.8129,6-11.719,9v3.7c3.9045,3,7.8143,6,11.719,9v-3.9c-3.0949-2.3-6.1868-4.6-9.2815-7,3.0937-2.3,6.1875-4.6,9.2815-6.9v-3.9zm9.562,0v3.9c3.094,2.3,6.188,4.6,9.281,6.9-3.093,2.4-6.187,4.7-9.281,7v3.9c3.905-3,7.814-6,11.719-9v-3.7c-3.906-3-7.813-6-11.719-9z"></path>
70+
</svg>
71+
</h2>
72+
<hr>
73+
<p>
74+
It's possible to embed the mobile tracker on any page! <br/>
75+
If you are developing a HAB project, you can add the tracker to your website. You can customize the tracker to fit, and there are options to limit the visible vehicles to
76+
a set of specific callsigns. <br/>
77+
It's easy. Just visit the page below and check it out.
78+
</p>
79+
<p>
80+
<a href="embed-preview.html" target="_blank">Customize tracker for embedding</a>
81+
</p>
82+
</div>
83+
</div>
84+
6085
<div id="aboutbox" style="display: none" class="flatpage">
6186
<div class="slimContainer">
6287
<h2><i class="icon-question rfloat"></i>Welcome</h2>
@@ -80,7 +105,7 @@ <h4>I'm launching a balloon!</h4>
80105
<br/>
81106

82107
<h4>What happened to HabHub?</h4>
83-
HabHub is soon to be retired due to obsolescence issues,
108+
HabHub has now been retired due to obsolescence issues,
84109
<a href="https://github.com/projecthorus/sondehub-amateur-tracker/wiki/Guide-for-HabHub-Users" target="_blank" rel="noopener">read more here.</a>
85110
<br/>
86111

@@ -104,7 +129,7 @@ <h2>Contribute</h2>
104129
<br/><br/>
105130
A huge thanks to RGP for developing the mobile tracker that this site is based on.
106131
<br/><br/>
107-
You can also find us on IRC in <a href="https://kiwiirc.com/nextclient/irc.libera.chat/highaltitude" target="_blank" rel="noopener">#highaltitude</a> at <b>libera.chat</b>.
132+
You can also find us on IRC in <a href="https://kiwiirc.com/nextclient/irc.libera.chat/habhub" target="_blank" rel="noopener">#habhub</a> at <b>libera.chat</b>.
108133
<br/><br/>
109134
Tracker Revision: <span class="r" id="build_version"></span>
110135
<br/>

js/app.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,14 @@ for(var idx in params) {
169169
case "embed":
170170
if(line[1] == "1") {
171171
wvar.enabled = true;
172-
if(!is_mobile) wvar.mode = 'All';
172+
if(!is_mobile) wvar.mode = '3d';
173173
}
174174
break;
175175
case "hidelist": if(line[1] == "1") wvar.vlist = false; break;
176176
case "hidegraph": if(line[1] == "1") wvar.graph = false; break;
177177
case "expandgraph": if(line[1] == "1") wvar.graph_expanded = true; break;
178178
case "filter":
179-
wvar.query = decodeURIComponent(line[1]);
179+
wvar.query = decodeURIComponent(line[1]).replace(/;/g,",");
180180
$("header .search input[type='text']").val(wvar.query);
181181
break;
182182
case "nyan": wvar.nyan = true; break;
@@ -188,7 +188,7 @@ for(var idx in params) {
188188

189189
// loads the tracker interface
190190
function trackerInit() {
191-
$('#loading,#settingsbox,#aboutbox,#chasebox').hide(); // welcome screen
191+
$('#loading,#settingsbox,#aboutbox,#embedbox,#chasebox').hide(); // welcome screen
192192
$('header,#main').show(); // interface elements
193193
checkSize();
194194

@@ -959,7 +959,7 @@ $(window).ready(function() {
959959
$("header .search form").on('submit', function(e) {
960960
e.preventDefault();
961961

962-
var text = $("header .search input[type='text']").val();
962+
var text = $("header .search input[type='text']").val().replace(/;/g,",");
963963

964964
if(text === wvar.query) return;
965965

js/tracker.js

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,10 @@ function clean_refresh(text, force, history_step) {
526526
try {
527527
client.unsubscribe(clientTopic);
528528
if (wvar.query && sondePrefix.indexOf(wvar.query) == -1) {
529-
var topic = "amateur/" + wvar.query;
529+
// Generate array of filter entries.
530+
var topic = wvar.query.split(",").map(function(el) {
531+
return 'amateur/' + el;
532+
});
530533
client.subscribe(topic);
531534
clientTopic = topic;
532535
} else {
@@ -3204,8 +3207,8 @@ function refresh() {
32043207
var mode = wvar.mode.toLowerCase();
32053208
mode = (mode == "position") ? "latest" : mode.replace(/ /g,"");
32063209

3207-
if (wvar.query && sondePrefix.indexOf(wvar.query) == -1) {
3208-
var data_str = "duration=3d&payload_callsign=" + encodeURIComponent(wvar.query);
3210+
if (wvar.query) {
3211+
var data_str = "duration=" + mode + "&payload_callsign=" + encodeURIComponent(wvar.query);
32093212
} else {
32103213
var data_str = "duration=" + mode;
32113214
}
@@ -3216,13 +3219,15 @@ function refresh() {
32163219
data: data_str,
32173220
dataType: "json",
32183221
success: function(data, textStatus) {
3219-
if (wvar.query != null && JSON.stringify(data).indexOf(wvar.query) == -1) {
3220-
refreshSingle(wvar.query);
3221-
} else {
3222+
// This check breaks multiple payload queries.
3223+
// Is this correct anyway? refreshSingle uses the /sonde/ API which is for radiosondes only?
3224+
// if (wvar.query != null && JSON.stringify(data).indexOf(wvar.query) == -1) {
3225+
// refreshSingle(wvar.query);
3226+
// } else {
32223227
response = formatData(data);
32233228
update(response, true);
32243229
$("#stTimer").attr("data-timestamp", response.fetch_timestamp);
3225-
}
3230+
//}
32263231
$("#stText").text("");
32273232
},
32283233
error: function() {
@@ -3238,6 +3243,20 @@ function refresh() {
32383243
//console.log("WebSockets - Resuming Websockets updates after poll.")
32393244
clearTimeout(periodical);
32403245
ajax_inprogress = false;
3246+
3247+
if(wvar.query){
3248+
// If we have a query, pan the map to cover the payloads in that query.
3249+
var vehicle_query = wvar.query.replace(/;/g,',').split(',');
3250+
var query_positions = [];
3251+
for (k in vehicle_query){
3252+
veh = vehicle_query[k];
3253+
if(vehicles.hasOwnProperty(veh)){
3254+
query_positions.push(vehicles[veh].positions[vehicles[veh].positions.length-1]);
3255+
}
3256+
}
3257+
map.fitBounds(query_positions, {'maxZoom': 8});
3258+
}
3259+
32413260
}
32423261
});
32433262
}
@@ -3327,7 +3346,10 @@ function liveData() {
33273346

33283347
function onConnect() {
33293348
if (wvar.query && sondePrefix.indexOf(wvar.query) == -1) {
3330-
var topic = "amateur/" + wvar.query;
3349+
//var topic = "amateur/" + wvar.query;
3350+
var topic = wvar.query.split(",").map(function(el) {
3351+
return 'amateur/' + el;
3352+
});
33313353
client.subscribe(topic);
33323354
clientTopic = topic;
33333355
} else {
@@ -3897,6 +3919,7 @@ function update(response, none) {
38973919
return;
38983920
}
38993921

3922+
// This is not required for sondehub-amateur?
39003923
if (sondePrefix.indexOf(wvar.query) > -1) {
39013924
for (var i = response.positions.position.length - 1; i >= 0; i--) {
39023925
try {

0 commit comments

Comments
 (0)