 FSHelper             = require 'app/util/fs/fshelper'
 settings             = require './settings'
 
+prependWithOrigin = (path) -> [location.origin, path].join '/'
+
 module.exports =
 
 class Ace extends KDView


  @registerStaticEmitter()

  getscript globals.acePath, (err) ->
    throw err  if err

    for k, v of globals.aceConfig
      ace.config.set k, v

    ACE_READY = yes
    Ace.emit 'ScriptLoaded'

      EmmetLoadState.PENDING = yes
      emmetPath = globals.acePath.split('/').slice(0, -1)
        .concat(['_ext-emmet.js']).join('/')

      getscript prependWithOrigin(emmetPath), (err) ->
        cb err for key, cb of emmetLoadListeners when typeof cb is 'function'
        EmmetLoadState.READY = yes
        emmetLoadListeners = null
