@@ -330,7 +330,7 @@ function handleTurnChange (turnData) {
330
330
updateCurrentTurnView ( turnData . current . name ) ;
331
331
updateNextTurnView ( turnData . next . name ) ;
332
332
toggleMyTurnHighlight ( ) ;
333
- updateCurrentGistView ( turnData . gist ) ;
333
+ if ( turnData . gist != null ) updateCurrentGistView ( turnData . gist ) ;
334
334
}
335
335
336
336
// When receiving updateState event from server,
@@ -358,8 +358,8 @@ function handleUpdateState (turnData) {
358
358
updateTimeLeftView ( turnData . millisRemaining ) ;
359
359
updateCurrentTurnView ( turnData . current . name ) ;
360
360
updateNextTurnView ( turnData . next . name ) ;
361
- toggleMyTurnHighlight ( ) ;
362
- updateCurrentGistView ( turnData . gist ) ;
361
+ toggleMyTurnHighlight ( ) ;
362
+ if ( turnData . gist != null ) updateCurrentGistView ( turnData . gist ) ;
363
363
}
364
364
365
365
@@ -368,7 +368,6 @@ function handleNewGistLink (gistData) {
368
368
// Update local state
369
369
console . log ( "called handleNewGist at " + new Date ( ) . toString ( ) . substring ( 16 , 25 ) , 'color: green; font-weight: bold;' ) ;
370
370
console . log ( gistData ) ;
371
-
372
371
// Update views
373
372
updateCurrentGistView ( gistData ) ;
374
373
}
@@ -519,7 +518,7 @@ function updateNextTurnView (playerName) {
519
518
}
520
519
521
520
// Append to a list of gist links for this game
522
- function updateCurrentGistView ( gistData ) {
521
+ function updateCurrentGistView ( gistData ) {
523
522
currentGistView . innerHTML = '<strong>Latest code:</strong> <a href="' + gistData . url + '">' + gistData . url + '</a>' ;
524
523
}
525
524
@@ -544,10 +543,11 @@ function handleCreateNewGist() {
544
543
545
544
postWithGitHubToken ( 'https://api.github.com/gists' , gistObject ) . then ( function ( responseText ) {
546
545
//console.log(responseText);
547
- console . log ( 'handleCreateNewGist: response received at ' + new Date ( ) . toString ( ) . substring ( 16 , 25 ) , 'color: red; font-weight: bold;' ) ;
548
- console . dir ( gistObject ) ;
546
+ console . log ( 'handleCreateNewGist: response received at ' + new Date ( ) . toString ( ) . substring ( 16 , 25 ) , 'color: red; font-weight: bold;' ) ;
549
547
550
548
var gistObject = JSON . parse ( responseText ) ;
549
+
550
+ console . dir ( gistObject ) ;
551
551
552
552
// Save new gist ID and URL locally
553
553
currentGist = { id : gistObject . id , url : gistObject . html_url } ;
@@ -579,7 +579,7 @@ function editGist(gistId, codeEditorContent) {
579
579
postWithGitHubToken ( 'https://api.github.com/gists/' + gistId , gistObject ) . then ( function ( responseText ) {
580
580
//console.log(responseText);
581
581
console . log ( 'editGist: response received at ' + new Date ( ) . toString ( ) . substring ( 16 , 25 ) , 'color: orange; font-weight: bold;' ) ;
582
- console . dir ( gistObject ) ;
582
+ console . dir ( JSON . parse ( responseText ) ) ;
583
583
584
584
} , handleError ) ;
585
585
@@ -599,6 +599,7 @@ function forkAndEditGist(gistId, codeEditorContent) {
599
599
console . log ( 'forkAndEditGist: response received at ' + new Date ( ) . toString ( ) . substring ( 16 , 25 ) , 'color: red; font-weight: bold;' ) ;
600
600
601
601
var gistObject = JSON . parse ( responseText ) ;
602
+ console . dir ( gistObject ) ;
602
603
603
604
// Send new gist data to server
604
605
socket . emit ( 'newGistLink' , { id : gistObject . id , url : gistObject . html_url } ) ;
0 commit comments