-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
69 lines (53 loc) · 1.95 KB
/
popup.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
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
var id = 'PKNotifier';
var alerts = 0;
var messages = 0;
var a = -1;
var m = -1;
function update() {
//Archived code. New system uses badges!
/*var s = "You have no new alerts or messages."
var alertsURL = "http://projectkorra.com/account/alerts";
var msgURL = "http://projectkorra.com/conversations/"
if (alerts > 0 && messages > 0) {
s = 'You have <a href="' + alertsURL + '">' + alerts + ' new alert' + (alerts == 1 ? '' : 's') + '</a> and <a href="' + msgURL + '">' + messages + ' new message' + (messages == 1 ? '' : 's') + '</a>!'
}
else if (alerts > 0) {
s = 'You have <a href="' + alertsURL + '">' + alerts + ' new alert' + (alerts == 1 ? '' : 's') + '</a>!'
}
else if (messages > 0) {
s = 'You have <a href="' + msgURL + '">' + messages + ' new message' + (messages == 1 ? '' : 's') + '</a>!'
}
$('#content').html(s);*/
$("#alertsCount").text((alerts <= 0 ? "" : alerts) + "");
$("#messageCount").text((messages <= 0 ? "" : messages) + "");
}
$(document).ready(function() {
$("#version").text("Version " + chrome.app.getDetails().version);
$("#settings").click(function() {
chrome.runtime.openOptionsPage()
});
chrome.storage.local.get('alerts', function(result) {
alerts = parseInt(result.alerts);
a = result.alerts;
a = result;
update();
});
chrome.storage.local.get('messages', function(response) {
messages = parseInt(response.messages);
m = response.messages;
update();
});
$('body').on('click', 'button', function() {
chrome.tabs.create({
url: $(this).attr('href')
});
return false;
});
$('body').on('click', 'a', function() {
if ($(this).id == "settings") return false;
chrome.tabs.create({
url: $(this).attr('href')
});
return false;
});
});