Skip to content

Commit 1455379

Browse files
committed
started adding togetherjs hooks
1 parent 89c6a0b commit 1455379

3 files changed

Lines changed: 53 additions & 7 deletions

File tree

‎v3/js/opt-frontend-common.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Online Python Tutor
44
https://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
88
Permission is hereby granted, free of charge, to any person obtaining a
99
copy of this software and associated documentation files (the

‎v3/js/opt-frontend.js‎

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Online Python Tutor
44
https://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
88
Permission is hereby granted, free of charge, to any person obtaining a
99
copy 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+
5765
function 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

‎v3/visualize.html‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,13 @@
7272
<div id="vizSurveyLabel" style="font-size: 8pt; color: #666;">
7373
Support our research by clicking a button when you see something interesting in the visualization.<br/>
7474
</div>
75-
<button class="surveyBtn" type="button">Eureka! Now I understand.</button>
76-
<button class="surveyBtn" type="button">I learned something new!</button>
77-
<button class="surveyBtn" type="button">I found the bug in my code!</button>
78-
<button class="surveyBtn" type="button">This looks confusing.</button>
79-
<button class="surveyBtn" type="button">I have another comment.</button>
75+
<div>
76+
<button class="surveyBtn" type="button">Eureka! Now I understand.</button>
77+
<button class="surveyBtn" type="button">I learned something new!</button>
78+
<button class="surveyBtn" type="button">I found the bug in my code!</button>
79+
<button class="surveyBtn" type="button">This looks confusing.</button>
80+
<button class="surveyBtn" type="button">I have another comment.</button>
81+
</div>
8082
</div>
8183

8284

0 commit comments

Comments
 (0)