Merge pull request #45 from codedust/extractchrome
moved some chromium-specific code into chromium.js
This commit is contained in:
commit
fb2aa6144c
3 changed files with 22 additions and 4 deletions
|
@ -17,7 +17,7 @@
|
|||
textsecure.registerOnLoadFunction(function() {
|
||||
if (!localStorage.getItem('first_install_ran')) {
|
||||
localStorage.setItem('first_install_ran', 1);
|
||||
chrome.tabs.create({url: "options.html"});
|
||||
extension.navigator.tabs.create("options.html");
|
||||
} else {
|
||||
if (isRegistrationDone()) {
|
||||
textsecure.subscribeToPush(function(message) {
|
||||
|
@ -26,7 +26,7 @@ textsecure.registerOnLoadFunction(function() {
|
|||
': "' + getString(message.message.body) + '"');
|
||||
var newUnreadCount = textsecure.storage.getUnencrypted("unreadCount", 0) + 1;
|
||||
textsecure.storage.putUnencrypted("unreadCount", newUnreadCount);
|
||||
chrome.browserAction.setBadgeText({text: newUnreadCount + ""});
|
||||
extension.navigator.setBadgeText(newUnreadCount);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,24 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
window.extension = window.extension || {};
|
||||
|
||||
window.extension.navigator = function() {
|
||||
var self = {};
|
||||
|
||||
var tabs = {};
|
||||
tabs.create = function(url){
|
||||
chrome.tabs.create({url: url});
|
||||
};
|
||||
self.tabs = tabs;
|
||||
|
||||
self.setBadgeText = function(text){
|
||||
chrome.browserAction.setBadgeText({text: text + ""});
|
||||
};
|
||||
|
||||
return self;
|
||||
}();
|
||||
|
||||
// Random shared utilities that are used only by chromium things
|
||||
|
||||
function registrationDone() {
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
|
||||
textsecure.registerOnLoadFunction(function() {
|
||||
if (textsecure.storage.getUnencrypted("number_id") === undefined) {
|
||||
chrome.tabs.create({url: "options.html"});
|
||||
extension.navigator.tabs.create("options.html");
|
||||
} else {
|
||||
$('.my-number').text(textsecure.storage.getUnencrypted("number_id").split(".")[0]);
|
||||
textsecure.storage.putUnencrypted("unreadCount", 0);
|
||||
chrome.browserAction.setBadgeText({text: ""});
|
||||
extension.navigator.setBadgeText("");
|
||||
$("#me").click(function() {
|
||||
$('#popup_send_numbers').val($('.my-number').text());
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue