codecombat/app/views/admin/CodeLogsView.coffee
Josh Callebaut c4652d82e2 Implements the SPADE logger into the SpellView
* Updates spade.js vendor file, adds a sublime-project for developers to use
* Moves server logic away from handlers
* Moves session update logic to middleware, sets up server schema to autorender IDs as ObjectIDs
* Modernizes the supermodel loading scheme and switches from constructor to initalize
2016-04-26 09:56:30 -07:00

43 lines
1.2 KiB
CoffeeScript

RootView = require 'views/core/RootView'
template = require 'templates/admin/codelogs-view'
CodeLogCollection = require 'collections/CodeLogs'
CodeLog = require 'models/CodeLog'
utils = require 'core/utils'
module.exports = class CodeLogsView extends RootView
template: template
id: 'codelogs-view'
tooltip: null
events:
'click .playback': 'onClickPlayback'
initialize: ->
@spade = new Spade()
@codelogs = new CodeLogCollection()
@supermodel.trackRequest(@codelogs.fetch())
onClickPlayback: (e) ->
@deleteTooltip()
events = LZString.decompressFromUTF16($(e.target).data('codelog'))
events = @spade.expand(JSON.parse(events))
@tooltip = $(document.createElement('textarea'))
@tooltip.attr('id', "codelogs-tooltip")
@tooltip.css({left: e.pageX + 20, top: e.pageY}) # Position near the cursor
@tooltip.blur @onBlurTooltip
@$('#codelogs-view').append @tooltip
@tooltip.focus()
@spade.play(events, @tooltip.context)
deleteTooltip: ->
if @tooltip?
@tooltip.off 'blur'
@tooltip.remove()
@tooltip = null
onBlurTooltip: (e) =>
@deleteTooltip()
destroy: ->
@deleteTooltip()
super()