Set title, updated help, cleanup
This commit is contained in:
		
							parent
							
								
									c74d265579
								
							
						
					
					
						commit
						88382a0a2b
					
				
					 5 changed files with 72 additions and 14 deletions
				
			
		| 
						 | 
				
			
			@ -1,8 +1,9 @@
 | 
			
		|||
// Main cryptalk module
 | 
			
		||||
define({
 | 
			
		||||
	compiles: ['$'],
 | 
			
		||||
	requires: ['mediator','hosts', 'templates', 'audio', 'fandango','notifications','sounds']
 | 
			
		||||
	requires: ['mediator','hosts', 'templates', 'audio', 'fandango','notifications','sounds','win']
 | 
			
		||||
}, function ($, requires, data) {
 | 
			
		||||
 | 
			
		||||
	var socket,
 | 
			
		||||
		key,
 | 
			
		||||
		host,
 | 
			
		||||
| 
						 | 
				
			
			@ -31,6 +32,7 @@ define({
 | 
			
		|||
		templates = requires.templates,
 | 
			
		||||
		sounds = requires.sounds,
 | 
			
		||||
		channel = requires.mediator(),
 | 
			
		||||
		win = requires.win,
 | 
			
		||||
 | 
			
		||||
		lockInput = function () {
 | 
			
		||||
			components.input[0].setAttribute('disabled', 'disabled');
 | 
			
		||||
| 
						 | 
				
			
			@ -346,10 +348,17 @@ define({
 | 
			
		|||
 | 
			
		||||
			mute: function () {
 | 
			
		||||
				mute = true;
 | 
			
		||||
				return post('info', templates.messages.muted);
 | 
			
		||||
			},
 | 
			
		||||
 | 
			
		||||
			unmute: function () {
 | 
			
		||||
				mute = false;
 | 
			
		||||
				return post('info', templates.messages.unmuted);
 | 
			
		||||
			},
 | 
			
		||||
 | 
			
		||||
			title: function (payload) {
 | 
			
		||||
				win.setTitle(payload);
 | 
			
		||||
				return post('info', $.template(templates.messages.title_set, { title: payload}));
 | 
			
		||||
			},
 | 
			
		||||
 | 
			
		||||
			join: function (payload) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,7 +15,7 @@ Usage
 | 
			
		|||
	channel.emit('notification:off');
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
define(['mediator','window'],function (mediator,win){
 | 
			
		||||
define(['mediator','win'],function (mediator,win){
 | 
			
		||||
 
 | 
			
		||||
	var enabled = true,
 | 
			
		||||
 
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,17 +23,25 @@ define({
 | 
			
		|||
		'                                                                       \n' +
 | 
			
		||||
		'----------------------------------------------------------------------	\n' +
 | 
			
		||||
		'                                                                       \n' +
 | 
			
		||||
		'Available commands:                                                    \n' +
 | 
			
		||||
		' 	/generate 				Generate random room                        \n' +
 | 
			
		||||
		'	/join		RoomId			Join a room	                            \n' +
 | 
			
		||||
		'	/count					Count participants of room                  \n' +
 | 
			
		||||
		'Client:                                                    			\n' +
 | 
			
		||||
		'	/key		StrongPassphrase	Sets encryption key                 \n' +
 | 
			
		||||
		'	/nick		NickName		Sets an optional nick                   \n' +
 | 
			
		||||
		'	/mute  					Toggle notification sounds					\n' +
 | 
			
		||||
		'	/key		OurStrongPassphrase	Sets encryption key                 \n' +
 | 
			
		||||
		'	/leave					Leave the room                              \n' +
 | 
			
		||||
		'	/mute  					Audio on									\n' +
 | 
			
		||||
		'	/unmute  				Audio off									\n' +
 | 
			
		||||
		'	/clear					Clear on-screen buffer                      \n' +
 | 
			
		||||
		'	/help					This                                        \n' +
 | 
			
		||||
		'	/title					Set your local page title					\n' +
 | 
			
		||||
		'                                                                       \n' +
 | 
			
		||||
		'Room:                                                    				\n' +
 | 
			
		||||
		' 	/generate 				Generate random room                        \n' +
 | 
			
		||||
		'	/join		RoomId			Join a room	                            \n' +
 | 
			
		||||
		'	/leave					Leave the room                              \n' +
 | 
			
		||||
		'	/count					Count participants                          \n' +
 | 
			
		||||
		'                                                                       \n' +
 | 
			
		||||
		'Host:  		                                                    	\n' +
 | 
			
		||||
		'	/hosts					List available hosts                   		\n' +
 | 
			
		||||
		'	/connect	HostIndex		Connect to selected host               	\n' +
 | 
			
		||||
		'	/disconnect				Disconnect from host    			        \n' +
 | 
			
		||||
		'                                                                       \n' +
 | 
			
		||||
		'You can select any of the five last commands/messages with up/down key.\n' +
 | 
			
		||||
		'                                                                       \n' + 
 | 
			
		||||
| 
						 | 
				
			
			@ -78,11 +86,11 @@ define({
 | 
			
		|||
		msg_no_key: 			'You have to set an encryption key before sending a message. See /help.',
 | 
			
		||||
		leave_from_nowhere: 	'How are you supposed to leave, while being nowhere?',
 | 
			
		||||
 | 
			
		||||
		// Sounds
 | 
			
		||||
		title_set: 				'The title of this window is now \'{title}\'.',
 | 
			
		||||
 | 
			
		||||
		muted: 					'Notifications and sounds are now muted.',
 | 
			
		||||
		unmuted: 				'Notifications and sounds are now on.',
 | 
			
		||||
 | 
			
		||||
		// Extra variables: 'commandName'
 | 
			
		||||
		unrecognized_command: 	'Unrecognized command: "{commandName}"',
 | 
			
		||||
 | 
			
		||||
		joined_room: 			'Joined room {room}',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										41
									
								
								public/js/cryptalk_modules/win.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								public/js/cryptalk_modules/win.js
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,41 @@
 | 
			
		|||
/*
 | 
			
		||||
 | 
			
		||||
	Emits:
 | 
			
		||||
		'window:focused'
 | 
			
		||||
		'window:blurred'
 | 
			
		||||
	
 | 
			
		||||
	Exports:
 | 
			
		||||
		title = window.getTitle();
 | 
			
		||||
		window.setTitle(title);
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
define(['mediator'],function (mediator){
 | 
			
		||||
 
 | 
			
		||||
	var exports = {},
 | 
			
		||||
		channel = mediator(),
 | 
			
		||||
 | 
			
		||||
		focusCallback = function() {
 | 
			
		||||
			channel.emit('window:focused');
 | 
			
		||||
		},
 | 
			
		||||
 
 | 
			
		||||
		blurCallback = function() {
 | 
			
		||||
			channel.emit('window:blurred');
 | 
			
		||||
		};
 | 
			
		||||
 | 
			
		||||
	exports.setTitle = function(t) 	{ document.title = t; },
 | 
			
		||||
	exports.getTitle = function() 	{ return document.title; };
 | 
			
		||||
 
 | 
			
		||||
	// Keep track of document focus/blur
 | 
			
		||||
	if (window.addEventListener){
 | 
			
		||||
		// Normal browsers
 | 
			
		||||
		window.addEventListener("focus", focusCallback, true);
 | 
			
		||||
		window.addEventListener("blur", blurCallback, true);
 | 
			
		||||
	} else {
 | 
			
		||||
		// IE
 | 
			
		||||
		window.observe("focusin", focusCallback);
 | 
			
		||||
		window.observe("focusout", blurCallback);
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
	return exports;
 | 
			
		||||
 
 | 
			
		||||
});
 | 
			
		||||
		Loading…
	
	Add table
		
		Reference in a new issue