add model.fn '_tnl' & temporary window.model debugging function

This commit is contained in:
Tyler Renelle 2012-06-20 17:13:47 -04:00
parent 15e4f987a6
commit af706e59b3

View file

@ -37,33 +37,39 @@ get '/', (page, model) ->
# Otherwise, select a new userId and initialize user
if !userId
userId = newUser(model, userId)
model.subscribe "users.#{userId}", (err, user) ->
model.ref '_user', user
# Setup "_todoList" for all the habit types
# Setup "_todoList" for all the habit types
lists = [ 'habit', 'daily', 'todo', 'reward']
for type in lists
ids = user.at "#{type}Ids"
model.refList "_#{type}List", "_user.#{type}s", "_user.#{type}Ids"
# http://tibia.wikia.com/wiki/Formula
model.fn '_tnl', '_user.lvl', (lvl) -> 50 * Math.pow(lvl, 2) - 150 * lvl + 200
page.render()
## VIEW HELPERS ##
view.fn 'taskClasses', (type, completed) ->
classes = type
classes = type
classes += " completed" if completed
return classes
## CONTROLLER FUNCTIONS ##
ready (model) ->
#TODO remove this!!!!! dangerous temporary debugging helper
window.model = model
lists = [ 'habit', 'daily', 'todo', 'reward']
for type in lists
list = model.at "_#{type}List"
# Make the list draggable using jQuery UI
ul = $(".#{type}s ul")
ul.sortable