Skip to content

Commit acca016

Browse files
author
Gary Keeble
committed
Merge branch 'User-Configurable-Time'
p'" This reverts commit a681053, reversing changes made to 6b02ca2.
2 parents a681053 + 43501af commit acca016

File tree

4 files changed

+50
-4
lines changed

4 files changed

+50
-4
lines changed

index.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,15 @@ <h4>Zoom</h4>
196196
<div class="form-inline">
197197
<div class="form-group">
198198
<div class="graph-zoom-control btn-group btn-group-vertical"></div>
199-
<input type="text" class="form-control graph-zoom" value="1.0" size="6">
199+
<input type="text" class="form-control graph-zoom" value="-" size="6">
200+
</div>
201+
</div>
202+
</li>
203+
<li class="log-chart-time-panel">
204+
<h4>Time</h4>
205+
<div class="form-inline">
206+
<div class="form-group">
207+
<input type="text" class="form-control graph-time" value="1.0" size="8">
200208
</div>
201209
</div>
202210
</li>

js/grapher.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,8 @@ function FlightLogGrapher(flightLog, graphConfig, canvas, craftCanvas, options)
438438
frameLabelTextWidthFrameTime = canvasContext.measureText("00:00.000").width;
439439

440440
canvasContext.fillText(formatTime(timeMsec, true), canvas.width - frameLabelTextWidthFrameTime - 8, canvas.height - 8 - drawingParams.fontSizeFrameLabel - 8);
441+
// update time field on toolbar
442+
$(".graph-time").val(formatTime(timeMsec, true));
441443
}
442444

443445
/**

js/main.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,23 @@ function BlackboxLogViewer() {
748748
}
749749
});
750750

751-
751+
// Add user configurable start time
752+
$(".graph-time").change(function() {
753+
754+
// the log is offset by the minTime
755+
var newTime = stringTimetoMsec($(".graph-time").val());
756+
757+
if (!isNaN(newTime)) {
758+
if (hasVideo) {
759+
setVideoTime(newTime / 1000000 + videoOffset);
760+
} else {
761+
newTime += flightLog.getMinTime();
762+
setCurrentBlackboxTime(newTime);
763+
}
764+
invalidateGraph();
765+
}
766+
});
767+
752768
var
753769
graphConfigDialog = new GraphConfigurationDialog($("#dlgGraphConfiguration"), function(newConfig) {
754770
graphConfig = newConfig;
@@ -845,8 +861,12 @@ function BlackboxLogViewer() {
845861

846862
$(document).keydown(function(e) {
847863
var shifted = (e.altKey || e.shiftKey || e.ctrlKey || e.metaKey);
848-
849-
if (graph && $(e.target).parents('.modal').length == 0) {
864+
if(e.which === 13 && e.target.type === 'text' && $(e.target).parents('.modal').length == 0) {
865+
// pressing return on a text field clears the focus.
866+
$(e.target).blur();
867+
}
868+
// keyboard controls are disabled on modal dialog boxes and text entry fields
869+
if (graph && e.target.type != 'text' && $(e.target).parents('.modal').length == 0) {
850870
switch (e.which) {
851871
case "I".charCodeAt(0):
852872
if (!(shifted)) {

js/tools.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,20 @@ function formatTime(msec, displayMsec) {
184184

185185
return (hours ? leftPad(hours, "0", 2) + ":" : "") + leftPad(mins, "0", 2) + ":" + leftPad(secs, "0", 2)
186186
+ (displayMsec ? "." + leftPad(msec, "0", 3) : "");
187+
}
188+
189+
function stringTimetoMsec(input) {
190+
try {
191+
var matches = input.match(/([0-9]+)(\D)*([0-9]+)*\D*([0-9]+)*/);
192+
193+
if(matches.length>2) { // there is a placeholder - either : or .
194+
if(matches[2] == ':'){ // time has been entered MM:SS.SSS
195+
return matches[1] * 60 * 1000000 + ((matches[3])?matches[3]:0) * 1000000 + ((matches[4])?(matches[4] + "00").slice(0,3):0) * 1000
196+
} else {
197+
return matches[1] * 1000000 + ((matches[3])?(matches[3] + "00").slice(0,3):0) * 1000;
198+
}
199+
} else return matches[1] * 1000000;
200+
} catch(e) {
201+
return 0;
202+
}
187203
}

0 commit comments

Comments
 (0)