]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#668] Cleanup unused vars and pointless conditions
authorRick Waldron <waldron.rick@gmail.com>
Fri, 29 Jul 2011 17:38:49 +0000 (13:38 -0400)
committerRick Waldron <waldron.rick@gmail.com>
Fri, 29 Jul 2011 17:40:22 +0000 (13:40 -0400)
popcorn.js

index a5941eec1fa57276f9cf21106abcec7525318556..354e7cdf4ee55543f6d217289f2982e4b7be34d8 100644 (file)
         // 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, digitPairsLength, lastIndex, lastElement,
+            digitPairs, lastIndex, lastPair, firstPair,
             frameInfo, frameTime;
 
         if ( typeof timeStr === "number" ) {
           return timeStr;
-        } else if ( typeof timeStr === "string" ) {
-          if ( !validTimeFormat.test( timeStr ) ) {
-            Popcorn.error( errorMessage );
-          }
-        } else {
+        }
+
+        if ( typeof timeStr === "string" &&
+              !validTimeFormat.test( timeStr ) ) {
           Popcorn.error( errorMessage );
         }
 
         digitPairs = timeStr.split( ":" );
         lastIndex = digitPairs.length - 1;
-        lastElement = digitPairs[ lastIndex ];
+        lastPair = digitPairs[ lastIndex ];
 
         // Fix last element:
-        if ( lastElement.indexOf( ";" ) > -1 ) {
+        if ( lastPair.indexOf( ";" ) > -1 ) {
 
-          frameInfo = lastElement.split( ";" );
+          frameInfo = lastPair.split( ";" );
           frameTime = 0;
 
           if ( framerate && ( typeof framerate === "number" ) ) {
           digitPairs[ lastIndex ] = parseInt( frameInfo[ 0 ], 10 ) + frameTime;
         }
 
+        firstPair = digitPairs[ 0 ];
+
         return {
 
-          1: parseFloat( digitPairs[ 0 ], 10 ),
+          1: parseFloat( firstPair, 10 ),
 
-          2: ( parseInt( digitPairs[ 0 ], 10 ) * 60 ) +
+          2: ( parseInt( firstPair, 10 ) * 60 ) +
                 parseFloat( digitPairs[ 1 ], 10 ),
 
-          3: ( parseInt( digitPairs[ 0 ], 10 ) * 3600 ) +
+          3: ( parseInt( firstPair, 10 ) * 3600 ) +
               ( parseInt( digitPairs[ 1 ], 10 ) * 60 ) +
                 parseFloat( digitPairs[ 2 ], 10 )