/
notify.html
executable file
·60 lines (57 loc) · 1.6 KB
/
notify.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="notify.css" />
<script src="jquery-1.4.4.min.js"></script>
<script src="common.js"></script>
</head>
<body>
<script>
var num = localStorage.unrd, //邮件数
msg_title = render(_LOCALE('have_N_mails'), {num: num}),
msg_handle = _LOCALE('handle_them'),
mgs_ignore = _LOCALE('ignore'),
digest = [], mail_ids = [],
bg = chrome.extension.getBackgroundPage(),
mails = parse(localStorage.mails),
ignored = parse(localStorage.ignored) || [];
for (var i = 0, len = mails.length; i < len; i++) {
var id = mails[i].id;
// 7 messages in digest at most.
if (digest.length < 7 && ignored.indexOf(id) == -1) {
digest.push((i+1) + '. ' + mails[i].title);
}
mail_ids.push(id);
}
if (!digest.length) {
window.close();
return;
}
$('body').ready(function(){
$('body').html(['<h1><img src="yellow.png" />',
msg_title,
'</h1><p class="digests">',
digest.join(' | ').slice(0,79), '...</p><a id="ignore" href="#">',
mgs_ignore ,
'</a><a id="enter" href="#">',
msg_handle,
'>></a>'].join('')
);
$('#enter').click(function(e){
bg.OCC.openMail();
window.close();
e.preventDefault();
});
$('#ignore').click(function(e){
if(parse(localStorage.noDupNotify)) {
localStorage.ignored = JSON.stringify(ignored.concat(mail_ids));
}
window.close();
e.preventDefault();
});
setTimeout(function(){window.close();},localStorage.notifyTime*1000);
});
</script>
</body>
</html>