Skip to content

Commit 1a3177b

Browse files
committed
bam
1 parent d98220c commit 1a3177b

7 files changed

Lines changed: 43 additions & 19 deletions

File tree

‎v5-unity/README.txt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,8 @@ https://github.com/petehunt/webpack-howto
6969
'webpack --watch' for continuous incremental build in development (fast!)
7070
'webpack -d' to include source maps
7171

72+
TODO: always do webpack -p for deploy to production, and add a unique hash
73+
74+
TODO: consider code splitting to split out common parts (e.g., libraries
75+
and unchanging parts) from the specific frontends
76+

‎v5-unity/js/opt-frontend-common.ts‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ require('./jquery-3.0.0.min.js');
88
require('./jquery.ba-bbq.js'); // contains slight pgbovine modifications
99
require('./jquery.ba-dotimeout.min.js');
1010

11-
var optTests = require('./opt-testcases.ts');
1211
var pytutor = require('./pytutor.ts');
1312
var assert = pytutor.assert;
1413

@@ -46,6 +45,9 @@ declare namespace AceAjax {
4645

4746
var originFrontendJsFile: string = undefined;
4847

48+
var appStateAugmenter: any = undefined; // super hacky! fixme
49+
var loadTestCases: any = undefined; // super hacky! fixme
50+
4951
// backend scripts to execute (Python 2 and 3 variants, if available)
5052
// make two copies of ../web_exec.py and give them the following names,
5153
// then change the first line (starting with #!) to the proper version
@@ -349,6 +351,8 @@ var togetherjsInUrl = ($.bbq.getState('togetherjs') !== undefined);
349351
var TogetherJSConfig_hubBase = "http://localhost:30035/"; // local
350352

351353
// TogetherJS common configuration
354+
// TODO: xxx these aren't 'exported' so they're no longer visible to TogetherJS
355+
// ... thus, these will NOT SET TogetherJS configuration options. ergh!!!
352356
var TogetherJSConfig_disableWebRTC = true;
353357
var TogetherJSConfig_suppressJoinConfirmation = true;
354358
var TogetherJSConfig_dontShowClicks = false;
@@ -810,6 +814,7 @@ function pyInputSetScrollTop(st) {
810814
}
811815

812816

817+
// TODO: fixme, this is all very hacky and inelegant
813818
function initializeFrontendParams(params) {
814819
originFrontendJsFile = params.originFrontendJsFile;
815820
executeCode = params.executeCode;
@@ -829,6 +834,12 @@ function initializeFrontendParams(params) {
829834
if (params.initAceEditor) {
830835
initAceEditor = params.initAceEditor;
831836
}
837+
if (params.appStateAugmenter) {
838+
appStateAugmenter = params.appStateAugmenter;
839+
}
840+
if (params.loadTestCases) {
841+
loadTestCases = params.loadTestCases;
842+
}
832843
}
833844

834845

@@ -1064,12 +1075,8 @@ function parseQueryString() {
10641075
codeopticonUsername = queryStrOptions.codeopticonUsername; // GLOBAL defined in codeopticon-learner.js
10651076
}
10661077

1067-
if (queryStrOptions.testCasesLst) {
1068-
$("#createTestsLink").hide();
1069-
optTests.initTestcasesPane('#testCasesPane');
1070-
queryStrOptions.testCasesLst.forEach(function(e) {
1071-
optTests.addTestcase(e);
1072-
});
1078+
if (queryStrOptions.testCasesLst && typeof(loadTestCases) !== 'undefined') {
1079+
loadTestCases(queryStrOptions.testCasesLst);
10731080
}
10741081

10751082
// ugh tricky -- always start in edit mode by default, and then

‎v5-unity/js/opt-frontend.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,8 @@ $(document).ready(function() {
688688
TogetherjsReadyHandler: optFrontendTogetherjsReadyHandler,
689689
TogetherjsCloseHandler: optFrontendTogetherjsCloseHandler,
690690
startSharedSession: optFrontendStartSharedSession,
691+
appStateAugmenter: optTests.appStateAugmenter,
692+
loadTestCases: optTests.loadTestcasesIntoPane,
691693
}); // initialize at the end
692694

693695

‎v5-unity/js/opt-live.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,8 +618,8 @@ function optLiveExecuteCode(forceStartingInstr, forceRawInputLst) {
618618
}
619619

620620
// see getAppState to see where it calls out to this function:
621-
function appStateAugmenter(appState) {
622-
appState.mode = 'display'; // super hack so that when you generate URLs, it will say 'display' mode
621+
function optLiveAppStateAugmenter(appState) {
622+
appState.mode = 'display'; // super hack so that when you generate URLs, it will say 'display' mode since we want to jump to curInstr, and that happens only in 'display' mode
623623
}
624624

625625
function optliveExecuteCodeFromScratch() {
@@ -631,6 +631,7 @@ $(document).ready(function() {
631631
optCommon.genericOptFrontendReady({originFrontendJsFile: originFrontendJsFile,
632632
executeCode: optLiveExecuteCode,
633633
initAceEditor: optLiveInitAceEditor,
634+
appStateAugmenter: optLiveAppStateAugmenter,
634635
});
635636

636637
$('#legendDiv')

‎v5-unity/js/opt-testcases.ts‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var testcasesPaneHtml = '\
3232
<a href="#" id="addNewTestCase">Add new test</a>\
3333
'
3434

35-
export function initTestcasesPane(parentDivId, onChangeCallback /* optional */) {
35+
export function initTestcasesPane(parentDivId, onChangeCallback=null /* optional */) {
3636
$(parentDivId).empty(); // just to be paranoid, empty this out
3737
// (and its event handlers, too, supposedly)
3838
$(parentDivId).html(testcasesPaneHtml);
@@ -93,7 +93,7 @@ function vizTestFinishSuccessfulExecution() {
9393
var curTestcaseId = 1;
9494

9595
function addTestcase(initialCod /* optional code to pre-seed this test */,
96-
onChangeCallback /* to be called if this elt changes */) {
96+
onChangeCallback=null /* to be called if this elt changes */) {
9797
var id = curTestcaseId;
9898
curTestcaseId++; // nasty global
9999
var newTr = $('<tr/>').attr('id', 'testCaseRow_' + id);
@@ -271,9 +271,17 @@ function getAllTestcases() {
271271
}
272272

273273
// see getAppState to see where it calls out to this function:
274-
function appStateAugmenter(appState) {
274+
export function appStateAugmenter(appState) {
275275
var tc = getAllTestcases();
276276
if (tc.length > 0) {
277277
appState['testCasesJSON'] = JSON.stringify(tc);
278278
}
279279
}
280+
281+
export function loadTestcasesIntoPane(testCasesLst) {
282+
$("#createTestsLink").hide();
283+
initTestcasesPane('#testCasesPane');
284+
testCasesLst.forEach(function(e) {
285+
addTestcase(e);
286+
});
287+
}

‎v5-unity/js/pytutor.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,12 @@ export function ExecutionVisualizer(domRootID, dat, params) {
165165
this.codeRowHeight = undefined;
166166

167167
// avoid 'undefined' state
168-
this.disableHeapNesting = (this.params.disableHeapNesting == true);
169-
this.drawParentPointers = (this.params.drawParentPointers == true);
170-
this.textualMemoryLabels = (this.params.textualMemoryLabels == true);
171-
this.showOnlyOutputs = (this.params.showOnlyOutputs == true);
172-
this.tabularView = (this.params.tabularView == true);
173-
this.showAllFrameLabels = (this.params.showAllFrameLabels == true);
168+
this.disableHeapNesting = (this.params.disableHeapNesting === true);
169+
this.drawParentPointers = (this.params.drawParentPointers === true);
170+
this.textualMemoryLabels = (this.params.textualMemoryLabels === true);
171+
this.showOnlyOutputs = (this.params.showOnlyOutputs === true);
172+
this.tabularView = (this.params.tabularView === true);
173+
this.showAllFrameLabels = (this.params.showAllFrameLabels === true);
174174

175175
this.executeCodeWithRawInputFunc = this.params.executeCodeWithRawInputFunc;
176176

‎v5-unity/package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
"scripts": {
1010
"start": "python bottle_server.py",
11-
"webpack": "webpack --progress --colors --watch"
11+
"webpack": "webpack --progress --colors --watch",
12+
"prod": "webpack -p"
1213
},
1314

1415
"dependencies" : {

0 commit comments

Comments
 (0)