<commit_before># Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

@slider_setup = ->
  @exchanges = {}
  $('ul.exchanges li').each (idx,el)->
    exg = spans_to_json(el)
    dust.render 'exchange-button', exg, (err,out)->
      if err
        console.log(err)
      else
        $(el).replaceWith(out)    
    exchanges[exg['name']] = exg
  $('ul.exchanges li').click(exg_toggle)

spans_to_json = (el)->
  record = {}
  $("span", el).each (idx,el)->
    j = $(el)
    record[j.attr('key')] = j.html()
  record

exg_toggle = (event) ->
  name = $(event.target).attr('name')
  exchange = exchanges[name]
  exchange.active = !exchange.active
  console.log('exchange '+name+' active '+exchange.active)<commit_msg>flag status<commit_after># Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

@slider_setup = ->
  @exchanges = {}
  $('ul.exchanges li').each (idx,el)->
    exg = spans_to_json(el)
    dust.render 'exchange-button', exg, (err,out)->
      if err
        console.log(err)
      else
        $(el).replaceWith(out)    
    exchanges[exg['name']] = exg
  $('ul.exchanges li').click(exg_toggle)

spans_to_json = (el)->
  record = {}
  $("span", el).each (idx,el)->
    j = $(el)
    record[j.attr('key')] = j.html()
  record

exg_toggle = (event) ->
  el = $(event.target)
  name = el.attr('name')
  exchange = exchanges[name]
  exchange.active = !exchange.active
  if exchange.active
    el.addClass('btn-success')
  if !exchange.active
    el.removeClass('btn-success')
{'fraction_non_alphanumeric': 0.16093835242771412, 'fraction_numerical': 0.0, 'mean_word_length': 3.37708830548926, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '3730678', 'n_tokens_mistral': 634, 'n_tokens_neox': 619, 'n_words': 150}