<commit_before><!DOCTYPE html>
<html>
<head>
  <title>AWS SDK for JavaScript - Console</title>
  <link rel="stylesheet" href="css/smoothness/jquery-ui-1.10.1.custom.css" />
  <style type="text/css">
    body { font-family: Helvetica, Arial, sans-serif; font-size: 9pt; }
    .padding { padding: 12px; }
    #header { background: #eee; font-size: 1.2em; }
    .selectorControl * { height: 200px; }
    #operationSelector { border: 1px solid #ccc; }
    #operationSelector h3 { padding: 0; margin-top: 0; }
    #serviceSelector { width: 20%; }
    #operationSelector { width: 20%; }
    #operationData { width: 50%; position: relative; top: 7px; font-family: Monaco, fixed; }
    .tableOutput { width: 100%; overflow: scroll; }
    .history-entry { margin-bottom: 12px; }
    .history-entry pre.output { background: #eee; border: 1px solid #ccc; overflow: scroll; height: 300px; }
    .grid { clear: right; }
    .halfwidth { float: left; width: 48%; margin-right: 6px; }
    .halfwidth:last-child { margin-right: 0px; }
    .break { clear: both; }
    table, th, td { border: 1px solid #ccc; border-collapse: collapse; vertical-align: top; }

    #login-buttons { float: right; }

    /* jquery-ui overrides */
    :focus { outline-width: 0; }
  </style>
  <script type="text/javascript" src="js/jquery-1.9.1.js"></script>
  <script type="text/javascript" src="js/jquery-ui-1.10.1.custom.min.js"></script>
  <script type="text/javascript" src="../../../dist/aws-sdk-all.js"></script>
  <script type="text/javascript" src="appinfo.js"></script>
  <script type="text/template" id="template-historyEntry">
    <div id="history-{entry}" class="history-entry">
      <ul>
        <li>
          <a href="#history-tab-{entry}">
            <img src="img/loading.gif"/>
            {service}.{operation}() &mdash; {date}
          </a>
        </li>
        <li><a href="#history-details-tab-{entry}">Details</a></li>
        <li><a href="#history-table-tab-{entry}">Tabular (Experimental)</a></li>
      </ul>
      <div id="history-tab-{entry}">
        <div class="grid">
          <div class="halfwidth">
            <h3>Response</h3>
            <pre class="padding output operationResponse"></pre>
          </div>
          <div class="halfwidth">
            <h3>Request</h3>
            <pre class="padding output operationRequest"></pre>
          </div>
        </div>
        <div class="break"></div>
      </div>
      <div id="history-details-tab-{entry}">
        <div class="grid">
          <div class="halfwidth">
            <h3>Request Details</h3>
            <pre class="padding output operationRequestDetails"></pre>
          </div>
          <div class="halfwidth">
            <h3>Response Details</h3>
            <pre class="padding output operationResponseDetails"></pre>
          </div>
        </div>
        <div class="break"></div>
      </div>
      <div id="history-table-tab-{entry}">
        <div class="tableOutput"></div>
      </div>
    </div>
  </script>
  <script type="text/javascript">
    services = {};
    currentServiceVar = null;
    currentService = null;
    currentOperation = null;
    data = null;
    error = null;
    response = null;
    requestCount = 0;

    function s4() {
      return Math.floor((1 + Math.random()) * 0x10000)
                 .toString(16)
                 .substring(1);
    };

    function guid() {
      return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
             s4() + '-' + s4() + s4() + s4();
    }

    /**
     * Turns a JS object into a table representation using a set of hints
     * to detect the key/value structure.
     *
     * Assume EC2 for now
     */
    function tableView(items, resultKey) {
      var table = $('<table/>').attr('cellpadding', 5);

      // transposed table for structures
      if (!Array.isArray(items)) {
        for (var key in items) {
          var row = $('<tr/>');
          $('<th/>').text(key).appendTo(row);
          $('<td/>').text(items[key]).appendTo(row);
          row.appendTo(table);
        }
        return table;
      }

      if (items.length === 0) return '';
      var i;
      // first build the headers
      var row = $('<tr/>');
      var keys = typeof items[0] === 'object' ? Object.keys(items[0]) : [resultKey];
      for (i = 0; i < keys.length; i++) {
        $('<th/>').text(keys[i]).appendTo(row);
      }
      row.appendTo(table);

      for (i = 0; i < items.length; i++) {
        row = $('<tr/>');
        if (typeof items[i] === 'object') {
          for (var key in items[i]) {
            var value = items[i][key];
            if (typeof value === 'object') { // complex type
              value = tableView(value);
            }
            $('<td/>').html(value).appendTo(row);
          }
        } else {
          $('<td/>').html(items[i]).appendTo(row);
        }
        row.appendTo(table);
      }

      return table;
    }

    function loadOperationsForService(svc) {
      if (currentServiceVar === svc) return;
      currentServiceVar = svc;
      currentService = services[svc];

      $('#operationSelector').empty();
      for (var key in currentService.api.operations) {
        var el = $('<option/>').attr('value', key).text(key);
        $('#operationSelector').append(el).change(function() {
          loadOperation($(this).val());
        });
      }
    }

    function loadOperation(operation) {
      if (currentOperation === operation) return;
      currentOperation = operation;

      var input = currentService.api.operations[operation].input.members;
      $('#operationData').val(JSON.stringify(input, null, 2));
    }

    function loadServices() {
      $('#serviceSelector').empty();
      for (var key in AWS) {
        if (!AWS[key].prototype) continue;
        if (AWS[key].prototype.constructor.__super__.name === 'Service') {
          var svcVarName = key.toLowerCase();
          try {
            var svc = services[svcVarName] = window[svcVarName] = new AWS[key]();
            var fullName = svc.api.abbreviation || svc.api.fullName;
            var el = $('<option/>').attr('value', svcVarName).text(fullName);
            $('#serviceSelector').append(el).change(function () {
              loadOperationsForService($(this).val());
            });
          } catch (e) {
            console.log('Failed to load service ' + key + ': ' + e.message);
          }
        }
      }
    }

    function executeOperation() {
      var params = JSON.parse($('#operationData').val() || '{}');
      currentService[currentOperation](params).send();<commit_msg>Provide better default generated input example format<commit_after><!DOCTYPE html>
<html>
<head>
  <title>AWS SDK for JavaScript - Console</title>
  <link rel="stylesheet" href="css/smoothness/jquery-ui-1.10.1.custom.css" />
  <style type="text/css">
    body { font-family: Helvetica, Arial, sans-serif; font-size: 9pt; }
    .padding { padding: 12px; }
    #header { background: #eee; font-size: 1.2em; }
    .selectorControl * { height: 200px; }
    #operationSelector { border: 1px solid #ccc; }
    #operationSelector h3 { padding: 0; margin-top: 0; }
    #serviceSelector { width: 20%; }
    #operationSelector { width: 20%; }
    #operationData { width: 50%; position: relative; top: 7px; font-family: Monaco, fixed; }
    .tableOutput { width: 100%; overflow: scroll; }
    .history-entry { margin-bottom: 12px; }
    .history-entry pre.output { background: #eee; border: 1px solid #ccc; overflow: scroll; height: 300px; }
    .grid { clear: right; }
    .halfwidth { float: left; width: 48%; margin-right: 6px; }
    .halfwidth:last-child { margin-right: 0px; }
    .break { clear: both; }
    table, th, td { border: 1px solid #ccc; border-collapse: collapse; vertical-align: top; }

    #login-buttons { float: right; }

    /* jquery-ui overrides */
    :focus { outline-width: 0; }
  </style>
  <script type="text/javascript" src="js/jquery-1.9.1.js"></script>
  <script type="text/javascript" src="js/jquery-ui-1.10.1.custom.min.js"></script>
  <script type="text/javascript" src="../../../dist/aws-sdk-all.js"></script>
  <script type="text/javascript" src="appinfo.js"></script>
  <script type="text/template" id="template-historyEntry">
    <div id="history-{entry}" class="history-entry">
      <ul>
        <li>
          <a href="#history-tab-{entry}">
            <img src="img/loading.gif"/>
            {service}.{operation}() &mdash; {date}
          </a>
        </li>
        <li><a href="#history-details-tab-{entry}">Details</a></li>
        <li><a href="#history-table-tab-{entry}">Tabular (Experimental)</a></li>
      </ul>
      <div id="history-tab-{entry}">
        <div class="grid">
          <div class="halfwidth">
            <h3>Response</h3>
            <pre class="padding output operationResponse"></pre>
          </div>
          <div class="halfwidth">
            <h3>Request</h3>
            <pre class="padding output operationRequest"></pre>
          </div>
        </div>
        <div class="break"></div>
      </div>
      <div id="history-details-tab-{entry}">
        <div class="grid">
          <div class="halfwidth">
            <h3>Request Details</h3>
            <pre class="padding output operationRequestDetails"></pre>
          </div>
          <div class="halfwidth">
            <h3>Response Details</h3>
            <pre class="padding output operationResponseDetails"></pre>
          </div>
        </div>
        <div class="break"></div>
      </div>
      <div id="history-table-tab-{entry}">
        <div class="tableOutput"></div>
      </div>
    </div>
  </script>
  <script type="text/javascript">
    services = {};
    currentServiceVar = null;
    currentService = null;
    currentOperation = null;
    data = null;
    error = null;
    response = null;
    requestCount = 0;

    function s4() {
      return Math.floor((1 + Math.random()) * 0x10000)
                 .toString(16)
                 .substring(1);
    };

    function guid() {
      return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
             s4() + '-' + s4() + s4() + s4();
    }

    /**
     * Turns a JS object into a table representation using a set of hints
     * to detect the key/value structure.
     *
     * Assume EC2 for now
     */
    function tableView(items, resultKey) {
      var table = $('<table/>').attr('cellpadding', 5);

      // transposed table for structures
      if (!Array.isArray(items)) {
        for (var key in items) {
          var row = $('<tr/>');
          $('<th/>').text(key).appendTo(row);
          $('<td/>').text(items[key]).appendTo(row);
          row.appendTo(table);
        }
        return table;
      }

      if (items.length === 0) return '';
      var i;
      // first build the headers
      var row = $('<tr/>');
      var keys = typeof items[0] === 'object' ? Object.keys(items[0]) : [resultKey];
      for (i = 0; i < keys.length; i++) {
        $('<th/>').text(keys[i]).appendTo(row);
      }
      row.appendTo(table);

      for (i = 0; i < items.length; i++) {
        row = $('<tr/>');
        if (typeof items[i] === 'object') {
          for (var key in items[i]) {
            var value = items[i][key];
            if (typeof value === 'object') { // complex type
              value = tableView(value);
            }
            $('<td/>').html(value).appendTo(row);
          }
        } else {
          $('<td/>').html(items[i]).appendTo(row);
        }
        row.appendTo(table);
      }

      return table;
    }

    function loadOperationsForService(svc) {
      if (currentServiceVar === svc) return;
      currentServiceVar = svc;
      currentService = services[svc];

      $('#operationSelector').empty();
      for (var key in currentService.api.operations) {
        var el = $('<option/>').attr('value', key).text(key);
        $('#operationSelector').append(el).change(function() {
          loadOperation($(this).val());
        });
      }
    }

    function loadOperation(operation) {
      if (currentOperation === operation) return;
      currentOperation = operation;

      var input = currentService.api.operations[operation].input;
      var obj = {shapeMap: {}};
      var sampleInput = inputForShape.call(obj, input);
      $('#operationData').val(JSON.stringify(sampleInput, null, 2));
    }

    function inputForShape(shape) {
      switch (shape.type) {
        case 'structure': return inputForStructure.call(this, shape);
        case 'map': return inputForMap.call(this, shape);
        case 'list': return inputForList.call(this, shape);
        case 'string': return "STRING";
        case 'integer': return 123;
        case 'timestamp': return "new Date()";
        default: return 'UNKNOWNVALUE';
      }
    }

    function inputForMap(shape) {
      return {someKey: inputForShape.call(this, shape.value)};
    }

    function inputForList(shape) {
      var value = inputForShape.call(this, shape.member);
      return [value, value, value];
    }

    function inputForStructure(shape) {
      var self = this, obj = {};
      AWS.util.each(shape.members, function(key, member) {
        if (shape.required.indexOf(key) < 0) return;
        obj[key] = inputForShape.call(self, member);
      });
      return obj;
    }

    function loadServices() {
      $('#serviceSelector').empty();
      for (var key in AWS) {
        if (!AWS[key].prototype) continue;
        if (AWS[key].prototype.constructor.__super__.name === 'Service') {
          var svcVarName = key.toLowerCase();
          try {
            var svc = services[svcVarName] = window[svcVarName] = new AWS[key]();
            var fullName = svc.api.abbreviation || svc.api.fullName;
            var el = $('<option/>').attr('value', svcVarName).text(fullName);
            $('#serviceSelector').append(el).change(function () {
              loadOperationsForService($(this).val());
            });
          } catch (e) {
            console.log('Failed to load service ' + key + ': ' + e.message);
          }
        }
      }
    }

    function executeOperation() {
      var params = eval('var _=' + ($('#operationData').val() || '{}') + ';_');
      currentService[currentOperation](params).send();
{'fraction_non_alphanumeric': 0.17544846992613436, 'fraction_numerical': 0.01167780513542033, 'mean_word_length': 2.2545787545787546, 'pattern_counts': {'":': 0, '<': 182, '<?xml version=': 0, '>': 177, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2209767', 'n_tokens_mistral': 4468, 'n_tokens_neox': 4316, 'n_words': 956}