]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#674] Fixes indentation of Popcorn.util.toSeconds() block
authorRick Waldron <waldron.rick@gmail.com>
Tue, 2 Aug 2011 21:28:51 +0000 (17:28 -0400)
committerRick Waldron <waldron.rick@gmail.com>
Tue, 2 Aug 2011 21:28:51 +0000 (17:28 -0400)
popcorn.js

index fb6cb938c9483673821095b4d295ba882803b1c7..9d31bc6d39b76a6f20d5362cf9eb12a78430d820 100644 (file)
     // 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 ];
     }
   };