Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
options = options || {};
this.baseURL = options.baseURL || '';
this.formats = options.formats || ['webm', 'mp4', 'ogv', 'ogg'];
this.eventName = options.eventName || 'canplaythrough';
this.assetsLoaded = 0;
this.totalAssets = 0;
this.crossOrigin = options.crossOrigin;
this.cache = Object.create(null); // Pure hash, no prototype
this.el = document.createElement('div');
this.el.style.display = 'none';
document.body.appendChild(this.el);
this.onError = this.onError.bind(this);
}
VideoCache.prototype = Object.create(Emitter.prototype);
VideoCache.prototype.load = function(videos) {
this.totalAssets = videos.length;
videos.forEach(function(url) {
var video = document.createElement('video');
var formats = url.formats || this.formats;
var videoId = url.path || url;
// Clean listeners on load
video.onerror = this.onError;
var onVideoReady = function(video) {
video.onerror = null;
video['on' + this.eventName] = null;
it('should win horizontally', function () {
const game = new Game();
game.setPlayers({ gameType: '2P' });
game.startGame();
sinon.spy(Emitter.prototype, 'emit');
try {
placeChips({
game,
columns: [2, 2, 3, 3, 4, 4, 5]
});
expect(Emitter.prototype.emit).to.have.been.calledWith('game:declare-winner');
} finally {
Emitter.prototype.emit.restore();
}
expect(game.winner).not.to.be.null;
expect(game.winner.name).to.equal('Human 1');
});
it('should end', function () {
const game = new Game();
game.setPlayers({ gameType: '2P' });
game.startGame();
sinon.spy(Emitter.prototype, 'emit');
try {
game.endGame();
expect(Emitter.prototype.emit).to.have.been.calledWith('game:end');
} finally {
Emitter.prototype.emit.restore();
}
expect(game.currentPlayer).to.be.null;
expect(game.inProgress).to.be.false;
expect(game.pendingChip).to.be.null;
});
it('should win horizontally', function () {
var game = new Game();
game.setPlayers(2);
game.startGame();
sinon.spy(Emitter.prototype, 'emit');
try {
placeChips({
game: game,
columns: [2, 2, 3, 3, 4, 4, 5]
});
expect(Emitter.prototype.emit).to.have.been.calledWith('game:declare-winner');
} finally {
Emitter.prototype.emit.restore();
}
expect(game.winner).not.to.be.null;
expect(game.winner.name).to.equal('Human 1');
});
it('should start', function () {
const game = new Game();
game.setPlayers({ gameType: '2P' });
sinon.spy(Emitter.prototype, 'emit');
try {
game.startGame();
expect(Emitter.prototype.emit).to.have.been.calledWith('game:start');
} finally {
Emitter.prototype.emit.restore();
}
expect(game.currentPlayer).to.equal(game.players[0]);
expect(game.inProgress).to.be.true;
});
it('should start', function () {
const game = new Game();
game.setPlayers({ gameType: '2P' });
sinon.spy(Emitter.prototype, 'emit');
try {
game.startGame();
expect(Emitter.prototype.emit).to.have.been.calledWith('game:start');
} finally {
Emitter.prototype.emit.restore();
}
expect(game.currentPlayer).to.equal(game.players[0]);
expect(game.inProgress).to.be.true;
});
it('should win horizontally', function () {
const game = new Game();
game.setPlayers({ gameType: '2P' });
game.startGame();
sinon.spy(Emitter.prototype, 'emit');
try {
placeChips({
game,
columns: [2, 2, 3, 3, 4, 4, 5]
});
expect(Emitter.prototype.emit).to.have.been.calledWith('game:declare-winner');
} finally {
Emitter.prototype.emit.restore();
}
expect(game.winner).not.to.be.null;
expect(game.winner.name).to.equal('Human 1');
});
EventEmitter.mixin = function(obj) {
assign(typeof obj === 'function' ? obj.prototype : obj, EventEmitter.prototype);
};
}
}
return target
}
/**
* Support events, e.g. 'authenticated'
*
* The 'authenticated' event is emitted in response to a
* local storage 'anvil.connect' event when the user is authenticated.
*
* This can be leveraged to react to an authentiation performed in
* other windows or tabs.
*/
extend(Anvil, TinyEmitter.prototype)
/**
* Provider configuration
*/
function configure (options) {
var params
Anvil.issuer = options.issuer
jwks.setJWK(options.jwk)
Anvil.params = params = {}
params.response_type = options.response_type || 'id_token token'
params.client_id = options.client_id
params.redirect_uri = options.redirect_uri
params.scope = [
'openid',
'profile'
hasAutoplay: opts.hasAutoplay === true ? true : false,
hasCueAutoplay: (opts.hasCueAutoplay || opts.hasAutoplay) === true ? true : false
};
this.el = el;
this._isPopulated = false;
this._hasPlayed = false;
this._isPlaying = false;
this.playbackInterval = -1;
this.onPlayerPopulated = this.onPlayerPopulated.bind(this);
this.onPlayerStateChange = this.onPlayerStateChange.bind(this);
this.onPlaybackUpdate = this.onPlaybackUpdate.bind(this);
}
Youtube.prototype = Object.create(Emitter.prototype);
Youtube.prototype.constructor = Youtube;
Youtube.prototype.populatePlayer = function(videoId, startTime) {
this.player = new YT.Player(this.el, {
width: '100%',
height: '100%',
videoId: videoId,
playerVars: {
modestbranding: 1,
rel: 0,
controls: this.options.controls === true ? 1 : 0,
showinfo: 0,
allowfullscreen: this.options.allowFullscreen,
autoplay: this.options.hasAutoplay === true ? 1 : 0,
wmode: 'transparent',
startSeconds: startTime,