diff --git a/public/js/controllers/rootCtrl.js b/public/js/controllers/rootCtrl.js index c89b770c59..7091331d29 100644 --- a/public/js/controllers/rootCtrl.js +++ b/public/js/controllers/rootCtrl.js @@ -50,9 +50,8 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$ } $rootScope.playSound = function(id){ - if (!User.user.preferences.sound) return; - var select = document.getElementById('audioTheme'); - var theme = select.options[select.selectedIndex].value; + if (!user.preferences.sound) return; + var theme = user.preferences.soundTheme; var file = 'audio/' + theme + '/' + id; document.getElementById('oggSource').src = file + '.ogg'; document.getElementById('mp3Source').src = file + '.mp3'; diff --git a/public/js/controllers/tasksCtrl.js b/public/js/controllers/tasksCtrl.js index 5c4de9c4b5..ec44bd0768 100644 --- a/public/js/controllers/tasksCtrl.js +++ b/public/js/controllers/tasksCtrl.js @@ -6,8 +6,20 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N $scope.user = User.user; $scope.score = function(task, direction) { - if (direction === 'down') $rootScope.playSound('Minus_Habit'); - if (direction === 'up') $rootScope.playSound('Plus_Habit'); + switch (task.type) { + case 'reward': + $rootScope.playSound('Reward'); + break; + case 'daily': + $rootScope.playSound('Daily'); + break; + case 'todo': + $rootScope.playSound('ToDo'); + break; + default: + if (direction === 'down') $rootScope.playSound('Minus_Habit'); + else if (direction === 'up') $rootScope.playSound('Plus_Habit'); + } User.user.ops.score({params:{id: task.id, direction:direction}}) }; diff --git a/views/index.jade b/views/index.jade index ae05c36d9f..a6d92ad08f 100644 --- a/views/index.jade +++ b/views/index.jade @@ -35,8 +35,3 @@ html(ng-app="habitrpg", ng-controller="RootCtrl", ng-class='{"applying-action":a #main(ui-view) include ./shared/footer - - // Load audio last - audio#sound(autoplay) - source#oggSource(type="audio/ogg") - source#mp3Source(type="audio/mp3") diff --git a/views/shared/footer.jade b/views/shared/footer.jade index a013c8135f..106e29547f 100644 --- a/views/shared/footer.jade +++ b/views/shared/footer.jade @@ -78,3 +78,8 @@ footer.footer(ng-controller='FooterCtrl') a.btn.btn-default(ng-click='addOneLevel()') +1 Level div(ng-init='deferredScripts()') + + // Load audio last + audio#sound(autoplay) + source#oggSource(type="audio/ogg") + source#mp3Source(type="audio/mp3")