authentication.js
1.39 KB
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
39
40
41
42
43
44
45
46
47
48
49
(function($,contextPath){
window.authentication=true;
var logoutEvent=function(){
layer.open({
type:1,
title:false,
content:'\
<div style="padding:50px;width:100%;height:100%;">\
<p style="text-align:center;">\
<span class="glyphicon glyphicon-exclamation-sign" style="font-size:40px;color:gray;"></span>\
</p>\
<p style="text-align:center;margin-top:30px;">\
由于刚刚的操作,您的登录帐号已发生变化,请注意使用!\
</p>\
</div>',
area:['400px','250px'],
btn:'我知道了',
btnAlign:'c',
yes:function(index,layero){
window.location.assign(contextPath)
layer.close(index);
},
cancel: function(index){
window.location.assign(contextPath)
},
success: function(layero, index){
$(layero).find('.layui-layer-btn').css('text-align','center');
}
});
}
var connection=function(){
if(window.authentication===false)return;
var xmlhttp=new XMLHttpRequest();
xmlhttp.open('GET',contextPath+'/authentication?t=' + Math.random(),true);
xmlhttp.send();
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
if(xmlhttp.responseText&&xmlhttp.responseText.indexOf('data:reconnection')!=-1){
connection();
}else{
window.authentication=false;
if(window._isOwner)return;
logoutEvent();
}
}
}
};
connection();
})(jQuery,_contextPath)