Skip to content

Commit

Permalink
New gamification sound
Browse files Browse the repository at this point in the history
  • Loading branch information
fracz committed Mar 20, 2019
1 parent 26817d9 commit 171d9fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions frontend/app/gamification/ResultBoardController.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ angular.module('git-exercises').component 'resultBoard',
$(document).mousedown (e) =>
if e.which == 2 or e.ctrlKey
$scope.$apply(=> @adminFormVisible = !@adminFormVisible)
@sound = 1
@sounds = [
new Audio('/images/sounds/your-turn.mp3')
new Audio('/images/sounds/cheerful.mp3')
]

fetch: =>
Expand All @@ -32,14 +34,17 @@ angular.module('git-exercises').component 'resultBoard',
# @resultBoard.splice(7)
angular.extend(item, newResults.find((i) -> i.committer_id is item.committer_id)) for item in @resultBoard
newPoints = @resultBoard.map((c) -> c.points).join('|')
if newPoints != oldPoints
@sounds[Math.floor(Math.random() * @sounds.length)].play()
@playSound() if newPoints != oldPoints
.catch =>
@fetchError = true
@currentSessionData = undefined
@resultBoard = []
.finally(=> $timeout(@fetch, 3000))

playSound: =>
sound = if @sound == -1 then Math.floor(Math.random() * @sounds.length) else @sound
@sounds[sound].play()

endCurrentSession: =>
if confirm('Na pewno zakończyć sesję?')
GamificationService.endCurrentSession(@adminPassword)
Expand Down
Binary file added frontend/public/images/sounds/cheerful.mp3
Binary file not shown.

0 comments on commit 171d9fe

Please sign in to comment.