]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
Linting
authorrwldrn <waldron.rick@gmail.com>
Mon, 20 Dec 2010 15:59:32 +0000 (10:59 -0500)
committerrwldrn <waldron.rick@gmail.com>
Mon, 20 Dec 2010 16:09:01 +0000 (11:09 -0500)
popcorn.js

index 0bb56ebf35a6ae707bf943708a70347f15b88fc7..319fdd90eeb88e3e3452a05e71fa38a2b913db9a 100644 (file)
@@ -6,9 +6,6 @@
   hasOwn = Object.prototype.hasOwnProperty, 
   slice = Array.prototype.slice,
 
-  // intentionally left undefined
-  undef,
-
   //  ID string matching
   rIdExp  = /^(#([\w\-\_\.]+))$/, 
   
                 }
                 tracks.endIndex--;
               }
-            } else {
+            } 
+            /*
+            //  This empty block causes errors with jslint
+            
+            else {
               // When user seeks, currentTime can be equal to previousTime on the
               // timeUpdate event. We are not doing anything with this right now, but we
               // may need this at a later point and should be aware that this behavior
               // happens in both Chrome and Firefox.
             }
-
+            */
             tracks.previousUpdateTime = currentTime;
+            
           }, false);
         } else {
-          setTimeout( function() {
+          global.setTimeout( function() {
             isReady( that );
           }, 1);
         }
     removePlugin: function( name ) {
 
       var byStart = this.data.trackEvents.byStart, 
-          byEnd = this.data.trackEvents.byEnd;        
+          byEnd = this.data.trackEvents.byEnd;
   
       delete Popcorn.p[ name ];
   
       // remove plugin reference from registry
-      for ( var i = 0, rl = Popcorn.registry.length; i < rl; i++ ) {
-        if ( Popcorn.registry[i].type === name ) {
-          Popcorn.registry.splice(i, 1);
+      for ( var r = 0, rl = Popcorn.registry.length; r < rl; r++ ) {
+        if ( Popcorn.registry[r].type === name ) {
+          Popcorn.registry.splice(r, 1);
           break; // plugin found, stop checking
         }
       }
 
       // remove all trackEvents
-      for ( var i = 0, sl = byStart.length; i < sl; i++ ) {
-        if ( byStart[i] && byStart[i].natives && byStart[i].natives.type === name ) {
-          byStart.splice( i, 1 );
-          i--; sl--; // update for loop if something removed, but keep checking
-          if ( this.data.trackEvents.startIndex <= i ) {
+      for ( var s = 0, sl = byStart.length; s < sl; s++ ) {
+        if ( byStart[s] && byStart[s].natives && byStart[s].natives.type === name ) {
+          byStart.splice( s, 1 );
+          s--; sl--; // update for loop if something removed, but keep checking
+          if ( this.data.trackEvents.startIndex <= s ) {
             this.data.trackEvents.startIndex--; // write test for this
           }
         }
       }
-      for ( var i = 0, el = byEnd.length; i < el; i++ ) {
-        if ( byEnd[i] && byEnd[i].natives && byEnd[i].natives.type === name ) {
-          byEnd.splice( i, 1 );
-          i--; el--; // update for loop if something removed, but keep checking
-          if ( this.data.trackEvents.endIndex <= i ) {
+      for ( var e = 0, el = byEnd.length; e < el; e++ ) {
+        if ( byEnd[e] && byEnd[e].natives && byEnd[e].natives.type === name ) {
+          byEnd.splice( e, 1 );
+          e--; el--; // update for loop if something removed, but keep checking
+          if ( this.data.trackEvents.endIndex <= e ) {
             this.data.trackEvents.endIndex--; // write test for this
           }
         }
           if ( eventInterface ) {
           
             var evt = document.createEvent( eventInterface );
-                evt.initEvent(type, true, true, window, 1);          
+                evt.initEvent(type, true, true, global, 1);          
           
             this.video.dispatchEvent(evt);
             
       }, 
       listen: function ( type, fn ) {
         
-        var self = this, hasEvents = true, ns = '';
+        var self = this, hasEvents = true;
         
         if ( !this.data.events[type] ) {
           this.data.events[type] = {};
 
   Popcorn.removeTrackEvent  = function( obj, trackId ) {
     
-    var trackLen = obj.data.trackEvents.byStart.length, 
-        historyLen = obj.data.history.length, 
+    var historyLen = obj.data.history.length, 
         indexWasAt = 0, 
         byStart = [], 
         byEnd = [], 
     //  Provides some sugar, but ultimately extends
     //  the definition into Popcorn.p 
     
-    var natives = Popcorn.events.all, 
-
-        reserved = [ "start", "end"], 
+    var reserved = [ "start", "end"], 
         plugin = {type: name},
         pluginFn, 
         setup;
         //  the events commence
         
         if ( "_setup" in setup && typeof setup._setup === "function" ) {
-          setup._setup.call(self, options);
+          setup._setup.call( this, options);
         }
         
 
     type: 'GET',
     async: true, 
     xhr: function()  {
-      return new XMLHttpRequest();
+      return new global.XMLHttpRequest();
     }
   };   
   
   
   Popcorn.xhr.httpData = function ( settings ) {
   
-    var data, json = null,  
+    var data, json = null;  
         
-    onreadystatechange = settings.ajax.onreadystatechange = function() {
+    settings.ajax.onreadystatechange = function() {
 
       if ( settings.ajax.readyState === 4 ) { 
         
   
   
   
-  //  Exposes Popcorn and a shorthand to global context
-  global.Popcorn = global.$P = Popcorn;
+  //  Exposes Popcorn to global context
+  global.Popcorn = Popcorn;
   
-})(window, document);
+})(window, window.document);