removePlugin: function( name ) {
var byStart = this.data.trackEvents.byStart,
- byEnd = this.data.trackEvents.byEnd;
+ byEnd = this.data.trackEvents.byEnd,
+ idx, rl, sl;
delete Popcorn.p[ name ];
// remove plugin reference from registry
- for ( var r = 0, rl = Popcorn.registry.length; r < rl; r++ ) {
- if ( Popcorn.registry[r].type === name ) {
- Popcorn.registry.splice(r, 1);
+ for ( idx = 0, rl = Popcorn.registry.length; idx < rl; idx++ ) {
+ if ( Popcorn.registry[ idx ].type === name ) {
+ Popcorn.registry.splice( idx, 1 );
break; // plugin found, stop checking
}
}
// remove all trackEvents
- 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 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
+ for ( idx = 0, sl = byStart.length; idx < sl; idx++ ) {
+
+ if ( ( byStart[ idx ] && byEnd[ idx ] ) &&
+ ( byStart[ idx ]._natives && byStart[ idx ]._natives.type === name ) &&
+ ( byEnd[ idx ]._natives && byEnd[ idx ]._natives.type === name ) ) {
+
+ byStart.splice( idx, 1 );
+ byEnd.splice( idx, 1 );
+
+ // update for loop if something removed, but keep checking
+ idx--; sl--;
+ if ( this.data.trackEvents.startIndex <= idx ) {
+ this.data.trackEvents.startIndex--;
+ this.data.trackEvents.endIndex--;
}
}
}
test("Last Check", function () {
// ALWAYS RUN LAST
-
- expect(1)
try {
equals( Setup.getGlobalSize(), Setup.globalSize + 1 , "Popcorn API did not leak");
- plus();
+
+ if ( !Setup.globalDiff.length ) {
+ //console.log(Setup.globalDiff);
+ }
} catch (e) {};
-// suppress console log errors
-if ( !window['console'] ) {
- var console = {},
- methods = 'log debug info warn error exception assert dir dirxml trace group groupEnd groupCollapsed time timeEnd profile profileEnd count clear notifyFirebug getFirebugElement firebug element'.split(' ');
-
- for ( var m in methods ) {
- console[ methods[m] ] = function () {
- //Array.prototype.slice.call(arguments)
- };
- }
-}
-
-
-(function (global) {
-
- // Store the number of global properties that exist prior to Popcorn API definition
-
- var Setup = {
- globalSize: 0
- };
-
- Setup.getGlobalSize = function() {
-
- var size = 0;
-
- for( var p in window ) {
- if ( p !== "_firebug" ) {
- size++;
- }
- }
-
- // account for self
- size++;
-
- // Store the number of global properties internally
- if ( !Setup.globalSize ) {
- Setup.globalSize = size;
- }
-
- return size;
- };
-
-
-
- Setup.eventset = "loadstart progress suspend emptied stalled play pause " +
- "loadedmetadata loadeddata waiting playing canplay canplaythrough " +
- "seeking seeked timeupdate ended ratechange durationchange volumechange";
-
- Setup.events = Setup.eventset.split(/\s+/g);
-
-
-
- global.Setup = Setup;
-
-})(window);
-
-
-Setup.getGlobalSize();
-
+// suppress console log errors\r
+if ( !window['console'] ) {\r
+ var console = {}, \r
+ methods = 'log debug info warn error exception assert dir dirxml trace group groupEnd groupCollapsed time timeEnd profile profileEnd count clear notifyFirebug getFirebugElement firebug element'.split(' ');\r
+ \r
+ for ( var m in methods ) {\r
+ console[ methods[m] ] = function () {\r
+ //Array.prototype.slice.call(arguments)\r
+ };\r
+ } \r
+}\r
+\r
+\r
+(function (global) { \r
+ \r
+ // Store the number of global properties that exist prior to Popcorn API definition\r
+ \r
+ var Setup = {\r
+ hasRun: false, \r
+ globalSize: 0, \r
+ globalCache: [], \r
+ globalDiff: []\r
+ };\r
+\r
+ Setup.getGlobalSize = function() {\r
+\r
+ var size = 0;\r
+\r
+ for( var p in window ) {\r
+ if ( p !== "_firebug" ) {\r
+ size++;\r
+ \r
+ if ( !Setup.hasRun ) {\r
+ Setup.globalCache.push( p );\r
+ } else {\r
+ if ( Setup.globalCache.indexOf( p ) === -1 ) {\r
+ Setup.globalDiff.push( p );\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ // account for self\r
+ size++;\r
+ \r
+ // Store the number of global properties internally\r
+ if ( !Setup.globalSize ) {\r
+ Setup.globalSize = size;\r
+ }\r
+ \r
+ if ( !Setup.hasRun ) {\r
+ Setup.hasRun = true;\r
+ }\r
+ \r
+ return size;\r
+ };\r
+ \r
+ \r
+ \r
+ Setup.eventset = "loadstart progress suspend emptied stalled play pause " + \r
+ "loadedmetadata loadeddata waiting playing canplay canplaythrough " + \r
+ "seeking seeked timeupdate ended ratechange durationchange volumechange";\r
+ \r
+ Setup.events = Setup.eventset.split(/\s+/g); \r
+\r
+ \r
+ \r
+ global.Setup = Setup;\r
+\r
+})(window);\r
+\r
+\r
+Setup.getGlobalSize();\r
+\r