mirror of
https://github.com/nerzhul/ocsms.git
synced 2025-06-08 16:36:25 +00:00
Blink tab when new message arrive and we are not in tab
This commit is contained in:
parent
96bc650e9f
commit
4fa5867e33
10
js/script.js
10
js/script.js
@ -13,6 +13,7 @@
|
|||||||
var selectedConversation = null;
|
var selectedConversation = null;
|
||||||
var curPhoneNumber = null;
|
var curPhoneNumber = null;
|
||||||
var lastMsgDate = 0;
|
var lastMsgDate = 0;
|
||||||
|
var originalTitle = '';
|
||||||
|
|
||||||
$.urlParam = function(name){
|
$.urlParam = function(name){
|
||||||
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
|
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
|
||||||
@ -32,7 +33,6 @@ var refreshConversation = function() {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$.getJSON(OC.generateUrl('/apps/ocsms/get/conversation'),
|
$.getJSON(OC.generateUrl('/apps/ocsms/get/conversation'),
|
||||||
{
|
{
|
||||||
'phoneNumber': curPhoneNumber,
|
'phoneNumber': curPhoneNumber,
|
||||||
@ -43,6 +43,10 @@ var refreshConversation = function() {
|
|||||||
if (conversationBuf != '') {
|
if (conversationBuf != '') {
|
||||||
$('.msg-endtag').before(conversationBuf);
|
$('.msg-endtag').before(conversationBuf);
|
||||||
$('#app-content').scrollTop(1E10);
|
$('#app-content').scrollTop(1E10);
|
||||||
|
// This will blink the tab because there is new messages
|
||||||
|
if (document.hasFocus() == false) {
|
||||||
|
document.title = originalTitle + " (new messages !)";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($('#app-content-header').is(':hidden')) {
|
if ($('#app-content-header').is(':hidden')) {
|
||||||
@ -188,6 +192,9 @@ function fetchInitialPeerList(jsondata) {
|
|||||||
|
|
||||||
(function ($, OC) {
|
(function ($, OC) {
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
// Register real title
|
||||||
|
originalTitle = document.title;
|
||||||
|
|
||||||
// Now bind the events when we click on the phone number
|
// Now bind the events when we click on the phone number
|
||||||
$.getJSON(OC.generateUrl('/apps/ocsms/get/peerlist'), function(jsondata, status) {
|
$.getJSON(OC.generateUrl('/apps/ocsms/get/peerlist'), function(jsondata, status) {
|
||||||
fetchInitialPeerList(jsondata);
|
fetchInitialPeerList(jsondata);
|
||||||
@ -229,5 +236,4 @@ function fetchInitialPeerList(jsondata) {
|
|||||||
});
|
});
|
||||||
setInterval(refreshConversation, 10000);
|
setInterval(refreshConversation, 10000);
|
||||||
});
|
});
|
||||||
|
|
||||||
})(jQuery, OC);
|
})(jQuery, OC);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user