<commit_before>Session.setDefault "editing_flycircuit_idid", null

Template.FlyCircuitPanel.events window.okCancelEvents("#edit-flycircuit-input",
  ok: (value) ->
    coll = window.get_collection_from_name(@collection)
    coll.update @_id,
      $addToSet:
        flycircuit_idids: +value # plus sign converts to integer

    Session.set "editing_flycircuit_idid", null
    return

  cancel: ->
    Session.set "editing_flycircuit_idid", null
    return
)

Template.FlyCircuitPanel.events
  "click .add-flycircuit-idid": (e, tmpl) ->
    Session.set "editing_flycircuit_idid", @_id
    Deps.flush() # update DOM before focus
    window.activateInput tmpl.find("#edit-flycircuit-input")
    return

  "click .remove": (evt) ->
    flycircuit_idid = @name
    parent_id = @parent_id
    coll = window.get_collection_from_name(@collection)

    # wait for CSS animation to finish
    Meteor.setTimeout (->
      coll.update
        _id: parent_id
      ,
        $pull:
          flycircuit_idids: flycircuit_idid

      return
    ), 300
    return

Template.FlyCircuitPanel.helpers
  adding_flycircuit_idid: ->
    Session.equals "editing_flycircuit_idid", @_id

  idid_dicts: ->
    result = []

    if !@flycircuit_idids?
      return result

    for idid in @flycircuit_idids
      tmp =
        name: idid
        parent_id: @_id<commit_msg>convert another Session variable to a ReactiveVar<commit_after>editing_flycircuit_idid = new ReactiveVar(null)

Template.FlyCircuitPanel.events window.okCancelEvents("#edit-flycircuit-input",
  ok: (value) ->
    coll = window.get_collection_from_name(@collection)
    coll.update @_id,
      $addToSet:
        flycircuit_idids: +value # plus sign converts to integer

    editing_flycircuit_idid.set(null)
    return

  cancel: ->
    editing_flycircuit_idid.set(null)
    return
)

Template.FlyCircuitPanel.events
  "click .add-flycircuit-idid": (e, tmpl) ->
    editing_flycircuit_idid.set(@_id)
    Deps.flush() # update DOM before focus
    window.activateInput tmpl.find("#edit-flycircuit-input")
    return

  "click .remove": (evt) ->
    flycircuit_idid = @name
    parent_id = @parent_id
    coll = window.get_collection_from_name(@collection)

    # wait for CSS animation to finish
    Meteor.setTimeout (->
      coll.update
        _id: parent_id
      ,
        $pull:
          flycircuit_idids: flycircuit_idid

      return
    ), 300
    return

Template.FlyCircuitPanel.helpers
  adding_flycircuit_idid: ->
    editing_flycircuit_idid.get() == @_id

  idid_dicts: ->
    result = []

    if !@flycircuit_idids?
      return result

    for idid in @flycircuit_idids
      tmp =
        name: idid
        parent_id: @_id
{'fraction_non_alphanumeric': 0.09709821428571429, 'fraction_numerical': 0.002232142857142857, 'mean_word_length': 2.9955423476968797, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 17, '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': '2807154', 'n_tokens_mistral': 941, 'n_tokens_neox': 880, 'n_words': 176}