Move most scripts to the background page

Dramatically improve load times for frontend pages.

Closes #133
This commit is contained in:
lilia 2015-03-15 16:04:39 -07:00
parent 5405b062d2
commit 08ccdf8d97
5 changed files with 215 additions and 292 deletions

View file

@ -21,14 +21,15 @@
extension.windows.getCurrent(function (windowInfo) {
var bg = extension.windows.getBackground();
window.$ = bg.$;
var conversation = bg.getConversationForWindow(windowInfo.id);
if (conversation) {
window.document.title = conversation.getTitle();
new Whisper.ConversationView({
new bg.Whisper.ConversationView({
model: conversation
}).$el.prependTo($('body'));
}).$el.prependTo($('body', document));
} else {
$('<div>').text('Error').prependTo($('body'));
$('<div>').text('Error').prependTo($('body', document));
}
});
}());

View file

@ -16,14 +16,14 @@
*/
(function () {
'use strict';
var bg = extension.windows.getBackground();
window.Whisper = window.Whisper || {};
if (textsecure.storage.getUnencrypted("number_id") === undefined) {
if (bg.textsecure.storage.getUnencrypted("number_id") === undefined) {
window.location = '/options.html';
} else {
new Whisper.InboxView().$el.prependTo($('body'));
textsecure.storage.putUnencrypted("unreadCount", 0);
new bg.Whisper.InboxView().$el.prependTo(bg.$('body',document));
bg.textsecure.storage.putUnencrypted("unreadCount", 0);
extension.navigator.setBadgeText("");
}
}());