Browse files

Notification on new message. HTML5 audio tag.

Added html5 audio tag to play notification on new message. Added .ogg
for Firefox and .mp3 for other browsers.
  • Loading branch information...
1 parent 01c5f61 commit d492ae27e7a73e439074f6a21f2d4c532cf09fca Richard Ive committed Mar 26, 2012
Showing with 10 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +6 −0 public/index.html
  3. +2 −0 public/js/app.js
  4. BIN public/media/bell.mp3
  5. BIN public/media/bell.ogg
View
2 .gitignore
@@ -2,3 +2,5 @@
*.un~
node_modules
test.js
+
+.DS_Store
View
6 public/index.html
@@ -47,6 +47,12 @@
<div id="spiner"></div>
<p id="statusmsg"></p>
</div>
+
+<audio preload="auto" autobuffer id="notification">
+ <source src="media/bell.mp3" />
+ <source src="media/bell.ogg" />
+</audio>
+
<div id="js">
<script src="//code.jquery.com/jquery.js" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.1/underscore-min.js" type="text/javascript"></script>
View
2 public/js/app.js
@@ -101,6 +101,8 @@ $(document).ready(function(){
}
}
+ document.getElementById('notification').play();
+
message = _.escapeHTML(message);
message = giveMeColors(message);
message = message.replace(/(https?:\/\/[-_.a-zA-Z0-9&?\/=\[\]()$!#+:]+)/g, "<a href=\"$1\" target=\"_BLANK\">$1</a>");
View
BIN public/media/bell.mp3
Binary file not shown.
View
BIN public/media/bell.ogg
Binary file not shown.

0 comments on commit d492ae2

Please sign in to comment.