2015-09-07 23:53:43 +02:00
|
|
|
/*
|
|
|
|
* vim: ts=4:sw=4:expandtab
|
2014-05-04 08:34:13 +02:00
|
|
|
*/
|
2014-10-11 01:58:34 +02:00
|
|
|
;(function() {
|
2015-03-06 20:43:53 +01:00
|
|
|
'use strict';
|
2015-05-13 02:07:13 +02:00
|
|
|
extension.windows.getBackground(function(bg) {
|
2015-11-03 04:19:30 +01:00
|
|
|
bg.storage.onready(function() {
|
|
|
|
$(function() {
|
2015-11-08 04:43:46 +01:00
|
|
|
var deviceName = bg.textsecure.storage.user.getDeviceName();
|
|
|
|
if (!deviceName) {
|
|
|
|
deviceName = 'Chrome';
|
|
|
|
if (navigator.userAgent.match('Mac OS')) {
|
|
|
|
deviceName += ' on Mac';
|
|
|
|
} else if (navigator.userAgent.match('Linux')) {
|
|
|
|
deviceName += ' on Linux';
|
|
|
|
} else if (navigator.userAgent.match('Windows')) {
|
|
|
|
deviceName += ' on Windows';
|
|
|
|
}
|
|
|
|
}
|
2015-11-03 04:19:30 +01:00
|
|
|
var view = new Whisper.InstallView({
|
|
|
|
el: $('#install'),
|
2015-11-08 04:43:46 +01:00
|
|
|
deviceName: deviceName
|
2015-05-13 02:07:13 +02:00
|
|
|
});
|
2016-01-12 01:08:54 +01:00
|
|
|
if (bg.textsecure.registration.everDone()) {
|
2015-11-03 04:19:30 +01:00
|
|
|
view.selectStep(3);
|
|
|
|
}
|
|
|
|
view.$el.show();
|
|
|
|
var accountManager = new bg.getAccountManager();
|
|
|
|
|
|
|
|
var init = function() {
|
|
|
|
view.clearQR();
|
|
|
|
|
|
|
|
accountManager.registerSecondDevice(
|
|
|
|
view.setProvisioningUrl.bind(view),
|
|
|
|
view.confirmNumber.bind(view),
|
|
|
|
view.incrementCounter.bind(view)
|
|
|
|
).then(function() {
|
|
|
|
var launch = function() {
|
|
|
|
bg.openInbox();
|
|
|
|
bg.removeEventListener('textsecure:contactsync', launch);
|
|
|
|
window.close();
|
|
|
|
};
|
|
|
|
bg.addEventListener('textsecure:contactsync', launch);
|
|
|
|
view.showSync();
|
|
|
|
}).catch(function(e) {
|
|
|
|
if (e.message === 'websocket closed') {
|
|
|
|
init();
|
|
|
|
} else if (e.name === 'HTTPError' && e.code == 411) {
|
|
|
|
view.showTooManyDevices();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
$('.error-dialog .ok').click(init);
|
|
|
|
init();
|
2015-04-01 22:08:09 +02:00
|
|
|
});
|
2015-05-11 23:22:15 +02:00
|
|
|
});
|
2014-10-11 01:58:34 +02:00
|
|
|
});
|
|
|
|
})();
|