Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit f36f6cf

Browse files
committed
continue move to async/await
Signed-off-by: Brad Miller <bonelake@mac.com>
1 parent 2280f0c commit f36f6cf

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

runestone/activecode/js/activecode.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -536,26 +536,25 @@ export class ActiveCode extends RunestoneBase {
536536
// add an initial load history button
537537
// if there is no edit then there is no append to_save (True/False)
538538
async addHistoryScrubber(pos_last) {
539-
var data = {
539+
let deferred = Promise.resolve();
540+
var reqData = {
540541
acid: this.divid,
541542
};
542-
var deferred = jQuery.Deferred();
543543
if (this.sid !== undefined) {
544-
data["sid"] = this.sid;
544+
reqData["sid"] = this.sid;
545545
}
546546
console.log("before get hist");
547-
548547
if (
549548
eBookConfig.practice_mode ||
550549
(this.isTimed && !this.assessmentTaken)
551550
) {
552551
// If this is timed and already taken we should restore history info
553-
helper();
552+
this.renderScrubber();
554553
} else {
555554
let request = new Request(eBookConfig.ajaxURL + "gethist.json", {
556555
method: "POST",
557556
headers: this.jsonHeaders,
558-
body: JSON.stringify(data),
557+
body: JSON.stringify(reqData),
559558
});
560559
let response = await fetch(request);
561560
let data = await response.json();
@@ -567,12 +566,15 @@ export class ActiveCode extends RunestoneBase {
567566
);
568567
}
569568
}
570-
helper();
569+
deferred = new Promise((resolve, reject) => {
570+
this.renderScrubber(pos_last);
571+
resolve("done");
572+
});
571573
}
572574
return deferred;
573575
}
574576

575-
helper() {
577+
renderScrubber(pos_last) {
576578
console.log("making a new scrubber");
577579
var scrubberDiv = document.createElement("div");
578580
$(scrubberDiv).css("display", "inline-block");
@@ -635,7 +637,6 @@ export class ActiveCode extends RunestoneBase {
635637
this.histButton = null;
636638
this.historyScrubber = scrubber;
637639
$(scrubberDiv).insertAfter(this.runButton);
638-
deferred.resolve();
639640
} // end definition of helper
640641

641642
createOutput() {
@@ -657,7 +658,7 @@ export class ActiveCode extends RunestoneBase {
657658
$(this.graphics).on(
658659
"DOMNodeInserted",
659660
"canvas",
660-
function (e) {
661+
function () {
661662
$(this.graphics).addClass("visible-ac-canvas");
662663
}.bind(this)
663664
);

runestone/common/js/runestonebase.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ export default class RunestoneBase {
111111
body: JSON.stringify(eventInfo),
112112
});
113113
post_promise = await fetch(request);
114-
post_promise = await fetch(request);
115114
if (!post_promise.ok) {
116115
throw new Error("Failed to log the run");
117116
}

0 commit comments

Comments
 (0)