This repository has been archived by the owner on Jan 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.html
72 lines (67 loc) · 2.22 KB
/
background.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
61
62
63
64
65
66
67
68
69
70
71
72
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
$(document).ready(function() {
fetchGowalla(true);
setInterval(fetchGowalla, 60000 * 5);
});
function fetchGowalla(initialRun) {
$.ajax({
url: 'http://gowalla.com/users/'+localStorage["gowallaUsername"]+'/friends_visits.atom',
success: function(data) {
if(data != null) {
html = '';
count = 0;
date = null;
$(data).find('entry').each(function(index) {
date = new Date($(this).find('updated').first().text());
if(date.getTime() > localStorage.lastRead)
count++;
if(initialRun == true && index == 0) {
localStorage.lastRead = date.getTime();
localStorage.notified = 0;
localStorage.badgeCount = 0;
}
});
if(count > 0) {
if(localStorage.desktopNotifications == 1 && (localStorage.notified == 0 || count > localStorage.badgeCount)) {
if(count == 1) {
var notification = webkitNotifications.createNotification(
'gowallaCling_icon.png',
'Gowalla Friends Activity',
'You\'ve had '+count.toString()+' friend checkin via Gowalla recently.'
);
} else {
var notification = webkitNotifications.createNotification(
'gowallaCling_icon.png',
'Gowalla Friends Activity',
'You\'ve had '+count.toString()+' friends checkin via Gowalla recently.'
);
}
localStorage.notified = 1;
notification.ondisplay = function() {
setTimeout(function () {notification.cancel();}, 8000);
};
notification.show();
}
localStorage.badgeCount = count;
badgeText = count > 99 ? "99+" : count.toString();
chrome.browserAction.setTitle({title: "Recent Friends Activity"});
chrome.browserAction.setBadgeText({text: badgeText});
chrome.browserAction.setBadgeBackgroundColor({color: [57,161,232,255]});
} else {
chrome.browserAction.setTitle({title: "No Friends Activity"});
chrome.browserAction.setBadgeText({text: ""});
}
}
}
});
}
</script>
</head>
<body>
</body>
</html>