devdocs/assets/javascripts/debug.js.coffee

86 lines
1.8 KiB
CoffeeScript
Raw Normal View History

return unless console?.time and console.groupCollapsed
2013-10-24 20:25:52 +02:00
#
# App
#
_init = app.init
app.init = ->
console.time 'Init'
_init.call(app)
console.timeEnd 'Init'
console.time 'Load'
_start = app.start
app.start = ->
console.timeEnd 'Load'
2015-01-01 21:01:03 +01:00
console.time 'Start'
_start.call(app, arguments...)
console.timeEnd 'Start'
2013-10-24 20:25:52 +02:00
#
# Searcher
#
2015-01-01 21:01:03 +01:00
_super = app.Searcher
_proto = app.Searcher.prototype
2013-10-24 20:25:52 +02:00
app.Searcher = ->
_super.apply @, arguments
_setup = @setup.bind(@)
@setup = ->
console.groupCollapsed "Search: #{@query}"
console.time 'Total'
_setup()
_match = @match.bind(@)
@match = =>
2015-02-08 15:36:15 +01:00
console.timeEnd @matcher.name if @matcher
2013-10-24 20:25:52 +02:00
_match()
_setupMatcher = @setupMatcher.bind(@)
@setupMatcher = ->
2014-11-03 01:46:00 +01:00
console.time @matcher.name
2013-10-24 20:25:52 +02:00
_setupMatcher()
_end = @end.bind(@)
@end = ->
console.log "Results: #{@totalResults}"
console.timeEnd 'Total'
2015-02-08 15:36:15 +01:00
console.groupEnd()
2013-10-24 20:25:52 +02:00
_end()
_kill = @kill.bind(@)
@kill = ->
if @timeout
2014-11-03 01:46:00 +01:00
console.timeEnd @matcher.name if @matcher
2013-10-24 20:25:52 +02:00
console.groupEnd()
console.timeEnd 'Total'
console.warn 'Killed'
_kill()
return
2015-02-08 15:36:15 +01:00
$.extend(app.Searcher, _super)
2013-10-24 20:25:52 +02:00
_proto.constructor = app.Searcher
app.Searcher.prototype = _proto
#
# View tree
#
2016-07-01 18:43:41 +02:00
@viewTree = (view = app.document, level = 0, visited = []) ->
return if visited.indexOf(view) >= 0
visited.push(view)
console.log "%c #{Array(level + 1).join(' ')}#{view.constructor.name}: #{!!view.activated}",
2013-10-24 20:25:52 +02:00
'color:' + (view.activated and 'green' or 'red')
2016-07-01 18:43:41 +02:00
for own key, value of view when key isnt 'view' and value
2013-10-24 20:25:52 +02:00
if typeof value is 'object' and value.setupElement
2016-07-01 18:43:41 +02:00
@viewTree(value, level + 1, visited)
2013-10-24 20:25:52 +02:00
else if value.constructor.toString().match(/Object\(\)/)
2016-07-01 18:43:41 +02:00
@viewTree(v, level + 1, visited) for own k, v of value when v and typeof v is 'object' and v.setupElement
2013-10-24 20:25:52 +02:00
return