diff --git a/src/app/loadJavascripts.coffee b/src/app/browser.coffee
similarity index 50%
rename from src/app/loadJavascripts.coffee
rename to src/app/browser.coffee
index 33d4a5d28f..75ae8a961a 100644
--- a/src/app/loadJavascripts.coffee
+++ b/src/app/browser.coffee
@@ -1,10 +1,51 @@
+###
+ Sets up "+1 Exp", "Level Up", etc notifications
+###
+module.exports.setupGrowlNotifications = (model) ->
+ return unless jQuery? # Only run this in the browser
+ user = model.at '_user'
+
+ statsNotification = (html, type) ->
+ #don't show notifications if user dead
+ return if user.get('stats.lvl') == 0
+ $.bootstrapGrowl html,
+ type: type # (null, 'info', 'error', 'success')
+ top_offset: 20
+ align: 'right' # ('left', 'right', or 'center')
+ width: 250 # (integer, or 'auto')
+ delay: 3000
+ allow_dismiss: true
+ stackup_spacing: 10 # spacing between consecutive stacecked growls.
+
+ # Setup listeners which trigger notifications
+ user.on 'set', 'stats.hp', (captures, args) ->
+ num = captures - args
+ rounded = Math.abs(num.toFixed(1))
+ if num < 0
+ statsNotification "HP -#{rounded}", 'error' # lost hp from purchase
+
+ user.on 'set', 'stats.money', (captures, args) ->
+ num = captures - args
+ rounded = Math.abs(num.toFixed(1))
+ # made purchase
+ if num < 0
+ # FIXME use 'warning' when unchecking an accidently completed daily/todo, and notify of exp too
+ statsNotification "GP -#{rounded}", 'success'
+ # gained money (and thereby exp)
+ else if num > 0
+ num = Math.abs(num)
+ statsNotification "Exp,GP +#{rounded}", 'success'
+
+ user.on 'set', 'stats.lvl', (captures, args) ->
+ if captures > args
+ statsNotification(' Level Up!', 'info')
+
###
Loads JavaScript files from (1) public/js/* and (2) external sources
We use this file (instead of or inside .html) so we can utilize require() to concatinate for
faster page load, and $.getScript for asyncronous external script loading
###
-
-module.exports = (model) ->
+module.exports.loadJavaScripts = (model) ->
# Load public/js/* files
# TODO use Bower
diff --git a/src/app/index.coffee b/src/app/index.coffee
index 6a78663a63..be1579bfe2 100644
--- a/src/app/index.coffee
+++ b/src/app/index.coffee
@@ -79,7 +79,7 @@ get '/', (page, model, next) ->
# ========== CONTROLLER FUNCTIONS ==========
ready (model) ->
- require('./loadJavascripts')(model)
+ require('./browser').loadJavaScripts(model)
# Setup model in scoring functions
scoring.setModel(model)
diff --git a/src/app/scoring.coffee b/src/app/scoring.coffee
index d4d37751a6..ff8c9005aa 100644
--- a/src/app/scoring.coffee
+++ b/src/app/scoring.coffee
@@ -3,6 +3,7 @@ moment = require 'moment'
_ = require 'lodash'
content = require './content'
helpers = require './helpers'
+browser = require './browser'
MODIFIER = .03 # each new level, armor, weapon add 3% modifier (this number may change)
user = undefined
model = undefined
@@ -11,48 +12,9 @@ model = undefined
setModel = (m) ->
model = m
user = model.at('_user')
- setupNotifications() unless model.get('_view.mobileDevice')
+ browser.setupGrowlNotifications(model) unless model.get('_view.mobileDevice')
-setupNotifications = ->
- return unless jQuery? # Only run this in the browser
-
- statsNotification = (html, type) ->
- #don't show notifications if user dead
- return if user.get('stats.lvl') == 0
- $.bootstrapGrowl html, {
- type: type # (null, 'info', 'error', 'success')
- top_offset: 20
- align: 'right' # ('left', 'right', or 'center')
- width: 250 # (integer, or 'auto')
- delay: 3000
- allow_dismiss: true
- stackup_spacing: 10 # spacing between consecutive stacecked growls.
- }
-
- # Setup listeners which trigger notifications
- user.on 'set', 'stats.hp', (captures, args) ->
- num = captures - args
- rounded = Math.abs(num.toFixed(1))
- if num < 0
- statsNotification "HP -#{rounded}", 'error' # lost hp from purchase
-
- user.on 'set', 'stats.money', (captures, args) ->
- num = captures - args
- rounded = Math.abs(num.toFixed(1))
- # made purchase
- if num < 0
- # FIXME use 'warning' when unchecking an accidently completed daily/todo, and notify of exp too
- statsNotification "GP -#{rounded}", 'success'
- # gained money (and thereby exp)
- else if num > 0
- num = Math.abs(num)
- statsNotification "Exp,GP +#{rounded}", 'success'
-
- user.on 'set', 'stats.lvl', (captures, args) ->
- if captures > args
- statsNotification(' Level Up!', 'info')
-
-###
+###
Calculates Exp & GP modification based on weapon & lvl
{value} task.value for gain
{modifiers} may manually pass in stats as {weapon, exp}. This is used for testing