Load notifications script from background page

pull/749/head
lilia 10 years ago
parent f90f6328dd
commit ddbaf87741

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

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

Loading…
Cancel
Save