Refactor userKeypress flag in index.html; working as expected now.
This commit is contained in:
		
							parent
							
								
									603a9fd3e8
								
							
						
					
					
						commit
						0f3e173a5b
					
				@ -63,8 +63,8 @@
 | 
			
		||||
    });
 | 
			
		||||
    // Add my .vimrc stuff.
 | 
			
		||||
    CodeMirror.Vim.map('jj', '<Esc>', 'insert')
 | 
			
		||||
    // Hacked semi-colon/colon swap remap into /assets/keymap/vim.js...kind of a heavy hammer might bite me later.
 | 
			
		||||
    // ...and it's already confused me later the same day. I deleted ~/notes.kaplon.us/CodeMirror w/out realizing I'd symlinked it into /assets!
 | 
			
		||||
    // Hacked semi-colon/colon swap remap into /assets/keymap/vim.js...a heavy-handed fix.
 | 
			
		||||
    // Note, ~/notes.kaplon.us/CodeMirror is symlinked it into /assets!
 | 
			
		||||
    // This no worky, there's no concept of <leader> in CodeMirror, but i was hoping this would work-around it.
 | 
			
		||||
    //CodeMirror.Vim.map(' c', '<Esc>o- [ ] ', 'normal')
 | 
			
		||||
    //CodeMirror.Vim.map(' x', '<ESC>;s/\[\s\]/[x]/g<CR>;noh<CR>', 'normal')
 | 
			
		||||
@ -75,8 +75,7 @@
 | 
			
		||||
    var userKeypress = false;
 | 
			
		||||
    var socket = io();
 | 
			
		||||
    socket.on('download allNotes', function(msg){
 | 
			
		||||
        //console.log(msg);
 | 
			
		||||
        userKeypress = false;   // Set this back to false, still getting infinite loop.
 | 
			
		||||
        userKeypress = false;   // Set back to false to avoid infinite content update loop when server sends initial content or changes from another client.
 | 
			
		||||
        var cursorPos = editor.getCursor();
 | 
			
		||||
        var scrollTop = editor.getScrollerElement().scrollTop;
 | 
			
		||||
        editor.getDoc().setValue(msg);
 | 
			
		||||
@ -88,10 +87,10 @@
 | 
			
		||||
    var typingTimer;
 | 
			
		||||
    editor.on("changes", function() {
 | 
			
		||||
        if (!userKeypress) { return; };  // Do nothing if no keys hit yet, avoids infinite loop since 'changes' event fires after initial websocket content loading.
 | 
			
		||||
        userKeypress = false;   // Set this back to false, still getting infinite loop.
 | 
			
		||||
        clearTimeout(typingTimer);
 | 
			
		||||
        typingTimer = setTimeout(
 | 
			
		||||
        function() {
 | 
			
		||||
            userKeypress = false;   // Set back to false to avoid infinite content update loop when server sends initial content or changes from another client.
 | 
			
		||||
            socket.emit('upload allNotes', editor.getValue());
 | 
			
		||||
        },
 | 
			
		||||
        2000
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user