Skip to content

Commit e6ff51d

Browse files
committed
hide button if no gps data is present on the log
1 parent 519cccc commit e6ff51d

File tree

4 files changed

+27
-17
lines changed

4 files changed

+27
-17
lines changed

css/main.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,10 @@ html:not(.has-log) #status-bar {
12051205
display: none;
12061206
}
12071207

1208+
html:not(.has-gps) .btn-gpx-export {
1209+
display: none;
1210+
}
1211+
12081212
#status-bar .bookmark-1,
12091213
#status-bar .bookmark-2,
12101214
#status-bar .bookmark-3,

js/flightlog.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,10 @@ function FlightLog(logData) {
10591059

10601060
return true;
10611061
};
1062+
1063+
this.hasGpsData = function() {
1064+
return this.getStats().frame.G ? true : false;;
1065+
};
10621066
}
10631067

10641068
FlightLog.prototype.accRawToGs = function(value) {

js/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,8 @@ function BlackboxLogViewer() {
408408
seekBar.setActivity(activity.times, activity.avgThrottle, activity.hasEvent);
409409

410410
seekBar.repaint();
411+
412+
html.toggleClass("has-gps", flightLog.hasGpsData());
411413
}
412414

413415
function setGraphState(newState) {

js/webworkers/gpx-export-worker.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
importScripts("/node_modules/lodash/lodash.min.js");
22

33
onmessage = function (event) {
4-
const header = `<?xml version="1.0" encoding="UTF-8"?>
5-
<gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/1" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.topografix.com/GPX/gpx_style/0/2 http://www.topografix.com/GPX/gpx_style/0/2/gpx_style.xsd" xmlns:gpx_style="http://www.topografix.com/GPX/gpx_style/0/2"
6-
version="1.1"
7-
creator="https://github.com/betaflight/blackbox-log-viewer">
8-
<metadata>
9-
<author>
10-
<name>Betaflight Blackbox Explorer</name>
11-
<link href="https://github.com/betaflight/blackbox-log-viewer"></link>
12-
</author>
13-
</metadata>`;
14-
15-
const footer = "</gpx>";
4+
const header = `
5+
<?xml version="1.0" encoding="UTF-8"?>
6+
<gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/1" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.topografix.com/GPX/gpx_style/0/2 http://www.topografix.com/GPX/gpx_style/0/2/gpx_style.xsd" xmlns:gpx_style="http://www.topografix.com/GPX/gpx_style/0/2"
7+
version="1.1"
8+
creator="https://github.com/betaflight/blackbox-log-viewer">
9+
<metadata>
10+
<author>
11+
<name>Betaflight Blackbox Explorer</name>
12+
<link href="https://github.com/betaflight/blackbox-log-viewer"></link>
13+
</author>
14+
</metadata>`;
15+
16+
const footer = `</gpx>`;
1617

1718
const timeIndex = event.data.fieldNames.indexOf("time");
1819
const latIndex = event.data.fieldNames.indexOf("GPS_coord[0]");
@@ -49,12 +50,11 @@ onmessage = function (event) {
4950
}
5051
}
5152

52-
let trk =
53-
`<trk>
54-
<name>new</name>
55-
<type>Flight</type>
53+
let trk = `
54+
<trk>
5655
<trkseg>${trkpts}</trkseg>
57-
</trk>`;
56+
</trk>
57+
`;
5858

5959
postMessage(header + "\n" + trk + "\n" + footer);
6060
};

0 commit comments

Comments
 (0)