From 26bbc07c68b395776f80e93a4e8306d9ee1e96c7 Mon Sep 17 00:00:00 2001 From: Anthony Truskinger Date: Fri, 7 Feb 2014 04:43:01 +1000 Subject: [PATCH] Converted times in annotation editor to absolute formats. Closes #89 --- src/app/listen/listen.js | 55 ++++++++++++++++++++-------------- src/app/listen/listen.tpl.html | 10 ++++--- src/sass/_time_formats.scss | 2 +- 3 files changed, 40 insertions(+), 27 deletions(-) diff --git a/src/app/listen/listen.js b/src/app/listen/listen.js index e2a75124..29d96234 100644 --- a/src/app/listen/listen.js +++ b/src/app/listen/listen.js @@ -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, @@ -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"); @@ -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) { @@ -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; @@ -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; @@ -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; @@ -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; } diff --git a/src/app/listen/listen.tpl.html b/src/app/listen/listen.tpl.html index dda07246..fe63fc24 100644 --- a/src/app/listen/listen.tpl.html +++ b/src/app/listen/listen.tpl.html @@ -37,7 +37,7 @@

Jump to minute: - {{jumpToMinute}} + {{jumpToMinuteAbsolute()}} @@ -46,7 +46,7 @@

- {{startOffsetChunk()}} + {{startOffsetAbsolute}}
@@ -73,7 +73,7 @@

- {{currentOffsetRecording()}} + {{currentOffsetAbsolute()}}
@@ -83,7 +83,7 @@

- {{endOffsetChunk()}} + {{endOffsetAbsolute}}
@@ -302,6 +302,8 @@

Stats

On screen: {{absoluteDateChunkStart() | moment:"format":"dddd, MMMM Do YYYY, HH:mm:ss ZZ"}} , Duration of chunk: {{durationChunk()}} + + {{currentOffsetRecording()}} diff --git a/src/sass/_time_formats.scss b/src/sass/_time_formats.scss index dae7d02b..7a2aa2e4 100644 --- a/src/sass/_time_formats.scss +++ b/src/sass/_time_formats.scss @@ -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"); }