 wdc_base = require '../connector_base/starschema_wdc_base.coffee'
 json_flattener = require './json_flattener.coffee'
 
-
-load_json = (url, success_callback)->
-  $.ajax
-    url: url
-    datatype: "json"
-    success: (data, textStatus, request)->
-      success_callback(data)
-    error: (xhr, ajaxOptions, thrownError)->
-      console.error("Error during search request", thrownError)
-      tableau.abortWithError "Error while trying to load '#{url}'. #{thrownError}"
 
 load_jsonp = (url, success_callback)->
   $.ajax

  steps:
    start:
      template: require './start.jade'
    run:
      template: require './run.jade'
    run_mongo:
      template: require './run.jade'


  transitions:
    "start > run": (data)->
      _.extend data, wdc_base.fetch_inputs("#state-start")

    "start > run_mongo": (data)->
      _.extend data, wdc_base.fetch_inputs("#state-start")
      url = "http://#{data.mongodb_host}:#{data.mongodb_port}/#{data.mongodb_db}/#{data.mongodb_collection}"

    success: (data, textStatus, request)->
      success_callback(data)
    error: (xhr, ajaxOptions, thrownError)->
      tableau.abortWithError "Error while trying to load '#{url}'. #{thrownError}"

JSONP_CALLBACK_NAME = "mongodb_wdc_jsonp_callback"
