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

Method initSpectateCode

app/views/play/SpectateView.js:318–348  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

316 }
317
318 initSpectateCode () {
319 const hasSubmittedCode = (this.session.get('submittedCode') != null) && (this.otherSession.get('submittedCode') != null)
320 if (!me.isAdmin() && (!me.activeProducts('esports').length || !hasSubmittedCode)) { return this.$el.find('.spectate-code').remove() }
321 this.editors = {}
322 for (const team of ['humans', 'ogres']) {
323 let left, left1
324 const session = team === 'humans' ? this.session : this.otherSession
325 this.$el.find('.spectate-code.team-' + team + ' .programming-language').text(utils.capitalLanguages[session.get('codeLanguage')])
326 const editor = (this.editors[team] = window.ace.edit(this.$el.find('.spectate-code.team-' + team + ' .ace')[0]))
327 const aceSession = editor.getSession()
328 aceSession.setMode(aceUtils.aceEditModes[session.get('submittedCodeLanguage')])
329 aceSession.setWrapLimitRange(null)
330 aceSession.setUseWrapMode(false)
331 aceSession.setNewLineMode('unix')
332 aceSession.setUseSoftTabs(true)
333 editor.setFontSize('10px')
334 editor.setTheme('ace/theme/textmate')
335 editor.setDisplayIndentGuides(false)
336 editor.setShowPrintMargin(false)
337 editor.setShowInvisibles(false)
338 editor.setAnimatedScroll(true)
339 editor.setShowFoldWidgets(true)
340 editor.$blockScrolling = Infinity
341 editor.setReadOnly(true)
342 const codeTeam = this.level.isType('ladder') ? 'humans' : (left = session.get('team')) != null ? left : team
343 editor.setValue((left1 = __guard__(__guard__(session.get('submittedCode'), x1 => x1['hero-placeholder' + (codeTeam === 'ogres' ? '-1' : '')]), x => x.plan)) != null ? left1 : '')
344 editor.clearSelection()
345 }
346 this.$el.find('.spectate-code').addClass('shown')
347 return this.$el.addClass('showing-code')
348 }
349
350 onMouseEnterSpectateCode (e) {
351 const team = $(e.target).closest('.spectate-code').hasClass('team-humans') ? 'humans' : 'ogres'

Callers 1

onLevelLoaderLoadedMethod · 0.95

Calls 6

isAdminMethod · 0.80
activeProductsMethod · 0.80
isTypeMethod · 0.80
clearSelectionMethod · 0.80
__guard__Function · 0.70
getMethod · 0.45

Tested by

no test coverage detected