utility.js
733 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var blinkInterval;
var docTitle = document.title;
/**
* 检查是否支持 websocket
* @returns {boolean}
*/
exports.isSupport = function() {
return !!window.WebSocket;
};
/**
* 添加闪烁提醒
* @returns {boolean}
*/
exports.addBlinkAlert = function() {
if (blinkInterval) {
clearInterval(blinkInterval);
}
blinkInterval = setInterval(function() {
document.title = '您有新消息';
setTimeout(function() {
document.title = docTitle;
}, 300);
}, 600);
};
/**
* 去除闪烁提醒
* @returns {boolean}
*/
exports.removeBlinkAlert = function() {
if (blinkInterval) {
clearInterval(blinkInterval);
document.title = docTitle;
}
};