Badge UI
This commit is contained in:
parent
41866cee95
commit
6ded33ae48
3 changed files with 19 additions and 5 deletions
|
@ -5,6 +5,9 @@ if (localStorage.getItem('first_install_ran')) {
|
|||
if (isRegistrationDone()) {
|
||||
subscribeToPush(function(message) {
|
||||
console.log("Got message from " + message.source + ": \"" + getString(message.message));
|
||||
var newUnreadCount = storage.getUnencrypted("unreadCount") + 1;
|
||||
storage.putUnencrypted("unreadCount", newUnreadCount);
|
||||
chrome.browserAction.setBadgeText({text: newUnreadCount + ""});
|
||||
storeMessage(message);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -82,6 +82,12 @@ function getDeviceId(encodedNumber) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
function timestampToHumanReadable(timestamp) {
|
||||
var date = new Date();
|
||||
date.setTime(timestamp*1000);
|
||||
return date.toUTCString();
|
||||
}
|
||||
|
||||
/************************************************
|
||||
*** Utilities to store data in local storage ***
|
||||
************************************************/
|
||||
|
|
15
popup.js
15
popup.js
|
@ -30,16 +30,21 @@ if (storage.getUnencrypted("number_id") === undefined) {
|
|||
for (var i = 0; i < MAX_CONVERSATIONS && i < conversations.length; i++) {
|
||||
var conversation = conversations[i];
|
||||
ul.append('<li>');
|
||||
for (var j = 0; j < MAX_MESSAGES_PER_CONVERSATION && conversation.length; j++) {
|
||||
ul.append(JSON.stringify(conversation[j]));
|
||||
for (var j = 0; j < MAX_MESSAGES_PER_CONVERSATION && j < conversation.length; j++) {
|
||||
var message = conversation[j];
|
||||
ul.append("From: " + message.sender + ", at: " + timestampToHumanReadable(message.timestamp) + "<br>");
|
||||
ul.append("Message: " + message.message + "<br><br>");
|
||||
}
|
||||
ul.append('</li>');
|
||||
}
|
||||
}
|
||||
|
||||
$(window).bind('storage', function() {
|
||||
console.log("Got localStorage update");
|
||||
fillMessages();
|
||||
$(window).bind('storage', function(e) {
|
||||
console.log("Got localStorage update for key " + e.key);
|
||||
if (event.key == "emessageMap")//TODO: Fix when we get actual encryption
|
||||
fillMessages();
|
||||
});
|
||||
fillMessages();
|
||||
storage.putUnencrypted("unreadCount", 0);
|
||||
chrome.browserAction.setBadgeText({text: ""});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue