solr/server/solr-webapp/webapp/js/scripts/documents.js
function addWizardFields(active_core, wizard) {
  var core_basepath = active_core.attr('data-basepath');
  var select_options = "";
  //Populate the select options based off the Fields REST API
  $.getJSON(window.location.protocol + '//' + window.location.host
          + core_basepath + "/schema/fields").done(
      //TODO: handle dynamic fields
      //TODO: get the unique key, too
      function (data) {
        var field_select = $("#wiz-field-select", wizard);
        field_select.empty();
        $.each(data.fields,
            function (i, item) {
              //console.log("i[" + i + "]=" + item.name);
              if (item.name != "_version_"){
                select_options += '<option name="' + item.name + '">'
                  + item.name + '</option>';
              }
            });
        //console.log("select_options: " + select_options);
        //fill in the select options
        field_select.append(select_options);
      });
  var wizard_doc = $("#wizard-doc", wizard);
  wizard_doc.die('focusin')
      .live('focusin', function (event) {
        $("#wizard-doc", wizard).text("");
      }
  );
  //Add the click handler for the "Add Field" target, which
  //takes the field content and moves it into the document target
  var add_field = $("#add-field-href", wizard);
  add_field.die("click")
      .live("click",
      function (event) {
        //take the field and the contents and append it to the document
        var wiz_select = $("#wiz-field-select", wizard);
        var selected = $("option:selected", wiz_select);
        console.log("selected field: " + selected);
        var wiz_doc = $("#wizard-doc", wizard);
        var the_document = $("#document");
        var current_doc = the_document.val();
        console.log("current_text: " + current_doc + " wiz_doc: " + wiz_doc.val());
        var index = current_doc.lastIndexOf("}");
        var new_entry = '"' + selected.val() + '":"' + wiz_doc.val() + '"';
        if (index >= 0) {
          current_doc = current_doc.substring(0, index) + ', ' + new_entry + "}";
        } else {
          //we don't have a doc at all
          current_doc = "{" + new_entry + "}";
        }
        current_doc = content_generator['json'](current_doc);
        the_document.val(current_doc);
        //clear the wiz doc window
        wiz_doc.val("");
        return false;
      }
  );

  //console.log("adding " + i + " child: " + child);

}
function addWizardFields(active_core, wizard) {
  var core_basepath = active_core.attr('data-basepath');
  var select_options = "";
  //Populate the select options based off the Fields REST API
  $.getJSON(window.location.protocol + '//' + window.location.host
          + core_basepath + "/schema/fields").done(
      //TODO: handle dynamic fields
      //TODO: get the unique key, too
      function (data) {
        var field_select = $("#wiz-field-select", wizard);
        field_select.empty();
        $.each(data.fields,
            function (i, item) {
              //console.log("i[" + i + "]=" + item.name);
              if (item.name != "_version_"){
                select_options += '<option name="' + item.name + '">'
                  + item.name + '</option>';
              }
            });
        //console.log("select_options: " + select_options);
        //fill in the select options
        field_select.append(select_options);
      });
  var wizard_doc = $("#wizard-doc", wizard);
  wizard_doc.die('focusin')
      .live('focusin', function (event) {
        $("#wizard-doc", wizard).text("");
      }
  );
  //Add the click handler for the "Add Field" target, which
  //takes the field content and moves it into the document target
  var add_field = $("#add-field-href", wizard);
  add_field.die("click")
      .live("click",
      function (event) {
        //take the field and the contents and append it to the document
        var wiz_select = $("#wiz-field-select", wizard);
        var selected = $("option:selected", wiz_select);
        console.log("selected field: " + selected);
        var wiz_doc = $("#wizard-doc", wizard);
        var the_document = $("#document");
        var current_doc = the_document.val();
        console.log("current_text: " + current_doc + " wiz_doc: " + wiz_doc.val());
        var index = current_doc.lastIndexOf("}");
        var new_entry = '"' + selected.val() + '":"' + wiz_doc.val() + '"';
        if (index >= 0) {
          current_doc = current_doc.substring(0, index) + ', ' + new_entry + "}";
        } else {
          //we don't have a doc at all
          current_doc = "{" + new_entry + "}";
        }
        current_doc = content_generator['json'](current_doc);
        the_document.val(current_doc);
        //clear the wiz doc window
        wiz_doc.val("");
        return false;
      }
  );

  //console.log("adding " + i + " child: " + child);

}
#/:core/documents Utiltity function for setting up the wizard fields