Skip to content

Commit

Permalink
[#674] Fixes indentation of Popcorn.util.toSeconds() block
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Aug 2, 2011
1 parent 05102bc commit 12d0e59
Showing 1 changed file with 36 additions and 36 deletions.
72 changes: 36 additions & 36 deletions popcorn.js
Expand Up @@ -1462,54 +1462,54 @@
// HH:MM:SS;FF
// Hours and minutes are optional. They default to 0
toSeconds: function( timeStr, framerate ) {
// Hours and minutes are optional
// Seconds must be specified
// Seconds can be followed by milliseconds OR by the frame information
var validTimeFormat = /^([0-9]+:){0,2}[0-9]+([.;][0-9]+)?$/,
errorMessage = "Invalid time format",
digitPairs, lastIndex, lastPair, firstPair,
frameInfo, frameTime;

if ( typeof timeStr === "number" ) {
return timeStr;
}

if ( typeof timeStr === "string" &&
!validTimeFormat.test( timeStr ) ) {
Popcorn.error( errorMessage );
}
// Hours and minutes are optional
// Seconds must be specified
// Seconds can be followed by milliseconds OR by the frame information
var validTimeFormat = /^([0-9]+:){0,2}[0-9]+([.;][0-9]+)?$/,
errorMessage = "Invalid time format",
digitPairs, lastIndex, lastPair, firstPair,
frameInfo, frameTime;

if ( typeof timeStr === "number" ) {
return timeStr;
}

digitPairs = timeStr.split( ":" );
lastIndex = digitPairs.length - 1;
lastPair = digitPairs[ lastIndex ];
if ( typeof timeStr === "string" &&
!validTimeFormat.test( timeStr ) ) {
Popcorn.error( errorMessage );
}

// Fix last element:
if ( lastPair.indexOf( ";" ) > -1 ) {
digitPairs = timeStr.split( ":" );
lastIndex = digitPairs.length - 1;
lastPair = digitPairs[ lastIndex ];

frameInfo = lastPair.split( ";" );
frameTime = 0;
// Fix last element:
if ( lastPair.indexOf( ";" ) > -1 ) {

if ( framerate && ( typeof framerate === "number" ) ) {
frameTime = parseFloat( frameInfo[ 1 ], 10 ) / framerate;
}
frameInfo = lastPair.split( ";" );
frameTime = 0;

digitPairs[ lastIndex ] = parseInt( frameInfo[ 0 ], 10 ) + frameTime;
if ( framerate && ( typeof framerate === "number" ) ) {
frameTime = parseFloat( frameInfo[ 1 ], 10 ) / framerate;
}

firstPair = digitPairs[ 0 ];
digitPairs[ lastIndex ] = parseInt( frameInfo[ 0 ], 10 ) + frameTime;
}

firstPair = digitPairs[ 0 ];

return {
return {

1: parseFloat( firstPair, 10 ),
1: parseFloat( firstPair, 10 ),

2: ( parseInt( firstPair, 10 ) * 60 ) +
parseFloat( digitPairs[ 1 ], 10 ),
2: ( parseInt( firstPair, 10 ) * 60 ) +
parseFloat( digitPairs[ 1 ], 10 ),

3: ( parseInt( firstPair, 10 ) * 3600 ) +
( parseInt( digitPairs[ 1 ], 10 ) * 60 ) +
parseFloat( digitPairs[ 2 ], 10 )
3: ( parseInt( firstPair, 10 ) * 3600 ) +
( parseInt( digitPairs[ 1 ], 10 ) * 60 ) +
parseFloat( digitPairs[ 2 ], 10 )

}[ digitPairs.length || 1 ];
}[ digitPairs.length || 1 ];
}
};

Expand Down

0 comments on commit 12d0e59

Please sign in to comment.