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

Method afterRender

app/views/admin/CodePlaybackView.js:51–79  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

49 // @spade.play(@options.events, $('#codearea').context)
50
51 afterRender () {
52 if (this.options.events == null) { return }
53 const initialSource = this.options.events[0].difContent
54 let codeLanguageGuess = 'python'
55 if (/^ *var /m.test(initialSource)) { codeLanguageGuess = 'javascript' }
56 if (/^\/\//m.test(initialSource)) { codeLanguageGuess = 'javascript' }
57 this.ace = aceUtils.initializeACE(this.$('#acearea')[0], codeLanguageGuess)
58 this.ace.$blockScrolling = Infinity
59 // @ace.setValue(@options.events[0].difContent)
60 this.spade.renderToElem(this.options.events, this.ace)
61 this.$el.find('#start-time').text('0s')
62 this.$el.find('#end-time').text((this.maxTime / 1000) + 's')
63 return (() => {
64 const result = []
65 for (const ev of Array.from(this.options.events)) {
66 const div = $('<div></div>')
67 div.addClass('event')
68 const percent = (ev.timestamp / this.maxTime) * 100
69 const offset = (15 * ev.timestamp) / this.maxTime
70 if (ev.eventName) {
71 div.css('background-color', 'rgba(255, 100, 100, 0.75)')
72 div.css('z-index', '100')
73 }
74 div.css('left', `calc(${percent}% + 7px - ${offset}px)`)
75 result.push(this.$el.find('#slider-container').prepend(div))
76 }
77 return result
78 })()
79 }
80
81 updateSlider () {
82 const value = (this.spade.elapsedTime / this.maxTime) * 100

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected