moved some chromium-specific code into chromium.js (using extension.navigator namespace)
This commit is contained in:
parent
cf35b7056f
commit
69ba6581b0
3 changed files with 22 additions and 4 deletions
|
@ -17,7 +17,7 @@
|
||||||
textsecure.registerOnLoadFunction(function() {
|
textsecure.registerOnLoadFunction(function() {
|
||||||
if (!localStorage.getItem('first_install_ran')) {
|
if (!localStorage.getItem('first_install_ran')) {
|
||||||
localStorage.setItem('first_install_ran', 1);
|
localStorage.setItem('first_install_ran', 1);
|
||||||
chrome.tabs.create({url: "options.html"});
|
extension.navigator.tabs.create("options.html");
|
||||||
} else {
|
} else {
|
||||||
if (isRegistrationDone()) {
|
if (isRegistrationDone()) {
|
||||||
textsecure.subscribeToPush(function(message) {
|
textsecure.subscribeToPush(function(message) {
|
||||||
|
@ -26,7 +26,7 @@ textsecure.registerOnLoadFunction(function() {
|
||||||
': "' + getString(message.message.body) + '"');
|
': "' + getString(message.message.body) + '"');
|
||||||
var newUnreadCount = textsecure.storage.getUnencrypted("unreadCount", 0) + 1;
|
var newUnreadCount = textsecure.storage.getUnencrypted("unreadCount", 0) + 1;
|
||||||
textsecure.storage.putUnencrypted("unreadCount", newUnreadCount);
|
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/>.
|
* 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
|
// Random shared utilities that are used only by chromium things
|
||||||
|
|
||||||
function registrationDone() {
|
function registrationDone() {
|
||||||
|
|
|
@ -17,11 +17,11 @@
|
||||||
|
|
||||||
textsecure.registerOnLoadFunction(function() {
|
textsecure.registerOnLoadFunction(function() {
|
||||||
if (textsecure.storage.getUnencrypted("number_id") === undefined) {
|
if (textsecure.storage.getUnencrypted("number_id") === undefined) {
|
||||||
chrome.tabs.create({url: "options.html"});
|
extension.navigator.tabs.create("options.html");
|
||||||
} else {
|
} else {
|
||||||
$('.my-number').text(textsecure.storage.getUnencrypted("number_id").split(".")[0]);
|
$('.my-number').text(textsecure.storage.getUnencrypted("number_id").split(".")[0]);
|
||||||
textsecure.storage.putUnencrypted("unreadCount", 0);
|
textsecure.storage.putUnencrypted("unreadCount", 0);
|
||||||
chrome.browserAction.setBadgeText({text: ""});
|
extension.navigator.setBadgeText("");
|
||||||
$("#me").click(function() {
|
$("#me").click(function() {
|
||||||
$('#popup_send_numbers').val($('.my-number').text());
|
$('#popup_send_numbers').val($('.my-number').text());
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue