Skip to content

Commit 88eed7f

Browse files
committed
more minor shufflings
1 parent d59ac8c commit 88eed7f

2 files changed

Lines changed: 32 additions & 53 deletions

File tree

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

Lines changed: 32 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -167,25 +167,16 @@ function generateUUID(){
167167
return uuid;
168168
};
169169

170-
171-
// OMG nasty wtf?!?
172-
173-
// From: http://stackoverflow.com/questions/21159301/quotaexceedederror-dom-exception-22-an-attempt-was-made-to-add-something-to-st
174-
175-
// Safari, in Private Browsing Mode, looks like it supports localStorage but all calls to setItem
176-
// throw QuotaExceededError. We're going to detect this and just silently drop any calls to setItem
177-
// to avoid the entire page breaking, without having to do a check at each usage of Storage.
178-
if (typeof localStorage === 'object') {
179-
try {
180-
localStorage.setItem('localStorage', '1');
181-
localStorage.removeItem('localStorage');
182-
} catch (e) {
183-
(Storage as any /* TS too strict */).prototype._setItem = Storage.prototype.setItem;
184-
Storage.prototype.setItem = function() {};
185-
alert('Your web browser does not support storing settings locally. In Safari, the most common cause of this is using "Private Browsing Mode". Some settings may not save or some features may not work properly for you.');
186-
}
170+
// From http://diveintohtml5.info/storage.html
171+
function supports_html5_storage() {
172+
try {
173+
return 'localStorage' in window && window['localStorage'] !== null;
174+
} catch (e) {
175+
return false;
176+
}
187177
}
188178

179+
189180
function initDeltaObj() {
190181
// make sure the editor already exists
191182
// (editor doesn't exist when you're, say, doing an iframe embed)
@@ -232,7 +223,6 @@ var initAceEditor = function(height) {
232223
s.setOption("useWorker", false);
233224

234225
setAceMode();
235-
236226
pyInputAceEditor.focus();
237227
}
238228

@@ -264,8 +254,9 @@ function setAceMode() {
264254
pyInputSetValue(CPP_BLANK_TEMPLATE);
265255
}
266256
} else {
257+
assert(selectorVal === '2' || selectorVal == '3')
267258
mod = 'python';
268-
tabSize = 4; // PEP8
259+
tabSize = 4; // PEP8 style standards
269260
}
270261
assert(mod);
271262

@@ -403,7 +394,6 @@ function syncAppState(appState) {
403394
}
404395
}
405396

406-
407397
// get OPT ready for integration with TogetherJS
408398
function initTogetherJS() {
409399
if (typeof TogetherJS === "undefined") {
@@ -672,13 +662,8 @@ function initTogetherJS() {
672662
});
673663
}
674664

675-
var TogetherjsReadyHandler = function() {
676-
alert("ERROR: need to override TogetherjsReadyHandler()");
677-
}
678-
679-
var TogetherjsCloseHandler = function() {
680-
alert("ERROR: need to override TogetherjsCloseHandler()");
681-
}
665+
var TogetherjsReadyHandler = undefined; // need to override in frontend
666+
var TogetherjsCloseHandler = undefined; // need to override in frontend
682667

683668
var startSharedSession = function() {
684669
$("#ssDiv").hide(); // hide ASAP!
@@ -716,7 +701,8 @@ function populateTogetherJsShareUrl() {
716701

717702

718703
function redrawConnectors() {
719-
if (appMode == 'display' || appMode == 'visualize' /* deprecated */) {
704+
if (appMode == 'display' ||
705+
appMode == 'visualize' /* deprecated */) {
720706
if (myVisualizer) {
721707
myVisualizer.redrawConnectors();
722708
}
@@ -731,15 +717,6 @@ function clearFrontendError() {
731717
$("#frontendErrorOutput").html('');
732718
}
733719

734-
// From http://diveintohtml5.info/storage.html
735-
function supports_html5_storage() {
736-
try {
737-
return 'localStorage' in window && window['localStorage'] !== null;
738-
} catch (e) {
739-
return false;
740-
}
741-
}
742-
743720
function pyInputGetValue() {
744721
return pyInputAceEditor.getValue();
745722
}
@@ -849,6 +826,23 @@ function genericOptFrontendReady(params) {
849826
*/
850827

851828

829+
// OMG nasty wtf?!?
830+
// From: http://stackoverflow.com/questions/21159301/quotaexceedederror-dom-exception-22-an-attempt-was-made-to-add-something-to-st
831+
// Safari, in Private Browsing Mode, looks like it supports localStorage but all calls to setItem
832+
// throw QuotaExceededError. We're going to detect this and just silently drop any calls to setItem
833+
// to avoid the entire page breaking, without having to do a check at each usage of Storage.
834+
if (typeof localStorage === 'object') {
835+
try {
836+
localStorage.setItem('localStorage', '1');
837+
localStorage.removeItem('localStorage');
838+
} catch (e) {
839+
(Storage as any /* TS too strict */).prototype._setItem = Storage.prototype.setItem;
840+
Storage.prototype.setItem = function() {};
841+
alert('Your web browser does not support storing settings locally. In Safari, the most common cause of this is using "Private Browsing Mode". Some features may not work properly for you.');
842+
}
843+
}
844+
845+
852846
// first initialize options from HTML LocalStorage. very important
853847
// that this code runs FIRST so that options get overridden by query
854848
// string options and anything else the user wants to override with.
@@ -907,7 +901,7 @@ function genericOptFrontendReady(params) {
907901
// ugh other idiosyncratic errors to ignore
908902
if ((settings.url.indexOf('name_lookup.py') > -1) ||
909903
(settings.url.indexOf('syntax_err_survey.py') > -1) ||
910-
(settings.url.indexOf('viz_interaction.py') > -1) {
904+
(settings.url.indexOf('viz_interaction.py') > -1)) {
911905
return; // get out early
912906
}
913907

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -707,21 +707,6 @@ $(document).ready(function() {
707707
loadTestCases: optTests.loadTestcasesIntoPane,
708708
}); // initialize at the end
709709

710-
711-
// deployed on 2015-03-12, taken down on 2015-03-16
712-
//$("#surveyHeader").html('<a href="http://45.56.123.166/~mgordon/OnlinePythonTutor/v3/embedding-demo.html?session=fvkqv4423mcxr" target="_blank">Click here to help our research</a> by collaboratively annotating<br/>a piece of Python code to create a tutorial for beginners.');
713-
//$("#surveyHeader").css('font-size', '12pt');
714-
715-
// run this AFTER genericOptFrontendReady so that opt_uuid is already
716-
// set by now
717-
var myUuid = optCommon.supports_html5_storage() ? localStorage.getItem('opt_uuid') : '';
718-
// deployed on 2015-03-19, added opt_uuid param on 2015-03-20
719-
// taken down on 2015-05-14
720-
//$("#surveyHeader")
721-
// .html('<iframe width="820" height="120" frameborder="0" src="http://45.56.123.166/~mgordon/OnlinePythonTutor/v3/embedding-demo-blur-frame.html?opt_uuid=' + myUuid + '"></iframe>')
722-
// .css('margin-bottom', '10px');
723-
724-
725710
initAceAndOptions(); // do this after genericOptFrontendReady
726711

727712
if (typeof initCodeopticon !== "undefined") {

0 commit comments

Comments
 (0)