 # Calls given callback with the hash as an argument
 # Currently uses mockmule.
 getMuleKeys = (fn) ->
-  url = "http://localhost:3000/key?jsonp=callback"
-  window.callback = (response) ->
-      keys = response.data
-      fn(keys)
+  url = "http://localhost:3000/key?jsonp=muleviewCallback"
+  window.muleviewCallback = (response) ->
+      fn(response.data)
+      delete window.muleviewCallback
   scriptTag = document.createElement("script")
   scriptTag.src=url
   scriptTag.type="text/javascript"

  width: "20%"
  split: true
  displayField: "name"
  # rootVisible: false
  store: treeStore


# fills the treeview accordingly
fillTree = (parent, keys) ->
  for name, subkeys of keys
    fullname = ((parent?.get("fullname") && (parent.get("fullname") + ".")) || "") + name
    node = Ext.create "KeyModel",
      name: name
      fullname: fullname
    parent.appendChild(node)
    fillTree(node, subkeys)

