Skip to content

Commit f9f63f1

Browse files
committed
bah fix bug for ace, i think
1 parent 4950fe5 commit f9f63f1

2 files changed

Lines changed: 44 additions & 44 deletions

File tree

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,13 @@ function syncAppState(appState) {
134134
setToggleOptions(appState);
135135

136136
// VERY VERY subtle -- temporarily prevent TogetherJS from sending
137-
// form update events while we set the code mirror value. otherwise
137+
// form update events while we set the input value. otherwise
138138
// this will send an incorrect delta to the other end and screw things
139139
// up because the initial states of the two forms aren't equal.
140-
if (useCodeMirror) {
141-
var orig = TogetherJS.config.get('ignoreForms');
142-
TogetherJS.config('ignoreForms', true);
143-
pyInputSetValue(appState.code);
144-
TogetherJS.config('ignoreForms', orig);
145-
}
140+
var orig = TogetherJS.config.get('ignoreForms');
141+
TogetherJS.config('ignoreForms', true);
142+
pyInputSetValue(appState.code);
143+
TogetherJS.config('ignoreForms', orig);
146144

147145
if (appState.rawInputLst) {
148146
rawInputLst = $.parseJSON(appState.rawInputLstJSON);

‎v3/js/opt-office-mix.js‎

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ function setFronendError(lines) {
129129
}
130130

131131

132-
function officeMixEnterViewMode(firstTime) {
132+
// temp safety for MSR faculty summit
133+
var tempSafe = true;
134+
135+
function officeMixEnterViewMode() {
133136
if (_labEditor) {
134137
_labEditor.done(function() { _labEditor = null; });
135138
}
@@ -138,22 +141,25 @@ function officeMixEnterViewMode(firstTime) {
138141
if (labInstance) {
139142
_labViewer = labInstance; // global
140143

141-
if (firstTime) {
142-
var savedAppState = _labViewer.components[0].component.data;
143-
setToggleOptions(savedAppState);
144-
if (savedAppState.code) {
145-
pyInputSetValue(savedAppState.code);
144+
var savedAppState = _labViewer.components[0].component.data;
145+
setToggleOptions(savedAppState);
146+
if (savedAppState.code) {
147+
pyInputSetValue(savedAppState.code);
148+
149+
if (!tempSafe) {
146150
executeCodeFromScratch();
147151
}
148152
}
153+
154+
if (tempSafe) {
155+
$("#toggleModebtn").html("Visualize code").show();
156+
enterEditMode();
157+
}
149158
}
150159
});
151-
152-
// on second thought, don't hide this
153-
//$("#toggleModebtn").hide();
154160
}
155161

156-
function officeMixEnterEditMode(firstTime) {
162+
function officeMixEnterEditMode() {
157163
if (_labViewer) {
158164
_labViewer.done(function() { _labViewer = null; });
159165
}
@@ -162,32 +168,30 @@ function officeMixEnterEditMode(firstTime) {
162168
if (labEditor) {
163169
_labEditor = labEditor; // global
164170

165-
if (firstTime) {
166-
_labEditor.getConfiguration(function(err, configuration) {
167-
if (configuration) {
168-
var savedAppState = configuration.components[0].data;
169-
setToggleOptions(savedAppState);
170-
if (savedAppState.code) {
171-
pyInputSetValue(savedAppState.code);
172-
}
171+
_labEditor.getConfiguration(function(err, configuration) {
172+
if (configuration) {
173+
var savedAppState = configuration.components[0].data;
174+
setToggleOptions(savedAppState);
175+
if (savedAppState.code) {
176+
pyInputSetValue(savedAppState.code);
173177
}
174-
});
175-
176-
// set configuration on every code edit and option toggle, to
177-
// set the 'dirty bit' on the enclosing PPT file
178-
if (useCodeMirror) {
179-
pyInputCodeMirror.on("change", saveCurrentConfiguration);
180-
}
181-
else {
182-
pyInputAceEditor.getSession().on("change", saveCurrentConfiguration);
183178
}
184-
$('select').change(saveCurrentConfiguration);
179+
});
180+
181+
// set configuration on every code edit and option toggle, to
182+
// set the 'dirty bit' on the enclosing PPT file
183+
if (useCodeMirror) {
184+
pyInputCodeMirror.on("change", saveCurrentConfiguration);
185+
}
186+
else {
187+
pyInputAceEditor.getSession().on("change", saveCurrentConfiguration);
185188
}
189+
$('select').change(saveCurrentConfiguration);
190+
191+
$("#toggleModebtn").html("Visualize code").show();
192+
enterEditMode();
186193
}
187194
});
188-
189-
$("#toggleModebtn").html("Visualize code").show();
190-
enterEditMode();
191195
}
192196

193197
function saveCurrentConfiguration() {
@@ -278,17 +282,17 @@ $(document).ready(function() {
278282
var initialMode = Labs.Core.LabMode[connectionResponse.mode];
279283

280284
if (initialMode == 'Edit') {
281-
officeMixEnterEditMode(true);
285+
officeMixEnterEditMode();
282286
} else if (initialMode == 'View') {
283-
officeMixEnterViewMode(true);
287+
officeMixEnterViewMode();
284288
}
285289

286290
// initialize these callbacks only after Labs.connect is successful
287291
Labs.on(Labs.Core.EventTypes.ModeChanged, function(data) {
288292
if (data.mode == 'Edit') {
289-
officeMixEnterEditMode(false);
293+
officeMixEnterEditMode();
290294
} else if (data.mode == 'View') {
291-
officeMixEnterViewMode(false);
295+
officeMixEnterViewMode();
292296
}
293297
});
294298

@@ -298,6 +302,4 @@ $(document).ready(function() {
298302
Labs.on(Labs.Core.EventTypes.Deactivate, function() {
299303
});
300304
});
301-
302-
pyInputSetValue('x = "world"\nprint("hello " + x)'); // set default
303305
});

0 commit comments

Comments
 (0)