 ac25b62fdc
			
		
	
	
	ac25b62fdc
	
	
	
		
			
			* Move install flow i18n logic to install_view.js (from options.js) * Switch to using placeholders (instead of jQuery) for i18n messages with html. * Switch to using moustache template instead of jQuery for i18n substitution. // FREEBIE
		
			
				
	
	
		
			61 lines
		
	
	
	
		
			2.3 KiB
			
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			61 lines
		
	
	
	
		
			2.3 KiB
			
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| /*
 | |
|  * vim: ts=4:sw=4:expandtab
 | |
|  */
 | |
| ;(function() {
 | |
|     'use strict';
 | |
|     extension.windows.getBackground(function(bg) {
 | |
|         bg.storage.onready(function() {
 | |
|             $(function() {
 | |
|                 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';
 | |
|                     }
 | |
|                 }
 | |
|                 var view = new Whisper.InstallView({
 | |
|                     el: $('#install'),
 | |
|                     deviceName: deviceName
 | |
|                 });
 | |
|                 if (bg.textsecure.registration.everDone()) {
 | |
|                     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();
 | |
|             });
 | |
|         });
 | |
|     });
 | |
| })();
 |