 # if location.hostname is "localhost"
 # window.onerror = (desc,page,line,chr)=> alert "Line: #{line}, desc: #{desc}, chr:#{chr}, page:#{page}"
 
-Function::bind or= do ->  
+Function::bind or= do ->
   {slice} = []
   (context)->
     func = @

        inflated = JSONH.unpack data
        console.log 'success', inflated
        console.log Date.now()-start
  
  registerPage:(name,classFunction)->
    # log "registering a page",name
    @pageClasses ?= {}

  singletons      : {}
  subscriptions   : []
  classes         : {}

  apiUri: switch KD.env
    when 'beta'
      'https://api.koding.com'
    else
      'https://dev-api.koding.com'

  appsUri: switch KD.env
    when 'beta'
      'http://app.koding.com'
    else
      'http://dev-app.koding.com'

  whoami:-> KD.getSingleton('mainController').getVisitor().currentDelegate

  isLoggedIn:-> @whoami() instanceof bongo.api.JAccount

  isMine:(account)-> @whoami().profile.nickname is account.profile.nickname

  checkFlag:(flag, account = KD.whoami())-> account.globalFlags and flag in account.globalFlags
