mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-07-13 17:52:22 +00:00
fix bug music not playing if music menu not open + integrate daily/todo/reward sounds
This commit is contained in:
parent
dcbd460331
commit
a5f1e30880
4 changed files with 21 additions and 10 deletions
|
|
@ -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';
|
||||
|
|
|
|||
|
|
@ -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}})
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Reference in a new issue