mirror of
https://github.com/YunoHost-Apps/minchat_ynh.git
synced 2024-09-03 19:36:29 +02:00
Possible alerts when new messages
This commit is contained in:
parent
69123fc39a
commit
e2eec9cb2f
2 changed files with 24 additions and 6 deletions
|
@ -76,8 +76,14 @@ if ($name.$room=="") {
|
||||||
?>
|
?>
|
||||||
<div id="wrapper">
|
<div id="wrapper">
|
||||||
<div id="menu">
|
<div id="menu">
|
||||||
<p class="welcome">Welcome to the <b><?php echo $room; ?></b> room, <b><?php echo $name; ?></b></p>
|
<div style="float:right">Alert on new message:
|
||||||
<div style="clear:both"></div>
|
<select id="whenal">
|
||||||
|
<option value="alno">never</option>
|
||||||
|
<option value="alwnf">when not in focus</option>
|
||||||
|
<option value="alyes">always</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<p class="welcome">Welcome to the <b><?php echo $room; ?></b> room, <b><?php echo $name; ?></b></p>
|
||||||
</div>
|
</div>
|
||||||
<div id="content">
|
<div id="content">
|
||||||
<div id="chatbox"></div>
|
<div id="chatbox"></div>
|
||||||
|
@ -103,10 +109,18 @@ function lienurl(s){
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
var doalert=false; // pas d'alerte au chargement init
|
||||||
var pos = 0;
|
var pos = 0;
|
||||||
var lastdate = 0;
|
var lastdate = 0;
|
||||||
var lastday='';
|
var lastday='';
|
||||||
var oldscrollHeight = $("#chatbox")[0].scrollHeight;
|
var oldscrollHeight = $("#chatbox")[0].scrollHeight;
|
||||||
|
var whenal=localStorage.getItem('whenal');
|
||||||
|
if (whenal===null) whenal="alno";
|
||||||
|
$("#whenal").val(whenal);
|
||||||
|
$("#whenal").change(function(){
|
||||||
|
whenal=$("#whenal").val();
|
||||||
|
localStorage.setItem('whenal',whenal);
|
||||||
|
});
|
||||||
|
|
||||||
$("#submitmsg").click(function() {
|
$("#submitmsg").click(function() {
|
||||||
var clientmsg = $("#usermsg").val();
|
var clientmsg = $("#usermsg").val();
|
||||||
|
@ -118,7 +132,8 @@ function lienurl(s){
|
||||||
data: {text: clientmsg,name:'<?php echo $name; ?>',room:'<?php echo $room; ?>'},
|
data: {text: clientmsg,name:'<?php echo $name; ?>',room:'<?php echo $room; ?>'},
|
||||||
async: false,
|
async: false,
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
loadLog();
|
doalert=false;
|
||||||
|
loadLog(); // pas d'alerte si propre message
|
||||||
},
|
},
|
||||||
error: function(request, status, error) {
|
error: function(request, status, error) {
|
||||||
$("#usermsg").val(clientmsg);
|
$("#usermsg").val(clientmsg);
|
||||||
|
@ -166,7 +181,12 @@ function lienurl(s){
|
||||||
html="";
|
html="";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$("#chatbox").append(html);
|
$("#chatbox").append(html);
|
||||||
|
if (doalert &&(whenal=="alyes" || ((whenal!=="alno") && !document.hasFocus()))){
|
||||||
|
alert('New message!');
|
||||||
|
}
|
||||||
|
doalert=true; // par défaut, alerte pour les autres cas
|
||||||
|
|
||||||
}
|
}
|
||||||
var newscrollHeight = $("#chatbox")[0].scrollHeight;
|
var newscrollHeight = $("#chatbox")[0].scrollHeight;
|
||||||
if (newscrollHeight > oldscrollHeight) {
|
if (newscrollHeight > oldscrollHeight) {
|
||||||
|
|
|
@ -65,8 +65,6 @@ a:hover { text-decoration: underline; }
|
||||||
|
|
||||||
#menu { padding: 12.5px 25px 12.5px 25px; }
|
#menu { padding: 12.5px 25px 12.5px 25px; }
|
||||||
|
|
||||||
.welcome { float: left; }
|
|
||||||
|
|
||||||
.logout { float: right; }
|
.logout { float: right; }
|
||||||
|
|
||||||
.tform { display: table; }
|
.tform { display: table; }
|
||||||
|
|
Loading…
Reference in a new issue