2015-11-03 03:19:30 +00:00
|
|
|
/*
|
|
|
|
* vim: ts=4:sw=4:expandtab
|
|
|
|
*/
|
|
|
|
(function () {
|
|
|
|
'use strict';
|
|
|
|
window.Whisper = window.Whisper || {};
|
|
|
|
|
|
|
|
Whisper.InstallView = Whisper.View.extend({
|
2016-01-17 10:54:34 +00:00
|
|
|
templateName: 'install_flow_template',
|
|
|
|
render_attributes: function() {
|
2016-08-31 20:38:11 +00:00
|
|
|
var playStoreHref = 'https://play.google.com/store/apps/details?id=org.thoughtcrime.securesms';
|
|
|
|
var appStoreHref = 'https://itunes.apple.com/us/app/signal-private-messenger/id874139669';
|
2016-01-17 10:54:34 +00:00
|
|
|
var twitterHref = 'https://twitter.com/whispersystems';
|
|
|
|
return {
|
|
|
|
installWelcome: i18n('installWelcome'),
|
|
|
|
installTagline: i18n('installTagline'),
|
|
|
|
installGetStartedButton: i18n('installGetStartedButton'),
|
2016-09-27 20:33:03 +00:00
|
|
|
installSignalLink: this.i18n_with_links('installSignalLinks', playStoreHref, appStoreHref),
|
2016-08-31 20:38:11 +00:00
|
|
|
installIHaveSignalButton: i18n('installGotIt'),
|
2016-09-27 20:33:03 +00:00
|
|
|
installFollowUs: this.i18n_with_links('installFollowUs', twitterHref),
|
2016-01-17 10:54:34 +00:00
|
|
|
installAndroidInstructions: i18n('installAndroidInstructions'),
|
|
|
|
installLinkingWithNumber: i18n('installLinkingWithNumber'),
|
|
|
|
installComputerName: i18n('installComputerName'),
|
|
|
|
installFinalButton: i18n('installFinalButton'),
|
|
|
|
installTooManyDevices: i18n('installTooManyDevices'),
|
|
|
|
ok: i18n('ok'),
|
|
|
|
};
|
|
|
|
},
|
2015-11-03 03:19:30 +00:00
|
|
|
initialize: function(options) {
|
|
|
|
this.counter = 0;
|
2016-01-17 10:54:34 +00:00
|
|
|
|
|
|
|
this.render();
|
|
|
|
|
2015-11-03 03:19:30 +00:00
|
|
|
this.$('#device-name').val(options.deviceName);
|
|
|
|
this.$('#step1').show();
|
|
|
|
},
|
|
|
|
events: function() {
|
|
|
|
return {
|
|
|
|
'click .step1': this.selectStep.bind(this, 1),
|
|
|
|
'click .step2': this.selectStep.bind(this, 2),
|
|
|
|
'click .step3': this.selectStep.bind(this, 3)
|
|
|
|
};
|
|
|
|
},
|
|
|
|
clearQR: function() {
|
2016-01-16 12:59:01 +00:00
|
|
|
this.$('#qr').text(i18n("installConnecting"));
|
2015-11-03 03:19:30 +00:00
|
|
|
},
|
|
|
|
setProvisioningUrl: function(url) {
|
2016-02-10 00:21:42 +00:00
|
|
|
this.$('#qr').html('');
|
|
|
|
new QRCode(this.$('#qr')[0]).makeCode(url);
|
2015-11-03 03:19:30 +00:00
|
|
|
},
|
|
|
|
confirmNumber: function(number) {
|
2015-11-08 04:34:34 +00:00
|
|
|
var parsed = libphonenumber.parse(number);
|
|
|
|
if (!libphonenumber.isValidNumber(parsed)) {
|
2016-01-21 21:59:04 +00:00
|
|
|
throw new Error('Invalid number ' + number);
|
2015-11-08 04:34:34 +00:00
|
|
|
}
|
2015-11-03 03:19:30 +00:00
|
|
|
this.$('#step4 .number').text(libphonenumber.format(
|
2015-11-08 04:34:34 +00:00
|
|
|
parsed,
|
2015-11-03 03:19:30 +00:00
|
|
|
libphonenumber.PhoneNumberFormat.INTERNATIONAL
|
|
|
|
));
|
|
|
|
this.selectStep(4);
|
|
|
|
this.$('#device-name').focus();
|
|
|
|
return new Promise(function(resolve, reject) {
|
|
|
|
this.$('#step4 .cancel').click(function(e) {
|
|
|
|
reject();
|
|
|
|
});
|
|
|
|
this.$('#sync').click(function(e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
var name = this.$('#device-name').val();
|
2016-09-01 20:15:04 +00:00
|
|
|
name = name.replace(/\0/g,''); // strip unicode null
|
2015-11-03 03:19:30 +00:00
|
|
|
if (name.trim().length === 0) {
|
|
|
|
this.$('#device-name').focus();
|
|
|
|
return;
|
|
|
|
}
|
2016-01-16 12:59:01 +00:00
|
|
|
this.$('.progress-dialog .status').text(i18n('installGeneratingKeys'));
|
2015-11-03 03:19:30 +00:00
|
|
|
this.selectStep(5);
|
|
|
|
resolve(name);
|
|
|
|
}.bind(this));
|
|
|
|
}.bind(this));
|
|
|
|
},
|
|
|
|
incrementCounter: function() {
|
|
|
|
this.$('.progress-dialog .bar').css('width', (++this.counter * 100 / 100) + '%');
|
|
|
|
},
|
|
|
|
selectStep: function(step) {
|
|
|
|
this.$('.step').hide();
|
|
|
|
this.$('#step' + step).show();
|
|
|
|
},
|
|
|
|
showSync: function() {
|
2016-01-16 12:59:01 +00:00
|
|
|
this.$('.progress-dialog .status').text(i18n('installSyncingGroupsAndContacts'));
|
2015-11-03 03:19:30 +00:00
|
|
|
this.$('.progress-dialog .bar').addClass('progress-bar-striped active');
|
|
|
|
},
|
|
|
|
showTooManyDevices: function() {
|
|
|
|
this.selectStep('TooManyDevices');
|
2016-02-10 00:21:42 +00:00
|
|
|
},
|
|
|
|
showConnectionError: function() {
|
|
|
|
this.$('#qr').text(i18n("installConnectionFailed"));
|
2015-11-03 03:19:30 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
})();
|