@@ -330,7 +330,7 @@ function handleTurnChange (turnData) {
330330 updateCurrentTurnView ( turnData . current . name ) ;
331331 updateNextTurnView ( turnData . next . name ) ;
332332 toggleMyTurnHighlight ( ) ;
333- updateCurrentGistView ( turnData . gist ) ;
333+ if ( turnData . gist != null ) updateCurrentGistView ( turnData . gist ) ;
334334}
335335
336336// When receiving updateState event from server,
@@ -358,8 +358,8 @@ function handleUpdateState (turnData) {
358358 updateTimeLeftView ( turnData . millisRemaining ) ;
359359 updateCurrentTurnView ( turnData . current . name ) ;
360360 updateNextTurnView ( turnData . next . name ) ;
361- toggleMyTurnHighlight ( ) ;
362- updateCurrentGistView ( turnData . gist ) ;
361+ toggleMyTurnHighlight ( ) ;
362+ if ( turnData . gist != null ) updateCurrentGistView ( turnData . gist ) ;
363363}
364364
365365
@@ -368,7 +368,6 @@ function handleNewGistLink (gistData) {
368368 // Update local state
369369 console . log ( "called handleNewGist at " + new Date ( ) . toString ( ) . substring ( 16 , 25 ) , 'color: green; font-weight: bold;' ) ;
370370 console . log ( gistData ) ;
371-
372371 // Update views
373372 updateCurrentGistView ( gistData ) ;
374373}
@@ -519,7 +518,7 @@ function updateNextTurnView (playerName) {
519518}
520519
521520// Append to a list of gist links for this game
522- function updateCurrentGistView ( gistData ) {
521+ function updateCurrentGistView ( gistData ) {
523522 currentGistView . innerHTML = '<strong>Latest code:</strong> <a href="' + gistData . url + '">' + gistData . url + '</a>' ;
524523}
525524
@@ -544,10 +543,11 @@ function handleCreateNewGist() {
544543
545544 postWithGitHubToken ( 'https://api.github.com/gists' , gistObject ) . then ( function ( responseText ) {
546545 //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;' ) ;
549547
550548 var gistObject = JSON . parse ( responseText ) ;
549+
550+ console . dir ( gistObject ) ;
551551
552552 // Save new gist ID and URL locally
553553 currentGist = { id : gistObject . id , url : gistObject . html_url } ;
@@ -579,7 +579,7 @@ function editGist(gistId, codeEditorContent) {
579579 postWithGitHubToken ( 'https://api.github.com/gists/' + gistId , gistObject ) . then ( function ( responseText ) {
580580 //console.log(responseText);
581581 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 ) ) ;
583583
584584 } , handleError ) ;
585585
@@ -599,6 +599,7 @@ function forkAndEditGist(gistId, codeEditorContent) {
599599 console . log ( 'forkAndEditGist: response received at ' + new Date ( ) . toString ( ) . substring ( 16 , 25 ) , 'color: red; font-weight: bold;' ) ;
600600
601601 var gistObject = JSON . parse ( responseText ) ;
602+ console . dir ( gistObject ) ;
602603
603604 // Send new gist data to server
604605 socket . emit ( 'newGistLink' , { id : gistObject . id , url : gistObject . html_url } ) ;
0 commit comments