14cb6b58a2
* Refactor options.js into a view * Break up install flow into a series of screens * Remove bootstrap * Make installer window static size, mostly to facilitate positioning // FREEBIE
52 lines
1.9 KiB
JavaScript
52 lines
1.9 KiB
JavaScript
/*
|
|
* vim: ts=4:sw=4:expandtab
|
|
*/
|
|
;(function() {
|
|
'use strict';
|
|
extension.windows.getBackground(function(bg) {
|
|
bg.storage.onready(function() {
|
|
$(function() {
|
|
var view = new Whisper.InstallView({
|
|
el: $('#install'),
|
|
deviceName: bg.textsecure.storage.user.getDeviceName()
|
|
});
|
|
if (bg.textsecure.registration.isDone()) {
|
|
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);
|
|
clearTimeout(timeout);
|
|
window.close();
|
|
};
|
|
var timeout = setTimeout(launch, 60000);
|
|
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();
|
|
});
|
|
});
|
|
});
|
|
})();
|