@@ -92,21 +92,21 @@ editor.getSession().setMode('ace/mode/javascript');
92
92
- connection Send: SocketIO built-in event
93
93
- disconnect Send: SocketIO built-in event
94
94
- loggedIn Send: handleUserLogin
95
- - editorChange Send: handleUserTyping
95
+ - editorTextChange Send: handleUserTyping
96
96
Receive: handleEditorChange
97
97
- playerListChange Receive: handlePlayerListChange
98
98
- updateState Receive: handleUpdateState
99
99
- turnChange Receive: handleTurnChange
100
- - changeCursor Send: handleChangeCursor
100
+ - editorCursorChange Send: handleChangeCursor
101
101
Receive: handleNewCursorData
102
- - changeScroll Send: handleChangeScroll
102
+ - editorScrollChange Send: handleeditorScrollChange
103
103
Receive: handleNewScrollData
104
104
- createNewGist Receive: createNewGist
105
105
- newGistLink Receive: handleNewGistLink
106
106
Send: (sent after creating or forking)
107
107
-------------------------------------------------------------- */
108
108
editor . getSession ( ) . on ( 'change' , handleUserTyping ) ;
109
- editor . getSession ( ) . selection . on ( 'changeCursor ' , handleChangeCursor ) ;
109
+ editor . getSession ( ) . selection . on ( 'editorCursorChange ' , handleChangeCursor ) ;
110
110
editor . getSession ( ) . on ( 'changeScrollLeft' , handleChangeScroll ) ;
111
111
editor . getSession ( ) . on ( 'changeScrollTop' , handleChangeScroll ) ;
112
112
@@ -149,7 +149,7 @@ function handleUserTyping (event) {
149
149
if ( socket . id === currentPlayerId ) {
150
150
//console.log('Sending data to server!')
151
151
// Send data to server
152
- socket . emit ( 'editorChange ' , editor . getValue ( ) ) ;
152
+ socket . emit ( 'editorTextChange ' , editor . getValue ( ) ) ;
153
153
}
154
154
}
155
155
@@ -177,7 +177,7 @@ function handleUserNameChange (event) {
177
177
178
178
// Send cursor and selection data to server
179
179
function handleChangeCursor ( event ) {
180
- //console.log('changeCursor fired!');
180
+ //console.log('editorCursorChange fired!');
181
181
//console.log('%c ' + event, 'color: green; font-weight: bold;');
182
182
183
183
// Cursor object:
@@ -187,16 +187,16 @@ function handleChangeCursor (event) {
187
187
// { end: {column, row}, start: {column, row} }
188
188
189
189
// Send to server:
190
- socket . emit ( 'changeCursor ' , { cursor : editor . getSession ( ) . selection . getCursor ( ) , range : editor . getSession ( ) . selection . getRange ( ) } ) ;
190
+ socket . emit ( 'editorCursorChange ' , { cursor : editor . getSession ( ) . selection . getCursor ( ) , range : editor . getSession ( ) . selection . getRange ( ) } ) ;
191
191
}
192
192
193
193
// Send scroll data to server
194
194
function handleChangeScroll ( event ) {
195
- //console.log('changeScroll (left or top) fired!');
195
+ //console.log('editorScrollChange (left or top) fired!');
196
196
//console.log('%c scrollLeft: ' + editor.getSession().getScrollLeft() + ', scrollTop: ' + editor.getSession().getScrollTop(), 'color: green; font-weight: bold;');
197
197
198
198
// Send to server:
199
- socket . emit ( 'changeScroll ' , { scrollLeft : editor . getSession ( ) . getScrollLeft ( ) , scrollTop : editor . getSession ( ) . getScrollTop ( ) } ) ;
199
+ socket . emit ( 'editorScrollChange ' , { scrollLeft : editor . getSession ( ) . getScrollLeft ( ) , scrollTop : editor . getSession ( ) . getScrollTop ( ) } ) ;
200
200
}
201
201
202
202
// TODO: Test 'input' event some more in different browsers!
@@ -205,9 +205,9 @@ function handleChangeScroll (event) {
205
205
/* -------------------------------------------------
206
206
EVENT LISTENERS / RECEIVE DATA FROM SERVER
207
207
---------------------------------------------------- */
208
- socket . on ( 'editorChange ' , handleEditorChange ) ;
209
- socket . on ( 'changeCursor ' , handleNewCursorData ) ;
210
- socket . on ( 'changeScroll ' , handleNewScrollData ) ;
208
+ socket . on ( 'editorTextChange ' , handleEditorChange ) ;
209
+ socket . on ( 'editorCursorChange ' , handleNewCursorData ) ;
210
+ socket . on ( 'editorScrollChange ' , handleNewScrollData ) ;
211
211
socket . on ( 'playerListChange' , handlePlayerListChange ) ;
212
212
socket . on ( 'updateState' , handleUpdateState ) ;
213
213
socket . on ( 'turnChange' , handleTurnChange ) ;
@@ -216,7 +216,7 @@ socket.on('newGistLink', handleNewGistLink);
216
216
217
217
// When receiving new editorInputView data from server
218
218
function handleEditorChange ( data ) {
219
- //console.log('editorChange event received!');
219
+ //console.log('editorTextChange event received!');
220
220
//console.log('%c ' + data, 'color: blue; font-weight: bold;');
221
221
222
222
updateEditorView ( data ) ;
@@ -234,7 +234,7 @@ function handleNewCursorData (data) {
234
234
235
235
// When receiving new scroll data from server
236
236
function handleNewScrollData ( data ) {
237
- //console.log('%c scrollChange event received!', 'color: blue; font-weight: bold;');
237
+ //console.log('%c editorScrollChange event received!', 'color: blue; font-weight: bold;');
238
238
//console.dir(data);
239
239
240
240
// Set Ace editor's scroll position to match
0 commit comments