forked from hooray/hoorayos
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhros.lock.js
More file actions
161 lines (161 loc) · 4.42 KB
/
hros.lock.js
File metadata and controls
161 lines (161 loc) · 4.42 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
HROS.lock = (function(){
return {
init: function(){
Mousetrap.bind(['space'], function(){
$('#lock').click();
return false;
});
$('body').on('click', '#lock', function(){
if($('#lock-info').is(':visible')){
$('#lock .title').animate({
top: '10%'
}, 500);
$('#lock .tip').animate({
top: '80%'
}, 500);
$('#lock-info').fadeOut();
Mousetrap.bind(['space'], function(){
$('#lock').click();
return false;
});
Mousetrap.unbind('esc');
}else{
$('#lock .title').animate({
top: '-200px'
}, 500);
$('#lock .tip').animate({
top: '100%'
}, 500);
$('#lock-info').fadeIn();
$('#lockpassword').val('').focus();
$('#lock-info .text-tip').text('');
Mousetrap.bind(['esc'], function(){
$('#lock').click();
return false;
});
Mousetrap.unbind('space');
}
});
$('body').on('click', '#lock-info', function(){
return false;
});
$('body').on('click', '#lockbtn', function(){
if($('#lockpassword').val() != ''){
$.ajax({
url: 'login.ajax.php',
data: {
ac: 'unlock',
password: $('#lockpassword').val()
}
}).done(function(responseText){
if(responseText == 'ERROR_LOCKPASSWORD'){
$('#lockpassword').val('').focus();
$('#lock-info .text-tip').text('解锁密码错误');
}else{
HROS.lock.hide();
}
});
}else{
$('#lock-info .text-tip').text('请输入解锁密码');
}
});
$('body').on('keydown', '#lockpassword', function(e){
if(e.keyCode == '13'){
$('#lockbtn').click();
}
});
},
show: function(){
if($('#lock').length == 0){
if(!HROS.base.checkLogin()){
HROS.base.loginDialog('锁定功能需要登录后才能使用,为了更好的操作,是否登录?');
}else{
var lock = function(){
$.ajax({
url: 'login.ajax.php',
data: {
ac: 'logout'
}
});
$('#desktop').hide();
var userinfo = Cookies.get(cookie_prefix + 'userinfo');
if(typeof userinfo !== 'undefined'){
userinfo = JSON.parse(userinfo);
$('body').append(HROS.template.lock({
'avatar': userinfo.avatar,
'username': userinfo.username
}));
}
//时间,日期,星期信息的显示
var getTimeDateWeek = function(){
var time = new Date();
$('#lock .time').text((time.getHours() < 10 ? '0' + time.getHours(): time.getHours()) + ':' + (time.getMinutes() < 10 ? '0' + time.getMinutes(): time.getMinutes()));
var date = time.getFullYear() + '/' + (time.getMonth() + 1) + '/' + time.getDate() + ',星期';
switch(time.getDay()){
case '1': date += '一'; break;
case '1': date += '二'; break;
case '1': date += '三'; break;
case '1': date += '四'; break;
case '1': date += '五'; break;
case '1': date += '六'; break;
default: date += '日';
}
$('#lock .week').text(date);
};
getTimeDateWeek();
lockFunc = setInterval(function(){
//检查是否有恶意修改源程序绕过锁屏界面
var iswarning = false;
if($('#desktop').is(':visible')){
iswarning = true;
}
if($('#lock').length == 0){
iswarning = true;
}
if($('#lock').is(':hidden')){
iswarning = true;
}
//如果有则重新载入锁屏
if(iswarning){
clearInterval(lockFunc);
$('#lock').remove();
HROS.lock.show();
}
getTimeDateWeek();
}, 1000);
};
if(Cookies.get(cookie_prefix + 'isfirstlock' + HROS.CONFIG.memberID) == null){
Cookies.set(cookie_prefix + 'isfirstlock' + HROS.CONFIG.memberID, 1);
swal({
type: 'warning',
title: '温馨提示',
text: '解锁密码默认为登录密码,是否要先进行修改?',
showCancelButton: true,
confirmButtonText: '继续锁定',
cancelButtonText: '修改解锁密码'
}, function(isConfirm){
if(isConfirm){
lock();
}else{
HROS.window.createTemp({
appid: 'zhsz',
title: '账号设置',
url: 'sysapp/account/security.php',
width: 550,
height: 580
});
}
});
}else{
lock();
}
}
}
},
hide: function(){
clearInterval(lockFunc);
$('#lock').remove();
$('#desktop').show();
}
}
})();