<commit_before><div class="page-header">
  <h1>Topic: {{topic}}</h1>
</div>
<div class="row">
  <div class="span14">
    <form method="post">
      <fieldset>
        <div class="clearfix">
          <label for="payload">Content</label>
          <div class="input">
            <textarea id="payload" name="payload" class="xxlarge" rows="10">{{value.payload}}</textarea>
          </div>
        </div>
        <div class="actions">
          <input id="update" type="submit" class="btn success" value="Update"></input>
        </div>
      </fieldset>
    </form>
  </div>
</div>

<script type="text/javascript" src="/socket.io/socket.io.js"></script>
<script type="text/javascript">
  socket = io.connect()

  socket.on("/topics/{{topic}}", function(data) {
    $("#payload").val(data);
  });

  $("#update").click(function() {
    $.post("/topics/{{topic}}", { "_method": "put", payload: $("#payload").val() });
    return false;
  });

</script><commit_msg>Improved client logic for the view.<commit_after><div class="page-header">
  <h1>Topic: {{topic}}</h1>
</div>
<div class="row">
  <div class="span14">
    <form method="post">
      <fieldset>
        <div class="clearfix">
          <label for="payload">Content</label>
          <div class="input">
            <textarea id="payload" name="payload" class="xxlarge" rows="10" readonly>{{value.payload}}</textarea>
          </div>
        </div>
        <div class="actions">
          <input id="update" type="submit" class="btn success" value="Update"></input>
          <input id="edit" type="submit" class="btn primary" value="Edit"></input>
          <input id="cancel" type="submit" class="btn error" value="Cancel"></input>
        </div>
      </fieldset>
    </form>
  </div>
</div>

<script type="text/javascript" src="/socket.io/socket.io.js"></script>
<script type="text/javascript">
  socket = io.connect()

  var textarea = $("#payload");
  var update = $("#update");
  var edit = $("#edit");
  var cancel = $("#cancel");

  update.hide();
  cancel.hide();

  var last_data = null;
  socket.on("/topics/{{topic}}", function(data) {
    last_data = data;
    if(textarea.attr("readonly")) {
      textarea.val(data);
    }
  });

  update.click(function() {
    $.post("/topics/{{topic}}", { "_method": "put", payload: textarea.val() });
    textarea.attr("readonly", true);
    edit.toggle();
    update.toggle();
    cancel.toggle();
    return false;
  });

  edit.click(function() {
    textarea.removeAttr("readonly");
    update.toggle();
    cancel.toggle();
    edit.toggle();
    return false;
  });

  cancel.click(function() {
    textarea.val(last_data);
    textarea.attr("readonly", true);
    update.toggle();
    cancel.toggle();
    edit.toggle();
    return false;
  });
</script>
{'fraction_non_alphanumeric': 0.21629416005767843, 'fraction_numerical': 0.004325883201153569, 'mean_word_length': 3.1050295857988166, 'pattern_counts': {'":': 2, '<': 63, '<?xml version=': 0, '>': 63, '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': '1831873', 'n_tokens_mistral': 899, 'n_tokens_neox': 868, 'n_words': 172}