Skip to content

Commit

Permalink
More linting
Browse files Browse the repository at this point in the history
  • Loading branch information
runestonetest committed Mar 29, 2020
1 parent ea6f9e2 commit 1bf6305
Show file tree
Hide file tree
Showing 9 changed files with 625 additions and 587 deletions.
5 changes: 3 additions & 2 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
],
"esversion": 6,
"quotmark": true,
"strict": false,
"strict": "implied",
"sub": true,
"browser": true,
"maxerr": 200,
"globalstrict": true
"globalstrict": true,
"devel": true

}
46 changes: 18 additions & 28 deletions runestone/activecode/js/acfactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,30 +104,24 @@ export default class ACFactory {
? eBookConfig.acDefaultLanguage
: "python";
// generate the HTML
var html =
'<div id="ac_modal_' +
divid +
'" class="modal fade">' +
' <div class="modal-dialog scratch-ac-modal">' +
' <div class="modal-content">' +
' <div class="modal-header">' +
' <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>' +
' <h4 class="modal-title">Scratch ActiveCode</h4>' +
" </div> " +
' <div class="modal-body">' +
' <textarea data-component="activecode" data-codelens="true" id="' +
divid +
'" data-lang="' +
lang +
'">' +
"\n" +
"\n" +
"\n" +
" </textarea>" +
" </div>" +
" </div>" +
" </div>" +
"</div>";
var html = `<div id="ac_modal_${divid} class="modal fade">
<div class="modal-dialog scratch-ac-modal">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">Scratch ActiveCode</h4>
</div>
<div class="modal-body">
<textarea data-component="activecode" data-codelens="true" id="${divid} data-lang="${lang}">
</textarea>
</div>
</div>
</div>
</div>`;
var el = $(html);
$("body").append(el);
el.on("shown.bs.modal show.bs.modal", function() {
Expand All @@ -136,10 +130,6 @@ export default class ACFactory {
e.CodeMirror.focus();
});
});
//$(document).bind('keypress', '\\', function(evt) {
// ACFactory.toggleScratchActivecode();
// return false;
//});
}
static toggleScratchActivecode() {
var divid = "ac_modal_" + eBookConfig.scratchDiv;
Expand Down
46 changes: 24 additions & 22 deletions runestone/activecode/js/activecode.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"use strict";

import RunestoneBase from "../../common/js/runestonebase.js";
import AudioTour from "./audiotour";
import "./activecode-i18n.en";
import CodeMirror from "codemirror";
import "codemirror/mode/python/python.js";
Expand Down Expand Up @@ -77,7 +78,7 @@ export class ActiveCode extends RunestoneBase {
socket = new WebSocket("wss://" + chatcodesServer);
}
if (!connection) {
connection = new sharedb.Connection(socket);
connection = new window.sharedb.Connection(socket);
}
if (!doc) {
doc = connection.get("chatcodes", "channels");
Expand Down Expand Up @@ -209,18 +210,19 @@ export class ActiveCode extends RunestoneBase {
}
createControls() {
var ctrlDiv = document.createElement("div");
var butt;
$(ctrlDiv).addClass("ac_actions");
$(ctrlDiv).addClass("col-md-12");
// Run
var butt = document.createElement("button");
butt = document.createElement("button");
$(butt).text($.i18n("msg_activecode_run_code"));
$(butt).addClass("btn btn-success run-button");
ctrlDiv.appendChild(butt);
this.runButton = butt;
$(butt).click(this.runProg.bind(this));
$(butt).attr("type", "button");
if (this.enabledownload || eBookConfig.downloadsEnabled) {
var butt = document.createElement("button");
butt = document.createElement("button");
$(butt).text("Download");
$(butt).addClass("btn save-button");
ctrlDiv.appendChild(butt);
Expand All @@ -229,7 +231,7 @@ export class ActiveCode extends RunestoneBase {
$(butt).attr("type", "button");
}
if (!this.hidecode && !this.hidehistory) {
var butt = document.createElement("button");
butt = document.createElement("button");
$(butt).text($.i18n("msg_activecode_load_history"));
$(butt).addClass("btn btn-default");
$(butt).attr("type", "button");
Expand Down Expand Up @@ -625,7 +627,7 @@ export class ActiveCode extends RunestoneBase {
$(coachDiv).css("display", "none");
this.codecoach = coachDiv;
this.outerDiv.appendChild(coachDiv);
var clearDiv = document.createElement("div");
clearDiv = document.createElement("div");
$(clearDiv).css("clear", "both"); // needed to make parent div resize properly
this.outerDiv.appendChild(clearDiv);
}
Expand Down Expand Up @@ -728,11 +730,12 @@ export class ActiveCode extends RunestoneBase {
// display grades in modal window
var showGradeSummary = function(data, status, whatever) {
var report = eval(data)[0];
var body;
// check for report['message']
if (report) {
if (report["version"] == 2) {
// new version; would be better to embed this in HTML for the activecode
var body =
body =
"<h4>Grade Report</h4>" +
"<p>This question: " +
report["grade"] +
Expand All @@ -743,7 +746,7 @@ export class ActiveCode extends RunestoneBase {
report["comment"] +
"</p>";
} else {
var body =
body =
"<h4>Grade Report</h4>" +
"<p>This assignment: " +
report["grade"] +
Expand All @@ -762,20 +765,19 @@ export class ActiveCode extends RunestoneBase {
body =
"<h4>The server did not return any grade information</h4>";
}
var html =
'<div class="modal fade">' +
' <div class="modal-dialog compare-modal">' +
' <div class="modal-content">' +
' <div class="modal-header">' +
' <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>' +
' <h4 class="modal-title">Assignment Feedback</h4>' +
" </div>" +
' <div class="modal-body">' +
body +
" </div>" +
" </div>" +
" </div>" +
"</div>";
var html = `<div class="modal fade">
<div class="modal-dialog compare-modal">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">Assignment Feedback</h4>
</div>
<div class="modal-body">
${body}
</div>
</div>
</div>
</div>`;
var el = $(html);
el.modal();
};
Expand Down Expand Up @@ -885,7 +887,7 @@ export class ActiveCode extends RunestoneBase {
var ifm = document.createElement("iframe");
$(ifm).addClass("tie-frame");
ifm.src = `https://tech-interview-exercises.appspot.com/client/question.html?qid=${this.tie}`;
setIframeDimensions = function() {
var setIframeDimensions = function() {
$(".tie-container").css(
"width",
$(".tie-container")
Expand Down
2 changes: 1 addition & 1 deletion runestone/activecode/js/activecode_html.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class HTMLActiveCode extends ActiveCode {
runProg() {
var prog = this.buildProg(true);
var scrubber_dfd, history_dfd, saveCode;
var saveCode = "True";
saveCode = "True";
var __ret = this.manage_scrubber(scrubber_dfd, history_dfd, saveCode);
history_dfd = __ret.history_dfd;
saveCode = __ret.saveCode;
Expand Down
Loading

0 comments on commit 1bf6305

Please sign in to comment.