<commit_before>

Template.docList.documents = ->
  Documents.find()

Template.docList.events =
  "click button": ->
    Documents.insert
      title: "untitled"

Template.docItem.current = ->
  @_id is Session.get("document")

Template.docItem.events =
  "click a": (e) ->
    e.preventDefault()
    Session.set("document", @_id)

Template.editor.title = ->
  id = Session.get("document")
  Documents.findOne(id)?.title

Template.editor.docid = ->
  Session.get("document")

Template.editor.events =
  "keydown input": (e) ->
    return unless e.keyCode == 13
    e.preventDefault()

    $(e.target).blur()
    id = Session.get("document")
    Documents.update id,
      title: e.target.value

  "click button": ->
    id = Session.get("document")
    Documents.remove(id)
    Session.set("document", null)<commit_msg>auto open new document<commit_after>

Template.docList.documents = ->
  Documents.find()

Template.docList.events =
  "click button": ->
    Documents.insert
      title: "untitled"
    , (err, id) ->
        return unless id
        Session.set("document", id)

Template.docItem.current = ->
  @_id is Session.get("document")

Template.docItem.events =
  "click a": (e) ->
    e.preventDefault()
    Session.set("document", @_id)

Template.editor.title = ->
  id = Session.get("document")
  Documents.findOne(id)?.title

Template.editor.docid = ->
  Session.get("document")

Template.editor.events =
  "keydown input": (e) ->
    return unless e.keyCode == 13
    e.preventDefault()

    $(e.target).blur()
    id = Session.get("document")
    Documents.update id,
      title: e.target.value

  "click button": ->
    id = Session.get("document")
    Documents.remove(id)
    Session.set("document", null)
{'fraction_non_alphanumeric': 0.16231884057971013, 'fraction_numerical': 0.002318840579710145, 'mean_word_length': 3.119331742243437, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 20, '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': '2454929', 'n_tokens_mistral': 580, 'n_tokens_neox': 560, 'n_words': 107}