-
Notifications
You must be signed in to change notification settings - Fork 9
/
notif.js
40 lines (33 loc) · 1.02 KB
/
notif.js
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
var capitalise = function(s) {
return s.charAt(0).toUpperCase() + s.slice(1);
};
var context = window.location.search.split('=')[1];
var $msg = $('#notifMsg');
var $link = $('#link2Drive');
$msg.html(chrome.i18n.getMessage('notifSaving' + capitalise(context)));
$link.click(function() {
var label = $link.hasClass('error') ? 'error' : 'success';
chrome.extension.getBackgroundPage().onVisitDrive(label);
window.close();
});
var onSaveSuccess = function() {
$link
.html(chrome.i18n.getMessage('notifLink'))
.attr('href', 'https://drive.google.com/');
$msg.html(chrome.i18n.getMessage('notifSuc' + capitalise(context)));
startTimeout();
};
var onSaveError = function(target) {
$link
.html(chrome.i18n.getMessage('notifLinkError'))
.attr('href', target)
.addClass('error');
$('#notifIcon').addClass('error');
$msg.html(chrome.i18n.getMessage('notifErr' + capitalise(context)));
startTimeout();
};
var startTimeout = function() {
window.setTimeout(function() {
window.close();
}, 5000);
};