33Online Python Tutor
44https://github.com/pgbovine/OnlinePythonTutor/
55
6- Copyright (C) 2010-2013 Philip J. Guo (philip@pgbovine.net)
6+ Copyright (C) 2010-2014 Philip J. Guo (philip@pgbovine.net)
77
88Permission is hereby granted, free of charge, to any person obtaining a
99copy of this software and associated documentation files (the
@@ -54,6 +54,14 @@ function setCodeMirrorVal(dat) {
5454}
5555
5656
57+ // EXPERIMENTAL
58+ var enableTogetherJS = false ;
59+
60+ var TogetherJSConfig_disableWebRTC = true ;
61+ var TogetherJSConfig_suppressJoinConfirmation = true ;
62+ var updateOutputSignalFromRemote = false ;
63+
64+
5765function getAppState ( ) {
5866 return { code : pyInputCodeMirror . getValue ( ) ,
5967 mode : appMode ,
@@ -68,6 +76,42 @@ function getAppState() {
6876$ ( document ) . ready ( function ( ) {
6977 setSurveyHTML ( ) ;
7078
79+ if ( enableTogetherJS ) {
80+ // dynamically load this JS file on demand
81+ //$.getScript("https://togetherjs.com/togetherjs-min.js", function() {
82+
83+ $ ( "#surveyHeader" ) . append ( '<div style="margin-top: 12px;">\
84+ <button id="togetherBtn" \
85+ style="font-size: 12pt; padding: 6px;" \
86+ type="button">Start TogetherJS</button>\
87+ </div>' ) ;
88+
89+ $ ( "#togetherBtn" ) . click ( function ( ) {
90+ TogetherJS ( ) ; // toggles on and off
91+ } ) ;
92+
93+ // fired when TogetherJS is activated. might fire on page load if there's
94+ // already an open session from a prior page load in the recent past.
95+ TogetherJS . on ( "ready" , function ( ) {
96+ console . log ( "TogetherJS ready" ) ;
97+ $ ( "#togetherBtn" ) . html ( "End TogetherJS" ) ;
98+ } ) ;
99+
100+ // emitted when TogetherJS is closed. This is not emitted when the
101+ // page simply closes or navigates elsewhere. It is only closed when
102+ // TogetherJS is specifically stopped.
103+ TogetherJS . on ( "close" , function ( ) {
104+ console . log ( "TogetherJS close" ) ;
105+ $ ( "#togetherBtn" ) . html ( "Start TogetherJS" ) ;
106+ } ) ;
107+
108+
109+ // this is the URL that we want, except it doesn't exist until
110+ // TogetherJS has been initialized: TogetherJS.shareUrl()
111+
112+ //});
113+ }
114+
71115 $ ( "#embedLinkDiv" ) . hide ( ) ;
72116 $ ( "#surveyHeader" ) . hide ( ) ;
73117
0 commit comments