付延余
2022-12-16 f0f8ee8c4a945adbc742d9bab69382b28ad311fb
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 timerWarnSound =null;
 
//播放告警音频
function playSound(obj){
    if($(obj).val()!='2'){
        $(obj).html('<i class="far fa-bell"></i>');
        $(obj).val('2');
        $(obj).attr('title','当前已开启页面告警声音提示,点击可关闭');
        timerWarnSound = setInterval(function(){ajaxWarnInfoCount()},60000);
    }else{
        $(obj).val('1');
        $(obj).attr('title','当前已关闭页面告警声音提示,点击可开启');
        $(obj).html('<i style="font-size:0.95rem;" class="far fa-bell-slash"></i>');
        clearInterval(timerWarnSound);
        timerWarnSound=null;
    }
 
}
 
 
function ajaxWarnInfoCount() {
    var urlParams = window.location.search;
    var dashView = "";
    if (urlParams.indexOf("dashView") != -1) {
        dashView = "?dashView=1";
    }
    $.ajax({
        url: "/tssw/warnInfo/warnCountAjax"+dashView,
        type: "GET",
        dataType: "json",
        success: function(data) {
            if(data != '0'){
                document.getElementById("notification").play();
                toastr.error("有新的告警消息,请查看推送通知或<a  target='_blank' href='/tssw/log/list'>点击查看日志");
            }
        }
    });
}