<commit_before>#// Place all the behaviors and hooks related to the matching controller here.
#// All this logic will automatically be available in application.js.
#= require action_cable

App.messages = App.cable.subscriptions.create { channel: "DiagramChannel", diagram_id: "1" },
  received: (data) ->
    @appendLine(data)

  appendLine: (data) ->
    html = @createLine(data)
    $("#mess").prepend(html)

  createLine: (data) ->
    data_p = JSON.parse(data)
    action = JSON.stringify(data_p.action)
    body = JSON.stringify(data_p.body)
    console.log action
    
    """
    <article class="chat-line">
      <span class="action">#{action}</span>
      <span class="body">#{body}</span><commit_msg>ADD effects for displaying messages<commit_after>#// Place all the behaviors and hooks related to the matching controller here.
#// All this logic will automatically be available in application.js.
#= require action_cable

App.messages = App.cable.subscriptions.create { channel: "DiagramChannel", diagram_id: "1" },
  received: (data) ->
    @appendLine(data)

  appendLine: (data) ->
    html = @createLine(data)
    $( "#mess" ).prepend(html)
    $( "article:hidden:first" ).fadeIn( "slow" );

  createLine: (data) ->
    data_p = JSON.parse(data)
    event = data_p.action.event || 'default'
    action = JSON.stringify(data_p.action)
    body = JSON.stringify(data_p.body)
    console.log action
    
    bgcolor = switch
      when event == 'deleted' then '#F7EDED'
      when event == 'created' then '#EBF7F0'
      when event == 'updated' then '#FCF6DB'
      else 'white'

    """
    <article class="chat-line" style="display:none;background:#{bgcolor}">
      <span class="action">#{action}</span>
      <span class="body">#{body}</span>
{'fraction_non_alphanumeric': 0.15073947667804324, 'fraction_numerical': 0.0034129692832764505, 'mean_word_length': 3.568831168831169, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, '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': '1771764', 'n_tokens_mistral': 556, 'n_tokens_neox': 551, 'n_words': 138}