-
Notifications
You must be signed in to change notification settings - Fork 7
/
background.js
39 lines (35 loc) · 1.05 KB
/
background.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
chrome.alarms.onAlarm.addListener(function () {
chrome.storage.local.get(function(result){
var lastMsgId = result.lastMsgId;
var accessToken = result.newAccessToken;
if( lastMsgId != null && accessToken != null) {
jQuery.ajax({
type :"GET",
url : 'https://www.yammer.com/api/v1/messages/received.json?newer_than='+lastMsgId+'&access_token='+accessToken,
data:{
"limit":5
},
dataType: 'json',
xhrFields: {
withCredentials: false
},
success : function(data) {
if(data.messages.length != 0) {
// set the notifier icon
/*chrome.browserAction.setIcon({
path: newMessageNotifierImgPath
});*/
var badgeText = data.messages.length.toString();;
chrome.browserAction.setBadgeText({text: badgeText});
}
else {
//console.log("empty messages");
}
},
error : function(){
//alert("background js error");
}
});
}
});
});