aboutsummaryrefslogtreecommitdiffstats
path: root/public/js/report.coffee
blob: 650e25b473159538d759c9604a21590b8f4608a6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
$(->
  $('.date').datepicker()

  $.getJSON('transactions', (data) ->
    $.each(data.transactions, ->
      keys = Object.keys(this)
      transaction = this

      $.each(keys, (i,v) ->
        $('tbody tr:last td:eq(' + i + ')').html(transaction[v])
      })

      $('tbody:last').append($('tbody tr:last').clone())
    })
    $('tbody tr:last').remove()

    btc = 0
    $('td:nth-child(4)').each(->
      btc += parseFloat($(this).html())
    })
    $('#btc').html(btc)

    cad = 0
    $('td:nth-child(5)').each(->
      cad += parseFloat($(this).html())
    })
    $('#cad').html(cad)
  })
)