Skip to content

Commit 6946944

Browse files
committed
pull out TogetherJS init into its own function
1 parent 6dea32d commit 6946944

1 file changed

Lines changed: 23 additions & 18 deletions

File tree

‎v3/js/opt-frontend.js‎

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -120,24 +120,7 @@ function setVisibleAppState(appState) {
120120
}
121121

122122

123-
$(document).ready(function() {
124-
setSurveyHTML();
125-
126-
$("#embedLinkDiv").hide();
127-
128-
pyInputCodeMirror = CodeMirror(document.getElementById('codeInputPane'), {
129-
mode: 'python',
130-
lineNumbers: true,
131-
tabSize: 4,
132-
indentUnit: 4,
133-
// convert tab into four spaces:
134-
extraKeys: {Tab: function(cm) {cm.replaceSelection(" ", "end");}}
135-
});
136-
137-
pyInputCodeMirror.setSize(null, '420px');
138-
139-
140-
if (enableTogetherJS) {
123+
function initTogetherJS() {
141124
$("#surveyHeader").remove(); // kill this to save space
142125

143126
var role = $.bbq.getState('role');
@@ -318,6 +301,28 @@ $(document).ready(function() {
318301
$("#togetherBtn").html("Get live help now");
319302
}
320303
});
304+
}
305+
306+
307+
$(document).ready(function() {
308+
setSurveyHTML();
309+
310+
$("#embedLinkDiv").hide();
311+
312+
pyInputCodeMirror = CodeMirror(document.getElementById('codeInputPane'), {
313+
mode: 'python',
314+
lineNumbers: true,
315+
tabSize: 4,
316+
indentUnit: 4,
317+
// convert tab into four spaces:
318+
extraKeys: {Tab: function(cm) {cm.replaceSelection(" ", "end");}}
319+
});
320+
321+
pyInputCodeMirror.setSize(null, '420px');
322+
323+
324+
if (enableTogetherJS) {
325+
initTogetherJS(); // can also call this manually as well
321326
}
322327

323328

0 commit comments

Comments
 (0)