<commit_before>if savedData = localStorage.getItem('stocks')
  window.stocks = savedData.split(',')
else
  window.stocks = ['GOOG', 'AAPL', 'YHOO']

source   = $("#stock-template").html()
template = Handlebars.compile(source)

_.each window.stocks, (symbol) ->
  stock = {symbol: symbol, last_price: ''}

  $('.stock-list').append('<li name="' + stock.symbol + '">' + template(stock) + '</li>')

  callback = (data) ->
    $($('li[name=' + symbol + ']')[0]).html(template(data))
    window.bindEvents()

  $.ajax({
    contentType: 'application/json',
    type: 'GET',
    url: '/stocks',
    data: { symbol: symbol },
    dataType: 'json',
    success: callback
  })

$stockList = $('.stock-list')
$($stockList[0]).addClass('active')

$($('.nav-item')[0]).addClass('active')

$('.nav-item').click (e) ->
  e.preventDefault()
  index = $(@).index()

  $('.nav-item').removeClass('active')
  $(@).addClass('active')

  $('.stock-list').removeClass('active')
  $($('.stock-list')[index]).addClass('active')

$('#symbol-lookup').click ->
  $('.add-symbol-wrapper').removeClass('visible')
  $('.symbol-lookup-wrapper').toggleClass('visible')

$('#add-symbol').click ->
  $('.symbol-lookup-wrapper').removeClass('visible')
  $('.add-symbol-wrapper').toggleClass('visible')

$('.stock-list li').click ->
  $(@).toggleClass('show-drawer')

window.bindEvents =  ->

  $(document).on 'click', '.remove', (event) ->
    event.preventDefault()
    stock = $(e.currentTarget).attr('name')
    window.stocks = _.reject(window.stocks, (symbol) -> symbol is stock)
    localStorage.setItem('stocks', window.stocks)
    $('li[name=' + stock + ']').remove()

  $('#add-symbol-form').submit (event) ->
    event.preventDefault()
    symbol = $(this).find('input')[0].value

    unless _.include(window.stocks, symbol)
      window.stocks.push(symbol)
      localStorage.setItem('stocks', window.stocks)

      stock = {symbol: symbol, last_price: ''}

      $('.stock-list').append('<li name="' + stock.symbol + '">' + template(stock) + '</li>')

      callback = (data) ->
        $($('li[name=' + symbol + ']')[0]).html(template(data))
        $('.stock-list').append()
        $('#add-symbol-form input').val('')

      $.ajax({
        contentType: 'application/json',
        url: '/stocks',
        data: { symbol: symbol },
        dataType: 'json',
        success: callback
      })

      window.bindEvents()
<commit_msg>Fix remove symbol behavior<commit_after>if savedData = localStorage.getItem('stocks')
  window.stocks = savedData.split(',')
else
  window.stocks = ['GOOG', 'AAPL', 'YHOO']

source   = $("#stock-template").html()
template = Handlebars.compile(source)

_.each window.stocks, (symbol) ->
  stock = {symbol: symbol, last_price: ''}

  $('.stock-list').append('<li name="' + stock.symbol + '">' + template(stock) + '</li>')

  callback = (data) ->
    $($('li[name=' + symbol + ']')[0]).html(template(data))
    window.bindEvents()

  $.ajax({
    contentType: 'application/json',
    type: 'GET',
    url: '/stocks',
    data: { symbol: symbol },
    dataType: 'json',
    success: callback
  })

$stockList = $('.stock-list')
$($stockList[0]).addClass('active')

$($('.nav-item')[0]).addClass('active')

$('.nav-item').click (e) ->
  e.preventDefault()
  index = $(@).index()

  $('.nav-item').removeClass('active')
  $(@).addClass('active')

  $('.stock-list').removeClass('active')
  $($('.stock-list')[index]).addClass('active')

$('#symbol-lookup').click ->
  $('.add-symbol-wrapper').removeClass('visible')
  $('.symbol-lookup-wrapper').toggleClass('visible')

$('#add-symbol').click ->
  $('.symbol-lookup-wrapper').removeClass('visible')
  $('.add-symbol-wrapper').toggleClass('visible')

$('.stock-list li').click ->
  $(@).toggleClass('show-drawer')

window.bindEvents =  ->

  $(document).on 'click', '.remove', (event) ->
    event.preventDefault()
    stock = $(event.currentTarget).attr('name')
    window.stocks = _.reject(window.stocks, (symbol) -> symbol is stock)
    localStorage.setItem('stocks', window.stocks)
    $('li[name=' + stock + ']').remove()

  $('#add-symbol-form').submit (event) ->
    event.preventDefault()
    symbol = $(this).find('input')[0].value

    unless _.include(window.stocks, symbol)
      window.stocks.push(symbol)
      localStorage.setItem('stocks', window.stocks)

      stock = {symbol: symbol, last_price: ''}

      $('.stock-list').append('<li name="' + stock.symbol + '">' + template(stock) + '</li>')

      callback = (data) ->
        $($('li[name=' + symbol + ']')[0]).html(template(data))
        $('.stock-list').append()
        $('#add-symbol-form input').val('')

      $.ajax({
        contentType: 'application/json',
        type: 'GET',
        url: '/stocks',
        data: { symbol: symbol },
        dataType: 'json',
        success: callback
      })

      window.bindEvents()

{'fraction_non_alphanumeric': 0.23889802631578946, 'fraction_numerical': 0.002055921052631579, 'mean_word_length': 3.488007380073801, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 33, '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': '3382717', 'n_tokens_mistral': 1603, 'n_tokens_neox': 1596, 'n_words': 261}