From e598947259e1fa85fe922b33317df6b7d02b4805 Mon Sep 17 00:00:00 2001 From: Darren Date: Fri, 5 Apr 2013 21:49:56 +0100 Subject: [PATCH] Highlight sounds --- client/assets/dev/view.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/client/assets/dev/view.js b/client/assets/dev/view.js index 407c660..dcc161b 100644 --- a/client/assets/dev/view.js +++ b/client/assets/dev/view.js @@ -442,6 +442,7 @@ _kiwi.view.Panel = Backbone.View.extend({ } else if (is_highlight) { _kiwi.app.view.alertWindow('* People are talking!'); + _kiwi.app.view.playSound('highlight'); this.alert('highlight'); } else { @@ -452,6 +453,11 @@ _kiwi.view.Panel = Backbone.View.extend({ this.alert('activity'); } + if (this.model.isQuery() && !this.model.isActive()) { + _kiwi.app.view.alertWindow('* People are talking!'); + _kiwi.app.view.playSound('highlight'); + } + // Update the activity counters (function () { // Only inrement the counters if we're not the active panel @@ -1159,6 +1165,8 @@ _kiwi.view.Application = Backbone.View.extend({ return 'This will close all KiwiIRC conversations. Are you sure you want to close this window?'; } }; + + this.initSound(); }, @@ -1381,6 +1389,36 @@ _kiwi.view.Application = Backbone.View.extend({ $('#controlbox').slideDown(0); this.doLayout(); } + }, + + + initSound: function () { + var that = this, + base_path = this.model.get('base_path'); + + $script(base_path + '/assets/libs/soundmanager2/soundmanager2-nodebug-jsmin.js', function() { + if (typeof soundManager === 'undefined') + return; + + soundManager.setup({ + url: base_path + '/assets/libs/soundmanager2/', + flashVersion: 9, // optional: shiny features (default = 8)// optional: ignore Flash where possible, use 100% HTML5 mode + preferFlash: true, + + onready: function() { + that.sound_object = soundManager.createSound({ + id: 'highlight', + url: base_path + '/assets/sound/highlight.mp3' + }); + } + }); + }); + }, + + + playSound: function (sound_id) { + if (!this.sound_object) return; + soundManager.play(sound_id); } }); -- 2.25.1