(options, levelID, leagueType, leagueID)
| 66 | module.exports = (LadderView = (function () { |
| 67 | LadderView = class LadderView extends RootView { |
| 68 | constructor (options, levelID, leagueType, leagueID) { |
| 69 | super(options) |
| 70 | this.levelID = levelID |
| 71 | this.leagueType = leagueType |
| 72 | this.leagueID = leagueID |
| 73 | this.refreshViews = this.refreshViews.bind(this) |
| 74 | this.leaderboardRankings = [] |
| 75 | |
| 76 | let tournamentEndDate, tournamentStartDate |
| 77 | this.level = this.supermodel.loadModel(new Level({ _id: this.levelID })).model |
| 78 | this.level.once('sync', level => { |
| 79 | this.setMeta({ title: $.i18n.t('ladder.arena_title', { arena: level.get('name') }) }) |
| 80 | }) |
| 81 | |
| 82 | const onLoaded = () => { |
| 83 | if (this.destroyed) { return } |
| 84 | if (this.level.get('description')) { this.levelDescription = marked(utils.i18n(this.level.attributes, 'description')).replace(/<img.*?>/, '') } |
| 85 | this.levelBanner = this.level.get('banner') |
| 86 | this.teams = teamDataFromLevel(this.level) |
| 87 | } |
| 88 | |
| 89 | if (this.level.loaded) { onLoaded() } else { this.level.once('sync', onLoaded) } |
| 90 | this.sessions = this.supermodel.loadCollection(new LevelSessionsCollection(this.levelID), 'your_sessions', { cache: false }).model |
| 91 | this.listenToOnce(this.sessions, 'sync', this.onSessionsLoaded) |
| 92 | this.winners = require('./tournament_results')[this.levelID] |
| 93 | |
| 94 | if (tournamentEndDate = { greed: 1402444800000, 'criss-cross': 1410912000000, 'zero-sum': 1428364800000, 'ace-of-coders': 1444867200000, 'battle-of-red-cliffs': 1598918400000 }[this.levelID]) { |
| 95 | this.tournamentTimeLeftString = moment(new Date(tournamentEndDate)).fromNow() |
| 96 | } |
| 97 | if (tournamentStartDate = { 'zero-sum': 1427472000000, 'ace-of-coders': 1442417400000, 'battle-of-red-cliffs': 1596295800000 }[this.levelID]) { |
| 98 | this.tournamentTimeElapsedString = moment(new Date(tournamentStartDate)).fromNow() |
| 99 | } |
| 100 | |
| 101 | this.calcTimeOffset() |
| 102 | this.mandate = this.supermodel.loadModel(new Mandate()).model |
| 103 | |
| 104 | this.tournamentId = utils.getQueryVariable('tournament') |
| 105 | if (this.tournamentId) { |
| 106 | const url = `/db/tournament/${this.tournamentId}/submission` |
| 107 | this.myTournamentSubmission = new TournamentSubmission().setURL(url) |
| 108 | this.supermodel.loadModel(this.myTournamentSubmission) |
| 109 | } |
| 110 | |
| 111 | // TODO: query for matching tournaments for the level and show tournaments list to click into results |
| 112 | this.loadLeague() |
| 113 | this.urls = require('core/urls') |
| 114 | |
| 115 | if (this.leagueType === 'clan') { |
| 116 | utils.getAnonymizationStatus(this.leagueID, this.supermodel).then(anonymous => { |
| 117 | this.anonymousPlayerName = anonymous |
| 118 | }) |
| 119 | } |
| 120 | |
| 121 | if (this.tournamentId) { |
| 122 | this.checkTournamentCloseInterval = setInterval(this.checkTournamentClose.bind(this), 3000) |
| 123 | this.checkTournamentClose() |
| 124 | } |
| 125 |
nothing calls this directly
no test coverage detected