diff --git a/app/assets/javascripts/backbone/templates/habits/index.jst.ejs b/app/assets/javascripts/backbone/templates/habits/index.jst.ejs
index 067f2d9888..ef0c91de35 100644
--- a/app/assets/javascripts/backbone/templates/habits/index.jst.ejs
+++ b/app/assets/javascripts/backbone/templates/habits/index.jst.ejs
@@ -1,7 +1,5 @@
New Habit
-
-
@@ -55,7 +53,7 @@
Rewards
-
+
@@ -69,7 +67,4 @@
|
-
-
-
diff --git a/app/assets/javascripts/backbone/views/habits/habit_view.js.coffee b/app/assets/javascripts/backbone/views/habits/habit_view.js.coffee
index 1aa7bd464d..53a181f884 100644
--- a/app/assets/javascripts/backbone/views/habits/habit_view.js.coffee
+++ b/app/assets/javascripts/backbone/views/habits/habit_view.js.coffee
@@ -22,10 +22,10 @@ class HabitTracker.Views.Habits.HabitView extends Backbone.View
tagName: "li"
# why is @model not available in this function? having to pass it in like this
- dynamicClass= (model) ->
- output = "habit habit-type-#{model.get('habit_type')}"
- if model.get("done") then output += " done"
- score = model.get("score")
+ dynamicClass: () =>
+ output = "habit habit-type-#{@model.get('habit_type')}"
+ if @model.get("done") then output += " done"
+ score = @model.get("score")
switch
when score<-8 then output += ' color-red'
when score>=-8 and score<-5 then output += ' color-pink'
@@ -38,7 +38,7 @@ class HabitTracker.Views.Habits.HabitView extends Backbone.View
render: ->
$(@el).attr('id', "habit_#{@model.get('id')}")
- $(@el).attr('class', dynamicClass(@model))
+ $(@el).attr('class', @dynamicClass())
$(@el).html(@template(@model.toJSON() ))
@$(".comment").qtip content:
diff --git a/app/assets/javascripts/backbone/views/habits/index_view.js.coffee b/app/assets/javascripts/backbone/views/habits/index_view.js.coffee
index 56f160204e..a5bd7da69d 100644
--- a/app/assets/javascripts/backbone/views/habits/index_view.js.coffee
+++ b/app/assets/javascripts/backbone/views/habits/index_view.js.coffee
@@ -8,12 +8,14 @@ class HabitTracker.Views.Habits.IndexView extends Backbone.View
@options.habits.bind('change', @render, this) #TODO this ruins tabs, revisit
window.userStats.bind('updatedStats', @updateStats, this)
+ # TODO create a view & template, bind to existing element
updateStats: () =>
- # TODO create a view & template, bind to existing element
stats = window.userStats
- #.to_i.to_s
- $('#tnl').html( "(Level #{stats.get('lvl')}) #{Math.round(stats.get('exp'))} / #{stats.tnl()}" )
- $( "#progressbar" ).progressbar value: stats.get('exp')/stats.tnl() * 100
+ @$('#tnl').html( "(Level #{stats.get('lvl')}) #{Math.round(stats.get('exp'))} / #{stats.tnl()}" )
+ @$( "#progressbar" ).progressbar value: stats.get('exp')/stats.tnl() * 100
+
+ money = stats.get('money').toFixed(1).split('.')
+ @$('#money').html("#{money[0]}
#{money[1]}
")
addAll: () =>
@options.habits.each(@addOne)
@@ -29,4 +31,5 @@ class HabitTracker.Views.Habits.IndexView extends Backbone.View
$(@el).html(@template(habits: @options.habits.toJSON() ))
@addAll()
@$("#habits-todos").tabs()
+ @updateStats()
return this
\ No newline at end of file
diff --git a/app/models/user.rb b/app/models/user.rb
index c74cfaed29..f7c323f773 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -27,6 +27,6 @@ class User < ActiveRecord::Base
end
def as_json(options={})
- super(:only => [:email, :lvl, :exp] )
+ super(:only => [:email, :lvl, :exp, :money] )
end
end