Sha256: 82d432a044e518d44008f7fff0d54e18360e24d68683fb11f55e0fb878838d04

Contents?: true

Size: 1.57 KB

Versions: 24

Compression:

Stored size: 1.57 KB

Contents

  # DO NOT USE the @view instance variable in any files in /app/javascripts/base.
  # The way they are cached makes it not safe to do so.

window.Debug = 
  on: false
  console: true
  logs: false
  
  consoleOn: ->
    typeof window['console'] != 'undefined' && this.console
  
  call: ->
    args = [].slice.call(arguments,0)
    level = args.shift()
    
    message = this.message.apply(Debug, args)

    if this.consoleOn()
      console[level](message)
      
    Logger.observe(message)
  
  log: ->
    args = [].slice.call(arguments,0)
    args.unshift("log")
    this.call.apply(this, args)
  
  error: ->
    args = [].slice.call(arguments,0)
    args.unshift("error")
    this.call.apply(this, args)
  
  message: ->
    args = [].slice.call(arguments,0)
    parts = []
    
    parts.push(this.timestamp())
    parts.push(this.generalInfo())
    
    $(args).each (i, arg) ->
      parts.push(Debug.object(arg))
    
    message = parts.join(" ")
    
    message
  
  object: (obj) ->
    if (typeof obj == "string")
      obj
    else if (obj == undefined)
      "undefined"
    else if (obj == null)
      "null"
    else if obj.message
      obj.message
    else if (obj.inspect)
      obj.inspect()
    else
      JSON.stringify(obj)
    
  checktime: (i) ->
    if i<10
      i="0" + i
      
    i
  
  timestamp: ->
    time = new Date()
    hour = this.checktime(time.getHours())
    minute = this.checktime(time.getMinutes())
    second = this.checktime(time.getSeconds())
    
    hour + ":" + minute + ":" + second
  
  generalInfo: ->
    "[<%= @version %> <%= @sprint_name %>]"
    

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
ymdp-1.4.7 lib/ymdp/javascripts/jquery/debug.js.coffee
ymdp-1.4.6 lib/ymdp/javascripts/jquery/debug.js.coffee
ymdp-1.4.5 lib/ymdp/javascripts/jquery/debug.js.coffee
ymdp-1.4.4 lib/ymdp/javascripts/jquery/debug.js.coffee
ymdp-1.4.3 lib/ymdp/javascripts/jquery/debug.js.coffee
ymdp-1.4.2 lib/ymdp/javascripts/jquery/debug.js.coffee
ymdp-1.4.1 lib/ymdp/javascripts/jquery/debug.js.coffee
ymdp-1.4.0 lib/ymdp/javascripts/jquery/debug.js.coffee
ymdp-1.3.4 lib/ymdp/javascripts/jquery/debug.js.coffee
ymdp-1.3.3 lib/ymdp/javascripts/jquery/debug.js.coffee
ymdp-1.3.2 lib/ymdp/javascripts/jquery/debug.js.coffee
ymdp-1.3.1 lib/ymdp/javascripts/jquery/debug.js.coffee
ymdp-1.3.0 lib/ymdp/javascripts/jquery/debug.js.coffee
ymdp-1.2.0 lib/ymdp/javascripts/jquery/debug.js.coffee
ymdp-1.1.0 lib/ymdp/javascripts/jquery/debug.js.coffee
ymdp-1.0.1 lib/ymdp/javascripts/jquery/debug.js.coffee
ymdp-1.0.0 lib/ymdp/javascripts/jquery/debug.js.coffee
ymdp-0.10.2 lib/ymdp/javascripts/jquery/debug.js.coffee
ymdp-0.10.1 lib/ymdp/javascripts/jquery/debug.js.coffee
ymdp-0.10.0 lib/ymdp/javascripts/jquery/debug.js.coffee