From 319b45ac31acdc50935c3de4da46e14e68395a1b Mon Sep 17 00:00:00 2001 From: Jonathan Duran Date: Fri, 16 Mar 2012 16:23:51 -0700 Subject: Consolidate conversion functions Signed-off-by: Jonathan Duran --- .../Timeline/TimelinePanel.reel/TimelinePanel.js | 53 ++++++++-------------- 1 file changed, 19 insertions(+), 34 deletions(-) (limited to 'js') diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js index 191228af..21ecdc39 100644 --- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js +++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js @@ -538,33 +538,6 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { } }, - updateTimeText:{ - value:function (millisec) { - var timeText; - var sec = (Math.floor((millisec / 1000))) % 60; - var min = (Math.floor((millisec / 1000) / 60)) % 60; - var milliSec = String(Math.round(millisec / 10)); - var returnMillisec = milliSec.slice(milliSec.length - 2, milliSec.length); - var returnSec; - var returnMin; - if (sec < 10) { - returnSec = "0" + sec; - } else { - returnSec = sec; - } - if (min < 10) { - returnMin = "0" + min; - } else { - returnMin = min; - } - if (millisec == 0) { - returnMillisec = "00"; - } - timeText = returnMin + ":" + returnSec + ":" + returnMillisec; - this.timetext.innerHTML = timeText; - } - }, - deselectTweens:{ value:function () { for (var i = 0; i < this.selectedTweens.length; i++) { @@ -771,12 +744,24 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { calculateTimeMarkerValue:{ value:function (currentMarker) { - var timeToReturn; var currentMilliseconds = currentMarker * this.millisecondsOffset; - var sec = (Math.floor((currentMilliseconds / 1000))) % 60; - var min = (Math.floor((currentMilliseconds / 1000) / 60)) % 60; - var milliSec = String(Math.round(currentMilliseconds / 10)); - var returnMillisec = milliSec.slice(milliSec.length - 2, milliSec.length); + return this.convertMillisecondsToTime(currentMilliseconds); + } + }, + + updateTimeText:{ + value:function (millisec) { + this.timetext.innerHTML = this.convertMillisecondsToTime(millisec); + } + }, + + convertMillisecondsToTime:{ + value:function(millisec){ + var timeToReturn; + var sec = (Math.floor((millisec / 1000))) % 60; + var min = (Math.floor((millisec / 1000) / 60)) % 60; + var milliSeconds = String(Math.round(millisec / 10)); + var returnMillisec = milliSeconds.slice(milliSeconds.length - 2, milliSeconds.length); var returnSec; var returnMin; if (sec < 10) { @@ -789,8 +774,8 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { } else { returnMin = min; } - if (currentMarker == 0) { - returnMillisec = "00"; + if (returnMillisec == "0") { + returnMillisec = "0" + returnMillisec; } timeToReturn = returnMin + ":" + returnSec + ":" + returnMillisec; return timeToReturn; -- cgit v1.2.3