From e2c63691b8f21f790e14254b93840807a60873a6 Mon Sep 17 00:00:00 2001 From: rwldrn Date: Mon, 20 Dec 2010 10:59:32 -0500 Subject: [PATCH] Linting --- popcorn.js | 67 +++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/popcorn.js b/popcorn.js index 0bb56eb..319fdd9 100644 --- a/popcorn.js +++ b/popcorn.js @@ -6,9 +6,6 @@ hasOwn = Object.prototype.hasOwnProperty, slice = Array.prototype.slice, - // intentionally left undefined - undef, - // ID string matching rIdExp = /^(#([\w\-\_\.]+))$/, @@ -145,17 +142,22 @@ } 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); } @@ -308,33 +310,33 @@ 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 } } @@ -402,7 +404,7 @@ 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); @@ -422,7 +424,7 @@ }, listen: function ( type, fn ) { - var self = this, hasEvents = true, ns = ''; + var self = this, hasEvents = true; if ( !this.data.events[type] ) { this.data.events[type] = {}; @@ -503,8 +505,7 @@ 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 = [], @@ -611,9 +612,7 @@ // 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; @@ -650,7 +649,7 @@ // the events commence if ( "_setup" in setup && typeof setup._setup === "function" ) { - setup._setup.call(self, options); + setup._setup.call( this, options); } @@ -713,7 +712,7 @@ type: 'GET', async: true, xhr: function() { - return new XMLHttpRequest(); + return new global.XMLHttpRequest(); } }; @@ -735,9 +734,9 @@ 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 ) { @@ -762,7 +761,7 @@ - // 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); -- 2.43.0