Fixes #13 by introducing vibration where available

This commit is contained in:
Marc Wäckerlin
2015-08-16 15:07:17 +00:00
parent fcd44e79d5
commit 32acb4e442
8 changed files with 293 additions and 59 deletions

View File

@@ -15,7 +15,7 @@
<body>
<div id="header">
<h1>Safe Chat</h1>
<h1>Safe Chat @PACKAGE_VERSION@</h1>
</div>
<div id="main">

View File

@@ -119,6 +119,19 @@ function status(text, msg) {
});
}
/// Alert user
/** Alert user, e.g. that a new message has arrived.
@param */
function alert() {
navigator.vibrate =
navigator.vibrate || navigator.webkitVibrate || navigator.mozVibrate || navigator.msVibrate;
if (navigator.vibrate) {
// vibration API supported
navigator.vibrate(1000);
}
(new Audio("A-Tone-His_Self-1266414414.mp3")).play();
}
/// Check if user name is available
/** Calls checknewuser.php on server and displays an error, if the
user name is already in use. This function is used when creating a
@@ -372,9 +385,7 @@ function get() {
// calculate and show emoticons
$('#id'+e.id).emoticonize();
// beep for the first new message
if (!beeped)
(new Audio("A-Tone-His_Self-1266414414.mp3"))
.play();
if (!beeped) alert()
beeped = true;
success();
})