mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-01 19:36:57 -05:00
commit
1535f36d87
9 changed files with 68 additions and 15 deletions
|
@ -37,6 +37,19 @@
|
|||
<script src="/javascripts/aether.js"></script>
|
||||
<script src="/javascripts/app.js"></script> <!-- it's all Backbone! -->
|
||||
|
||||
<script>
|
||||
window.linkedInAsyncInit = function() {
|
||||
console.log("Linkedin Async Init!");
|
||||
Backbone.Mediator.publish('linkedin-loaded');
|
||||
};
|
||||
|
||||
</script>
|
||||
<script type="text/javascript" async src="http://platform.linkedin.com/in.js">
|
||||
api_key: 75v8mv4ictvmx6
|
||||
onLoad: linkedInAsyncInit
|
||||
authorize: true
|
||||
</script>
|
||||
|
||||
<script>
|
||||
window.userObject = "userObjectTag";
|
||||
</script>
|
||||
|
|
|
@ -124,6 +124,8 @@ module.exports = class God extends CocoClass
|
|||
console.log "|#{@nick}'s debugger|", event.data.args...
|
||||
when 'debug-value-return'
|
||||
Backbone.Mediator.publish 'god:debug-value-return', event.data.serialized
|
||||
when 'debug-world-load-progress-changed'
|
||||
Backbone.Mediator.publish 'god:debug-world-load-progress-changed', event.data
|
||||
|
||||
onNewWorldCreated: (e) ->
|
||||
@currentUserCodeMap = @filterUserCodeMapWhenFromWorld e.world.userCodeMap
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
module.exports = initializeLinkedIn = ->
|
||||
window.linkedInAsyncInit = ->
|
||||
console.log "Linkedin async init success!"
|
||||
Backbone.Mediator.publish 'linkedin-loaded'
|
||||
|
||||
linkedInSnippet =
|
||||
'<script type="text/javascript" async src="http://platform.linkedin.com/in.js">
|
||||
api_key: 75v8mv4ictvmx6
|
||||
onLoad: linkedInAsyncInit
|
||||
authorize: true
|
||||
</script>'
|
||||
''
|
||||
|
||||
$('head').append(linkedInSnippet)
|
||||
|
|
|
@ -8,4 +8,11 @@
|
|||
padding: 10px
|
||||
background: transparent url(/images/level/popover_background.png)
|
||||
background-size: 100% 100%
|
||||
.progress
|
||||
position: relative
|
||||
span
|
||||
position: absolute
|
||||
display: block
|
||||
color: black
|
||||
width: 100%
|
||||
|
||||
|
|
|
@ -1,2 +1,6 @@
|
|||
div.progress
|
||||
.progress-bar(role="progressbar", aria-valuenow="50", aria-valuemin="0", aria-valuemax="100")
|
||||
span Inspecting variable...
|
||||
pre
|
||||
|
||||
code
|
|
@ -14,6 +14,7 @@ module.exports = class DebugView extends View
|
|||
subscriptions:
|
||||
'god:new-world-created': 'onNewWorld'
|
||||
'god:debug-value-return': 'handleDebugValue'
|
||||
'god:debug-world-load-progress-changed': 'handleWorldLoadProgressChanged'
|
||||
'tome:spell-shown': 'changeCurrentThangAndSpell'
|
||||
'tome:cast-spells': 'onTomeCast'
|
||||
'surface:frame-changed': 'onFrameChanged'
|
||||
|
@ -26,6 +27,7 @@ module.exports = class DebugView extends View
|
|||
@ace = options.ace
|
||||
@thang = options.thang
|
||||
@spell = options.spell
|
||||
@progress = 0
|
||||
@variableStates = {}
|
||||
@globals = {Math: Math, _: _, String: String, Number: Number, Array: Array, Object: Object} # ... add more as documented
|
||||
for className, serializedClass of serializedClasses
|
||||
|
@ -36,6 +38,7 @@ module.exports = class DebugView extends View
|
|||
@lastFrameRequested = -1
|
||||
@workerIsSimulating = false
|
||||
@spellHasChanged = false
|
||||
@debouncedTooltipUpdate = _.debounce @updateTooltipProgress, 100
|
||||
|
||||
|
||||
|
||||
|
@ -50,15 +53,30 @@ module.exports = class DebugView extends View
|
|||
|
||||
|
||||
setTooltipKeyAndValue: (key, value) =>
|
||||
@hideProgressBarAndShowText()
|
||||
message = "Time: #{@calculateCurrentTimeString()}\n#{key}: #{value}"
|
||||
@$el.find("code").text message
|
||||
@$el.show().css(@pos)
|
||||
|
||||
setTooltipText: (text) =>
|
||||
#perhaps changing styling here in the future
|
||||
@hideProgressBarAndShowText()
|
||||
@$el.find("code").text text
|
||||
@$el.show().css(@pos)
|
||||
|
||||
|
||||
setTooltipProgress: (progress) =>
|
||||
@showProgressBarAndHideText()
|
||||
@$el.find(".progress-bar").css('width',progress + '%').attr 'aria-valuenow', progress
|
||||
@$el.show().css(@pos)
|
||||
|
||||
showProgressBarAndHideText: ->
|
||||
@$el.find("pre").css("display","none")
|
||||
@$el.find(".progress").css("display","block")
|
||||
|
||||
hideProgressBarAndShowText: ->
|
||||
@$el.find("pre").css("display","block")
|
||||
@$el.find(".progress").css("display","none")
|
||||
|
||||
onTomeCast: ->
|
||||
@invalidateCache()
|
||||
|
||||
|
@ -91,7 +109,9 @@ module.exports = class DebugView extends View
|
|||
if @variableChain and not key is @variableChain.join(".") then return
|
||||
@setTooltipKeyAndValue(key,value)
|
||||
|
||||
|
||||
handleWorldLoadProgressChanged: (data) ->
|
||||
@progress = data.progress
|
||||
|
||||
afterRender: ->
|
||||
super()
|
||||
@ace.on "mousemove", @onMouseMove
|
||||
|
@ -140,7 +160,12 @@ module.exports = class DebugView extends View
|
|||
onMouseOut: (e) ->
|
||||
@variableChain = @markerRange = null
|
||||
@update()
|
||||
|
||||
|
||||
updateTooltipProgress: =>
|
||||
if @variableChain and @progress < 1
|
||||
@setTooltipProgress(@progress * 100)
|
||||
_.delay @updateTooltipProgress, 100
|
||||
|
||||
onNewWorld: (e) ->
|
||||
@thang = @options.thang = e.world.thangMap[@thang.id] if @thang
|
||||
@frameRate = e.world.frameRate
|
||||
|
@ -148,6 +173,7 @@ module.exports = class DebugView extends View
|
|||
onFrameChanged: (data) ->
|
||||
@currentFrame = data.frame
|
||||
@frameRate = data.world.frameRate
|
||||
|
||||
onSpellChangedCalculation: (data) ->
|
||||
@spellHasChanged = data.hasChangedSignificantly
|
||||
|
||||
|
@ -159,8 +185,8 @@ module.exports = class DebugView extends View
|
|||
@setTooltipKeyAndValue(@variableChain.join("."),@stringifyValue(@thang[@variableChain[1]],0))
|
||||
else if @variableChain.length is 1 and Aether.globals[@variableChain[0]]
|
||||
@setTooltipKeyAndValue(@variableChain.join("."),@stringifyValue(Aether.globals[@variableChain[0]],0))
|
||||
else if @workerIsSimulating
|
||||
@setTooltipText("World is simulating, please wait...")
|
||||
else if @workerIsSimulating and @progress < 1
|
||||
@debouncedTooltipUpdate()
|
||||
else if @currentFrame is @lastFrameRequested and (cacheValue = @retrieveValueFromCache(@thang.id, @spell.name, @variableChain, @currentFrame))
|
||||
@setTooltipKeyAndValue(@variableChain.join("."),cacheValue)
|
||||
else
|
||||
|
@ -171,7 +197,8 @@ module.exports = class DebugView extends View
|
|||
frame: @currentFrame
|
||||
if @currentFrame isnt @lastFrameRequested then @workerIsSimulating = true
|
||||
@lastFrameRequested = @currentFrame
|
||||
@setTooltipText("Finding value...")
|
||||
@progress = 0
|
||||
@debouncedTooltipUpdate()
|
||||
else
|
||||
@$el.hide()
|
||||
if @variableChain?.length is 2
|
||||
|
|
|
@ -148,7 +148,7 @@ work = () ->
|
|||
console.log "Non-UserCodeError:", error.toString() + "\n" + error.stack or error.stackTrace
|
||||
self.cleanUp()
|
||||
return true
|
||||
|
||||
|
||||
self.onWorldLoadProgress = onWorldLoadProgress = (progress) ->
|
||||
#console.log "Worker onWorldLoadProgress"
|
||||
self.postMessage
|
||||
|
|
|
@ -9,6 +9,7 @@ class LevelSessionHandler extends Handler
|
|||
editableProperties: ['multiplayer', 'players', 'code', 'codeLanguage', 'completed', 'state',
|
||||
'levelName', 'creatorName', 'levelID', 'screenshot',
|
||||
'chat', 'teamSpells', 'submitted', 'unsubscribed','playtime']
|
||||
privateProperties: ['code', 'submittedCode', 'unsubscribed']
|
||||
jsonSchema: require '../../../app/schemas/models/level_session'
|
||||
|
||||
getByRelationship: (req, res, args...) ->
|
||||
|
@ -20,7 +21,7 @@ class LevelSessionHandler extends Handler
|
|||
if req.user.isAdmin() or req.user.id is document.creator or ('employer' in req.user.get('permissions'))
|
||||
return documentObject
|
||||
else
|
||||
return _.omit documentObject, ['submittedCode','code']
|
||||
return _.omit documentObject, @privateProperties
|
||||
|
||||
getActiveSessions: (req, res) ->
|
||||
return @sendUnauthorizedError(res) unless req.user.isAdmin()
|
||||
|
|
|
@ -236,12 +236,14 @@ UserHandler = class UserHandler extends Handler
|
|||
@sendSuccess(res, documents)
|
||||
|
||||
getLevelSessions: (req, res, userID) ->
|
||||
return @sendUnauthorizedError(res) unless req.user._id+'' is userID or req.user.isAdmin()
|
||||
query = creator: userID
|
||||
isAuthorized = req.user._id+'' is userID or req.user.isAdmin()
|
||||
projection = null
|
||||
if req.query.project
|
||||
projection = {}
|
||||
projection[field] = 1 for field in req.query.project.split(',')
|
||||
projection[field] = 1 for field in req.query.project.split(',') when isAuthorized or not (field in LevelSessionHandler.privateProperties)
|
||||
# If no req.query.project, then LevelSessionHandler.formatEntity will remove private properties if needed.
|
||||
|
||||
LevelSession.find(query).select(projection).exec (err, documents) =>
|
||||
return @sendDatabaseError(res, err) if err
|
||||
documents = (LevelSessionHandler.formatEntity(req, doc) for doc in documents)
|
||||
|
|
Loading…
Reference in a new issue