Skip to content

Commit 90bb308

Browse files
committed
some frontend refactoring action
(my first rebase squash!) more frontend code refactoring tiny cleanups teeny
1 parent 98eb2a6 commit 90bb308

5 files changed

Lines changed: 20 additions & 66 deletions

File tree

‎v3/js/composingprograms.js‎

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,6 @@ var preseededCurInstr = null; // if you passed in a 'curInstr=<number>' in the U
4444
var myVisualizer = null; // singleton ExecutionVisualizer instance
4545

4646

47-
function enterEditMode() {
48-
$.bbq.pushState({ mode: 'edit' }, 2 /* completely override other hash strings to keep URL clean */);
49-
}
50-
51-
function enterDisplayNoFrillsMode() {
52-
$.bbq.pushState({ mode: 'display_no_frills' }, 2 /* completely override other hash strings to keep URL clean */);
53-
}
54-
5547
var pyInputCodeMirror; // CodeMirror object that contains the input text
5648

5749
function setCodeMirrorVal(dat) {
@@ -170,13 +162,6 @@ $(document).ready(function() {
170162
compactFuncLabels: true,
171163
}
172164

173-
function handleSuccessFunc() {
174-
// also scroll to top to make the UI more usable on smaller monitors
175-
$(document).scrollTop(0);
176-
177-
$.bbq.pushState({ mode: 'display' }, 2 /* completely override other hash strings to keep URL clean */);
178-
}
179-
180165
function handleUncaughtExceptionFunc(trace) {
181166
if (trace.length == 1) {
182167
var errorLineNo = trace[0].line - 1; /* CodeMirror lines are zero-indexed */
@@ -201,7 +186,7 @@ $(document).ready(function() {
201186
backend_script, backendOptionsObj,
202187
frontendOptionsObj,
203188
'pyOutputPane',
204-
handleSuccessFunc, handleUncaughtExceptionFunc);
189+
enterDisplayMode, handleUncaughtExceptionFunc);
205190
}
206191

207192
function executeCodeFromScratch() {
@@ -285,4 +270,3 @@ $(document).ready(function() {
285270
$('#urlOutput').val(urlStr);
286271
});
287272
});
288-

‎v3/js/csc108h.js‎

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,6 @@ var preseededCurInstr = null; // if you passed in a 'curInstr=<number>' in the U
4545
var myVisualizer = null; // singleton ExecutionVisualizer instance
4646

4747

48-
function enterEditMode() {
49-
$.bbq.pushState({ mode: 'edit' }, 2 /* completely override other hash strings to keep URL clean */);
50-
}
51-
52-
function enterDisplayNoFrillsMode() {
53-
$.bbq.pushState({ mode: 'display_no_frills' }, 2 /* completely override other hash strings to keep URL clean */);
54-
}
55-
5648
var pyInputCodeMirror; // CodeMirror object that contains the input text
5749

5850
function setCodeMirrorVal(dat) {
@@ -173,13 +165,6 @@ $(document).ready(function() {
173165
updateOutputCallback: function() {$('#urlOutput,#embedCodeOutput').val('');},
174166
}
175167

176-
function handleSuccessFunc() {
177-
// also scroll to top to make the UI more usable on smaller monitors
178-
$(document).scrollTop(0);
179-
180-
$.bbq.pushState({ mode: 'display' }, 2 /* completely override other hash strings to keep URL clean */);
181-
}
182-
183168
function handleUncaughtExceptionFunc(trace) {
184169
if (trace.length == 1) {
185170
var errorLineNo = trace[0].line - 1; /* CodeMirror lines are zero-indexed */
@@ -204,7 +189,7 @@ $(document).ready(function() {
204189
backend_script, backendOptionsObj,
205190
frontendOptionsObj,
206191
'pyOutputPane',
207-
handleSuccessFunc, handleUncaughtExceptionFunc);
192+
enterDisplayMode, handleUncaughtExceptionFunc);
208193
}
209194

210195
function executeCodeFromScratch() {
@@ -286,4 +271,3 @@ $(document).ready(function() {
286271
$('#urlOutput').val(urlStr);
287272
});
288273
});
289-

‎v3/js/matrixtutor.js‎

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ var myVisualizer = null; // singleton ExecutionVisualizer instance
4747
var VIZ_LABEL = "Run and Visualize Code";
4848

4949

50-
function enterEditMode() {
51-
$.bbq.pushState({ mode: 'edit' }, 2 /* completely override other hash strings to keep URL clean */);
52-
}
53-
54-
function enterDisplayNoFrillsMode() {
55-
$.bbq.pushState({ mode: 'display_no_frills' }, 2 /* completely override other hash strings to keep URL clean */);
56-
}
57-
5850
var pyInputCodeMirror; // CodeMirror object that contains the solution code
5951
var pyTestInputCodeMirror; // CodeMirror object that contains the test code
6052

@@ -166,13 +158,6 @@ $(document).ready(function() {
166158
jumpToEnd: true,
167159
}
168160

169-
function handleSuccessFunc() {
170-
// also scroll to top to make the UI more usable on smaller monitors
171-
$(document).scrollTop(0);
172-
173-
$.bbq.pushState({ mode: 'display' }, 2 /* completely override other hash strings to keep URL clean */);
174-
}
175-
176161
function handleUncaughtExceptionFunc(trace) {
177162
if (trace.length == 1) {
178163
var errorLineNo = trace[0].line - 1; /* CodeMirror lines are zero-indexed */
@@ -213,7 +198,7 @@ $(document).ready(function() {
213198
backend_script, backendOptionsObj,
214199
frontendOptionsObj,
215200
'pyOutputPane',
216-
handleSuccessFunc, handleUncaughtExceptionFunc);
201+
enterDisplayMode, handleUncaughtExceptionFunc);
217202
}
218203

219204
function executeCodeFromScratch() {

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,21 @@ function setToggleOptions(dat) {
9797
}
9898

9999

100+
function enterDisplayMode() {
101+
$(document).scrollTop(0); // scroll to top to make UX better on small monitors
102+
$.bbq.pushState({ mode: 'display' }, 2 /* completely override other hash strings to keep URL clean */);
103+
}
104+
105+
function enterEditMode() {
106+
$(document).scrollTop(0); // scroll to top to make UX better on small monitors
107+
$.bbq.pushState({ mode: 'edit' }, 2 /* completely override other hash strings to keep URL clean */);
108+
}
109+
110+
function enterDisplayNoFrillsMode() {
111+
$.bbq.pushState({ mode: 'display_no_frills' }, 2 /* completely override other hash strings to keep URL clean */);
112+
}
113+
114+
100115
function executePythonCode(pythonSourceCode,
101116
backendScript, backendOptionsObj,
102117
frontendOptionsObj,

‎v3/js/opt-frontend.js‎

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,6 @@ var preseededCurInstr = null; // if you passed in a 'curInstr=<number>' in the U
4343
var myVisualizer = null; // singleton ExecutionVisualizer instance
4444

4545

46-
function enterEditMode() {
47-
$.bbq.pushState({ mode: 'edit' }, 2 /* completely override other hash strings to keep URL clean */);
48-
}
49-
50-
function enterDisplayNoFrillsMode() {
51-
$.bbq.pushState({ mode: 'display_no_frills' }, 2 /* completely override other hash strings to keep URL clean */);
52-
}
53-
5446
var pyInputCodeMirror; // CodeMirror object that contains the input text
5547

5648
function setCodeMirrorVal(dat) {
@@ -96,6 +88,7 @@ $(document).ready(function() {
9688
// thanks to http://benalman.com/projects/jquery-bbq-plugin/
9789
$(window).bind("hashchange", function(e) {
9890
appMode = $.bbq.getState('mode'); // assign this to the GLOBAL appMode
91+
//console.log("hashchange", appMode);
9992

10093
if (appMode === undefined || appMode == 'edit') {
10194
$("#pyInputPane").show();
@@ -201,13 +194,6 @@ $(document).ready(function() {
201194
//, hideCode: true,
202195
}
203196

204-
function handleSuccessFunc() {
205-
// also scroll to top to make the UI more usable on smaller monitors
206-
$(document).scrollTop(0);
207-
208-
$.bbq.pushState({ mode: 'display' }, 2 /* completely override other hash strings to keep URL clean */);
209-
}
210-
211197
function handleUncaughtExceptionFunc(trace) {
212198
if (trace.length == 1 && trace[0].line) {
213199
var errorLineNo = trace[0].line - 1; /* CodeMirror lines are zero-indexed */
@@ -232,7 +218,7 @@ $(document).ready(function() {
232218
backend_script, backendOptionsObj,
233219
frontendOptionsObj,
234220
'pyOutputPane',
235-
handleSuccessFunc, handleUncaughtExceptionFunc);
221+
enterDisplayMode, handleUncaughtExceptionFunc);
236222
}
237223

238224
function executeCodeFromScratch() {

0 commit comments

Comments
 (0)