From af706e59b3fb08c4e850bb710a11168f85879d9b Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Wed, 20 Jun 2012 17:13:47 -0400 Subject: [PATCH] add model.fn '_tnl' & temporary window.model debugging function --- src/app/index.coffee | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/app/index.coffee b/src/app/index.coffee index 309c334f45..8330e23a9a 100644 --- a/src/app/index.coffee +++ b/src/app/index.coffee @@ -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