diff --git a/assets/js/controllers/RootCtrl.coffee b/assets/js/controllers/RootCtrl.coffee deleted file mode 100644 index c385c7c9bb..0000000000 --- a/assets/js/controllers/RootCtrl.coffee +++ /dev/null @@ -1,15 +0,0 @@ -"use strict" - -# Make user and settings available for everyone through root scope. -habitrpg.controller "RootCtrl", ($scope, $rootScope, $location, User) -> - $rootScope.modals = {} - $rootScope.User = User - $rootScope.user = User.user - $rootScope.settings = User.settings - - # FIXME this is dangerous, organize helpers.coffee better, so we can group them by which controller needs them, - # and then simply _.defaults($scope, Helpers.user) kinda thing - _.defaults $rootScope, window.habitrpgShared.algos - _.defaults $rootScope, window.habitrpgShared.helpers - $rootScope.authenticated = -> - User.settings.auth.apiId isnt "" \ No newline at end of file diff --git a/assets/js/controllers/rootCtrl.js b/assets/js/controllers/rootCtrl.js new file mode 100644 index 0000000000..20db696454 --- /dev/null +++ b/assets/js/controllers/rootCtrl.js @@ -0,0 +1,33 @@ +"use strict"; + +/* Make user and settings available for everyone through root scope. + */ + +habitrpg.controller("RootCtrl", function($scope, $rootScope, $location, User) { + $rootScope.modals = {}; + $rootScope.User = User; + $rootScope.user = User.user; + $rootScope.settings = User.settings; + + /* + FIXME this is dangerous, organize helpers.coffee better, so we can group them by which controller needs them, + and then simply _.defaults($scope, Helpers.user) kinda thing + */ + _.defaults($rootScope, window.habitrpgShared.algos); + _.defaults($rootScope, window.habitrpgShared.helpers); + + /* + Very simple path-set. `set('preferences.gender','m')` for example. We'll deprecate this once we have a complete API + */ + $rootScope.set = function(k, v) { + var log = { op: 'set' }; + window.helpers.dotSet(k, v, User.user); + log[k] = v; + User.log(log); + }; + + $rootScope.authenticated = function() { + User.settings.auth.apiId !== ""; + }; + +});