Skip to content

Commit 32f550e

Browse files
committed
eliminate silly default modal dialogs
1 parent 75cd6e8 commit 32f550e

8 files changed

Lines changed: 36 additions & 16 deletions

v3/composingprograms.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<br/>
7474

7575
<div id="codeInputPane"></div> <!-- populate with a CodeMirror instance -->
76-
76+
<div id="frontendErrorOutput"></div>
7777
<div id="surveyPane"></div>
7878

7979
<p>

v3/csc108h.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
<br/>
7373

7474
<div id="codeInputPane"></div> <!-- populate with a CodeMirror instance -->
75-
75+
<div id="frontendErrorOutput"></div>
7676
<div id="surveyPane"></div>
7777

7878
<p>

v3/css/opt-frontend.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ button.surveyBtn {
8686
margin-right: auto;
8787
}
8888

89+
#frontendErrorOutput {
90+
color: #e93f34; /* should match brightRed JavaScript variable */
91+
font-size: 12pt;
92+
line-height: 1.5em;
93+
margin-top: 8px;
94+
}
8995

9096
/* necessary for CodeMirror error line highlighting to work! */
9197
.CodeMirror .errorLine { background: #ffff3f !important; }

v3/js/composingprograms.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ $(document).ready(function() {
9898
function executeCodeFromScratch() {
9999
// don't execute empty string:
100100
if ($.trim(pyInputCodeMirror.getValue()) == '') {
101-
alert('Type in some code to visualize.');
101+
setFronendError(["Type in some code to visualize."]);
102102
return;
103103
}
104104

v3/js/csc108h.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ $(document).ready(function() {
101101
function executeCodeFromScratch() {
102102
// don't execute empty string:
103103
if ($.trim(pyInputCodeMirror.getValue()) == '') {
104-
alert('Type in some code to visualize.');
104+
setFronendError(["Type in some code to visualize."]);
105105
return;
106106
}
107107

v3/js/opt-frontend-common.js

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,15 @@ function redrawConnectors() {
102102
}
103103
}
104104

105+
function setFronendError(lines) {
106+
$("#frontendErrorOutput").html(lines.map(htmlspecialchars).join('<br/>'));
107+
$("#frontendErrorOutput").show();
108+
}
109+
110+
function clearFrontendError() {
111+
$("#frontendErrorOutput").hide();
112+
}
113+
105114

106115
// run at the END so that everything else can be initialized first
107116
function genericOptFrontendReady() {
@@ -153,12 +162,14 @@ function genericOptFrontendReady() {
153162
return; // get out early
154163
}
155164

156-
alert("Server error (possibly due to memory/resource overload). " +
157-
"Report a bug to philip@pgbovine.net\n\n" +
158-
"(Click the 'Generate URL' button to include a unique URL in your email bug report.)");
165+
setFronendError(["Server error (possibly due to memory/resource overload).",
166+
"Report a bug to philip@pgbovine.net by clicking on the",
167+
"'Generate URL' button and including a URL in your email."]);
159168

160169
doneExecutingCode();
161170
});
171+
172+
clearFrontendError();
162173
}
163174

164175
function getQueryStringOptions() {
@@ -370,12 +381,16 @@ function executePythonCode(pythonSourceCode,
370381
outputDiv,
371382
handleSuccessFunc, handleUncaughtExceptionFunc) {
372383
if (!backendScript) {
373-
alert('Server configuration error: No backend script');
384+
setFronendError(["Server configuration error: No backend script",
385+
"Report a bug to philip@pgbovine.net by clicking on the",
386+
"'Generate URL' button and including a URL in your email."]);
374387
return;
375388
}
376389

377390
isExecutingCode = true; // nasty global
378391

392+
clearFrontendError();
393+
379394
$.get(backendScript,
380395
{user_script : pythonSourceCode,
381396
raw_input_json: rawInputLst.length > 0 ? JSON.stringify(rawInputLst) : '',
@@ -391,16 +406,15 @@ function executePythonCode(pythonSourceCode,
391406
handleUncaughtExceptionFunc(trace);
392407

393408
if (trace.length == 1) {
394-
alert(trace[0].exception_msg);
409+
setFronendError([trace[0].exception_msg]);
395410
}
396411
else if (trace[trace.length - 1].exception_msg) {
397-
alert(trace[trace.length - 1].exception_msg);
412+
setFronendError([trace[trace.length - 1].exception_msg]);
398413
}
399414
else {
400-
alert("Unknown error. Reload to try again," +
401-
"or report a bug to philip@pgbovine.net\n\n" +
402-
"(Click the 'Generate URL' button to include a " +
403-
"unique URL in your email bug report.)");
415+
setFronendError(["Unknown error. Reload the page and try again.",
416+
"Report a bug to philip@pgbovine.net by clicking on the",
417+
"'Generate URL' button and including a URL in your email."]);
404418
}
405419
}
406420
else {

v3/js/opt-frontend.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ function executeCode(forceStartingInstr) {
380380
function executeCodeFromScratch() {
381381
// don't execute empty string:
382382
if ($.trim(pyInputCodeMirror.getValue()) == '') {
383-
alert('Type in some code to visualize.');
383+
setFronendError(["Type in some code to visualize."]);
384384
return;
385385
}
386386

v3/visualize.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
<br/>
108108

109109
<div id="codeInputPane"></div> <!-- populate with a CodeMirror instance -->
110-
110+
<div id="frontendErrorOutput"></div>
111111
<div id="surveyPane"></div>
112112

113113
<p>

0 commit comments

Comments
 (0)