|  | @@ -1,3 +1,26 @@
 | 
	
		
			
				|  |  | +const emojiPatterns = [
 | 
	
		
			
				|  |  | +    { pattern: ':)', replacement: '🙂' },
 | 
	
		
			
				|  |  | +    { pattern: ':-)', replacement: '🙂' },
 | 
	
		
			
				|  |  | +    { pattern: ':D', replacement: '😀' },
 | 
	
		
			
				|  |  | +    { pattern: ':-D', replacement: '😀' },
 | 
	
		
			
				|  |  | +    { pattern: ';)', replacement: '😉' },
 | 
	
		
			
				|  |  | +    { pattern: ';-)', replacement: '😉' },
 | 
	
		
			
				|  |  | +    { pattern: ':(', replacement: '😞' },
 | 
	
		
			
				|  |  | +    { pattern: ':-(', replacement: '😞' },
 | 
	
		
			
				|  |  | +    { pattern: ':\'(', replacement: '😭' },
 | 
	
		
			
				|  |  | +    { pattern: ':\'-(', replacement: '😭' },
 | 
	
		
			
				|  |  | +    { pattern: ':\\', replacement: '😕' },
 | 
	
		
			
				|  |  | +    { pattern: ':-\\', replacement: '😕' },
 | 
	
		
			
				|  |  | +    { pattern: ':/', replacement: '😕' },
 | 
	
		
			
				|  |  | +    { pattern: ':-/', replacement: '😕' },
 | 
	
		
			
				|  |  | +    { pattern: ':|', replacement: '😐' },
 | 
	
		
			
				|  |  | +    { pattern: ':-|', replacement: '😐' },
 | 
	
		
			
				|  |  | +    { pattern: ':*', replacement: '😘' },
 | 
	
		
			
				|  |  | +    { pattern: ':-*', replacement: '😘' },
 | 
	
		
			
				|  |  | +    { pattern: '<3', replacement: '❤️' },
 | 
	
		
			
				|  |  | +    { pattern: '(y)', replacement: '👍' },
 | 
	
		
			
				|  |  | +];
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  const socket = io();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  $(() => {
 | 
	
	
		
			
				|  | @@ -141,6 +164,24 @@ function onServerLogin(user, history) {
 | 
	
		
			
				|  |  |      });
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      $("#chat-host .messageField").keypress((e) => {
 | 
	
		
			
				|  |  | +        const field = $('#chat-host .messageForm .messageField');
 | 
	
		
			
				|  |  | +        if (field.prop('selectionStart') == field.prop('selectionEnd')) {
 | 
	
		
			
				|  |  | +            const val = field.val();
 | 
	
		
			
				|  |  | +            const cursorPos = field.prop('selectionStart');
 | 
	
		
			
				|  |  | +            const valBefore = val.substring(0, cursorPos);
 | 
	
		
			
				|  |  | +            const valAfter = val.substring(cursorPos);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            for (const emojiPatternItem of emojiPatterns) {
 | 
	
		
			
				|  |  | +                if (valBefore.endsWith(emojiPatternItem.pattern)) {
 | 
	
		
			
				|  |  | +                    field.val(
 | 
	
		
			
				|  |  | +                        valBefore.substring(0, valBefore.length - emojiPatternItem.pattern.length) + emojiPatternItem.replacement + valAfter
 | 
	
		
			
				|  |  | +                    );
 | 
	
		
			
				|  |  | +                    field.prop('selectionStart', cursorPos);
 | 
	
		
			
				|  |  | +                    field.prop('selectionEnd', cursorPos);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          if(e.key == 'Enter' && !e.shiftKey) {
 | 
	
		
			
				|  |  |              e.preventDefault();
 | 
	
		
			
				|  |  |              $('#chat-host .messageForm').submit();
 |