diff --git a/app/assets/main.html b/app/assets/main.html
index 1aede0254..b77636a8f 100644
--- a/app/assets/main.html
+++ b/app/assets/main.html
@@ -37,6 +37,19 @@
+
+
+
diff --git a/app/lib/God.coffee b/app/lib/God.coffee
index 622552e1b..017c1263d 100644
--- a/app/lib/God.coffee
+++ b/app/lib/God.coffee
@@ -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
diff --git a/app/lib/services/linkedin.coffee b/app/lib/services/linkedin.coffee
index aca441148..094f8eedb 100644
--- a/app/lib/services/linkedin.coffee
+++ b/app/lib/services/linkedin.coffee
@@ -1,12 +1,9 @@
module.exports = initializeLinkedIn = ->
window.linkedInAsyncInit = ->
+ console.log "Linkedin async init success!"
Backbone.Mediator.publish 'linkedin-loaded'
linkedInSnippet =
- ''
+ ''
$('head').append(linkedInSnippet)
diff --git a/app/styles/play/level/tome/spell_debug.sass b/app/styles/play/level/tome/spell_debug.sass
index e02326b55..976675c2e 100644
--- a/app/styles/play/level/tome/spell_debug.sass
+++ b/app/styles/play/level/tome/spell_debug.sass
@@ -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%
diff --git a/app/templates/play/level/tome/spell_debug.jade b/app/templates/play/level/tome/spell_debug.jade
index 428446e3a..01a8225ea 100644
--- a/app/templates/play/level/tome/spell_debug.jade
+++ b/app/templates/play/level/tome/spell_debug.jade
@@ -1,2 +1,6 @@
+div.progress
+ .progress-bar(role="progressbar", aria-valuenow="50", aria-valuemin="0", aria-valuemax="100")
+ span Inspecting variable...
pre
+
code
\ No newline at end of file
diff --git a/app/views/play/level/tome/spell_debug_view.coffee b/app/views/play/level/tome/spell_debug_view.coffee
index c48d3beab..2fb4584f9 100644
--- a/app/views/play/level/tome/spell_debug_view.coffee
+++ b/app/views/play/level/tome/spell_debug_view.coffee
@@ -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
diff --git a/headless_client/worker_world.coffee b/headless_client/worker_world.coffee
index 1680b86aa..41d09210e 100644
--- a/headless_client/worker_world.coffee
+++ b/headless_client/worker_world.coffee
@@ -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
diff --git a/server/levels/sessions/level_session_handler.coffee b/server/levels/sessions/level_session_handler.coffee
index 7a89cebdf..65c4f6f19 100644
--- a/server/levels/sessions/level_session_handler.coffee
+++ b/server/levels/sessions/level_session_handler.coffee
@@ -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()
diff --git a/server/users/user_handler.coffee b/server/users/user_handler.coffee
index 6d4609d35..571bae538 100644
--- a/server/users/user_handler.coffee
+++ b/server/users/user_handler.coffee
@@ -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)