Load notifications script from background page

This commit is contained in:
lilia 2015-05-12 17:07:13 -07:00
parent f90f6328dd
commit ddbaf87741
2 changed files with 51 additions and 52 deletions

View file

@ -15,61 +15,61 @@
*/
;(function() {
'use strict';
$('.notifications .on button').click(function() {
Whisper.Notifications.disable();
initOptions();
});
$('.notifications .off button').click(function() {
Whisper.Notifications.enable(initOptions);
initOptions();
});
function initOptions() {
if (Whisper.Notifications.isEnabled()) {
$('.notifications .on').show();
$('.notifications .off').hide();
} else {
$('.notifications .on').hide();
$('.notifications .off').show();
}
}
function setProvisioningUrl(url) {
$('#status').text('');
new QRCode($('#qr')[0]).makeCode(url);
}
function confirmNumber(number) {
return new Promise(function(resolve, reject) {
$('#qr').hide();
$('.confirmation-dialog .number').text(number);
$('.confirmation-dialog .cancel').click(function(e) {
localStorage.clear();
reject();
});
$('.confirmation-dialog .ok').click(function(e) {
e.stopPropagation();
$('.confirmation-dialog').hide();
$('.progress-dialog').show();
$('.progress-dialog .status').text('Generating Keys');
resolve();
});
$('.modal-container').show();
extension.windows.getBackground(function(bg) {
$('.notifications .on button').click(function() {
bg.Whisper.Notifications.disable();
initOptions();
});
}
var counter = 0;
function incrementCounter() {
$('.progress-dialog .bar').css('width', (++counter * 100 / 100) + '%');
}
$('.notifications .off button').click(function() {
bg.Whisper.Notifications.enable(initOptions);
initOptions();
});
$('.modal-container .cancel').click(function() {
$('.modal-container').hide();
});
function initOptions() {
if (bg.Whisper.Notifications.isEnabled()) {
$('.notifications .on').show();
$('.notifications .off').hide();
} else {
$('.notifications .on').hide();
$('.notifications .off').show();
}
}
$(function() {
extension.windows.getBackground(function(bg) {
function setProvisioningUrl(url) {
$('#status').text('');
new QRCode($('#qr')[0]).makeCode(url);
}
function confirmNumber(number) {
return new Promise(function(resolve, reject) {
$('#qr').hide();
$('.confirmation-dialog .number').text(number);
$('.confirmation-dialog .cancel').click(function(e) {
localStorage.clear();
reject();
});
$('.confirmation-dialog .ok').click(function(e) {
e.stopPropagation();
$('.confirmation-dialog').hide();
$('.progress-dialog').show();
$('.progress-dialog .status').text('Generating Keys');
resolve();
});
$('.modal-container').show();
});
}
var counter = 0;
function incrementCounter() {
$('.progress-dialog .bar').css('width', (++counter * 100 / 100) + '%');
}
$('.modal-container .cancel').click(function() {
$('.modal-container').hide();
});
$(function() {
if (bg.textsecure.registration.isDone()) {
$('#complete-number').text(bg.textsecure.storage.user.getNumber());
$('#setup-complete').show().addClass('in');

View file

@ -117,7 +117,6 @@
<script type="text/javascript" src="js/components.js"></script>
<script type="text/javascript" src="js/database.js"></script>
<script type="text/javascript" src="js/notifications.js"></script>
<script type="text/javascript" src="js/libphonenumber-util.js"></script>
<script type="text/javascript" src="js/models/messages.js"></script>
<script type="text/javascript" src="js/models/conversations.js"></script>