MCPcopy Create free account
hub / github.com/codecombat/codecombat / onClickNewSpectateButton

Method onClickNewSpectateButton

app/views/ladder/LadderView.js:500–513  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

498 }
499
500 onClickNewSpectateButton () {
501 const player1Index = parseInt(this.$el.find('#spectate-player-1').val().split(':')[0]) - 1
502 const player2Index = parseInt(this.$el.find('#spectate-player-2').val().split(':')[0]) - 1
503 const player1 = this.leaderboardRankings[player1Index]
504 const player2 = this.leaderboardRankings[player2Index]
505 const humanSession = player1 != null ? player1[player1.length - 1] : undefined
506 const ogreSession = player2 != null ? player2[player2.length - 1] : undefined
507 let url = `/play/spectate/${this.level.get('slug')}?`
508 if (humanSession && ogreSession) { url += `session-one=${humanSession}&session-two=${ogreSession}` }
509 if (this.league) { url += '&league=' + this.league.id }
510 if (key.command) { url += '&autoplay=false' }
511 if (this.tournamentState === 'ended') { url += '&tournament=' + this.tournamentId }
512 return window.open(url, key.command ? '_blank' : 'spectate') // New tab for spectating specific matches
513 }
514
515 destroy () {
516 clearInterval(this.refreshInterval)

Callers

nothing calls this directly

Calls 2

getMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected