Skip to content

Commit

Permalink
Converted times in annotation editor to absolute formats. Closes #89
Browse files Browse the repository at this point in the history
  • Loading branch information
atruskie committed Feb 6, 2014
1 parent eb12842 commit 26bbc07
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 27 deletions.
55 changes: 33 additions & 22 deletions src/app/listen/listen.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead'])

// set up some dummy objects for use later
$scope.jumpToHide = true;
$scope.startOffsetAbsolute = null;
$scope.endOffsetAbsolute = null;
$scope.model = {
audioElement: {
volume: null,
Expand Down Expand Up @@ -165,6 +167,14 @@ angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead'])
throw "The provided sample rate for the Media json must be a number!";
}


var // moment works by reference - need to parse the date twice - sigh
absoluteStartChunk = moment($scope.model.media.datetime).add('s', parseFloat($scope.model.media.startOffset)),
absoluteEndChunk = moment($scope.model.media.datetime).add('s', parseFloat($scope.model.media.endOffset));

$scope.startOffsetAbsolute = absoluteStartChunk.format("HH:mm:ss");
$scope.endOffsetAbsolute = absoluteEndChunk.format("HH:mm:ss");

},
function mediaGetFailure() {
console.error("retrieval of media json failed");
Expand Down Expand Up @@ -312,19 +322,7 @@ angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead'])
};


$scope.startOffsetChunk = function () {
if (!$scope.model.media) {
return undefined;
}

return baw.secondsToDurationFormat($scope.model.media.startOffset);
};
$scope.endOffsetChunk = function () {
if (!$scope.model.media) {
return undefined;
}
return baw.secondsToDurationFormat($scope.model.media.endOffset);
};

$scope.durationChunk = function () {
if (!$scope.model.media) {
Expand Down Expand Up @@ -356,6 +354,23 @@ angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead'])
return baw.secondsToDurationFormat(start + offset);
};

$scope.currentOffsetAbsolute = function () {
var chunkOffset = 0;
if ($scope.model.audioElement) {
chunkOffset = $scope.model.audioElement.position;
}

if (!$scope.model.media) {
return undefined;
}

var baseDate = moment($scope.model.media.datetime),
recordingOffset = parseFloat($scope.model.media.startOffset),
absolute = baseDate.add('s', recordingOffset + chunkOffset);

return absolute.format("HH:mm:ss.SSS");
};

$scope.absoluteDateChunkStart = function () {
if (!$scope.model.media || !$scope.model.audioRecording) {
return undefined;
Expand All @@ -366,6 +381,10 @@ angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead'])
return offset;
};

$scope.jumpToMinuteAbsolute = function jumpToMinuteCalculation() {
return moment($scope.model.media.datetime).add('m', $scope.jumpToMinute).format("HH:mm:ss");
};


$scope.previousEnabled = false;
$scope.nextEnabled = false;
Expand All @@ -384,11 +403,7 @@ angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead'])
if (linkType === "previous") {
var lowerBound = ($routeParams.start - stepBy);

if ($routeParams.start > 0) {
$scope.previousEnabled = true;
} else {
$scope.previousEnabled = false;
}
$scope.previousEnabled = $routeParams.start > 0;

if (lowerBound === 0) {
baseLink.end = lowerBound + stepBy;
Expand Down Expand Up @@ -419,11 +434,7 @@ angular.module('bawApp.listen', ['decipher.tags', 'ui.bootstrap.typeahead'])
end: (($routeParams.end + stepBy < maxEnd) ? $routeParams.end + stepBy : maxEnd)
});

if ($routeParams.end < $scope.model.audioRecording.durationSeconds - constants.listen.minAudioDurationSeconds) {
$scope.nextEnabled = true;
} else {
$scope.nextEnabled = false;
}
$scope.nextEnabled = $routeParams.end < $scope.model.audioRecording.durationSeconds - constants.listen.minAudioDurationSeconds;

return uriNext;
}
Expand Down
10 changes: 6 additions & 4 deletions src/app/listen/listen.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ <h1 id="chunkInfo" class="row">
Jump to minute:
<input ng-class="{'hide-thumb' : jumpToHide}" type="range" min="0" max="{{jumpToMax}}"
ng-slider="jumpToMinute" step="1">
<span>{{jumpToMinute}}</span>
<span>{{jumpToMinuteAbsolute()}}</span>
<button class="btn btn-default" ng-click="jumpTo()">Go</button>
</span>
</div>
Expand All @@ -46,7 +46,7 @@ <h1 id="chunkInfo" class="row">

<div id="chunkTimeStamps" class="clear-pseudo center-block">

<span class="left"> <span class="hint relative-recording-time hint--right">{{startOffsetChunk()}}</span></span>
<span class="left"> <span class="hint absolute-time hint--right">{{startOffsetAbsolute}}</span></span>

<div class="btn-toolbar">

Expand All @@ -73,7 +73,7 @@ <h1 id="chunkInfo" class="row">
<div class="btn-group">
<span class="position btn btn-default">
<!--<span class="hint relative-chunk-time hint--bottom">{{currentOffsetChunk()}}</span><br/>-->
<span class="hint relative-recording-time hint--bottom">{{currentOffsetRecording()}}</span>
<span class="hint absolute-time hint--bottom">{{currentOffsetAbsolute()}}</span>
</span>

</div>
Expand All @@ -83,7 +83,7 @@ <h1 id="chunkInfo" class="row">

</div>

<span class="right"> <span class="hint relative-recording-time hint--left">{{endOffsetChunk()}}</span></span>
<span class="right"> <span class="hint absolute-time hint--left">{{endOffsetAbsolute}}</span></span>

</div>

Expand Down Expand Up @@ -302,6 +302,8 @@ <h2 class="debug-ui">Stats</h2>
On screen: <span class="hint absolute-time hint--top">{{absoluteDateChunkStart() | moment:"format":"dddd, MMMM Do YYYY, HH:mm:ss ZZ"}}</span>
, Duration of chunk: <span class="hint duration hint--top">{{durationChunk()}} </span>
</li>

<span class="hint relative-recording-time hint--bottom">{{currentOffsetRecording()}}</span>
</ul>

<!--<baw-debug-info></baw-debug-info>-->
Expand Down
2 changes: 1 addition & 1 deletion src/sass/_time_formats.scss
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@

.absolute-time {
@extend .time;
@include hint-custom-color($time-absolute-color, "A date and time");
@include hint-custom-color($time-absolute-color, "A real point in time");

@include arrow-border-color($time-absolute-color, "true");
}
Expand Down

0 comments on commit 26bbc07

Please sign in to comment.