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

Commit a765e39

Browse files
committed
Fix: detect pretext book and use for progress
1 parent 82d9215 commit a765e39

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

runestone/common/js/user-highlights.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ function getCompletions() {
2121
currentPathname.lastIndexOf("?")
2222
);
2323
}
24-
var data = { lastPageUrl: currentPathname };
24+
var data = {
25+
lastPageUrl: currentPathname,
26+
isPtxBook: isPreTeXt()
27+
};
2528
jQuery
2629
.ajax({
2730
url: `${eBookConfig.new_server_prefix}/logger/getCompletionStatus`,
@@ -40,7 +43,7 @@ function getCompletions() {
4043
completionClass = "buttonAskCompletion";
4144
completionMsg = "Mark as Completed";
4245
}
43-
$("#main-content").append(
46+
$("#scprogresscontainer").append(
4447
'<div style="text-align:center"><button class="btn btn-lg ' +
4548
completionClass +
4649
'" id="completionButton">' +
@@ -274,6 +277,14 @@ function enableCompletions() {
274277
// call enable user highlights after login
275278
$(document).on("runestone:login", enableCompletions);
276279

280+
function isPreTeXt() {
281+
let ptxMarker = document.querySelector("body.pretext");
282+
if (ptxMarker) {
283+
return true;
284+
} else {
285+
return false;
286+
}
287+
}
277288
// _ processPageState
278289
// -------------------------
279290
function processPageState(completionFlag) {
@@ -285,11 +296,14 @@ function processPageState(completionFlag) {
285296
currentPathname.lastIndexOf("?")
286297
);
287298
}
299+
// Is this a ptx book?
300+
let isPtxBook = isPreTeXt()
288301
var data = {
289302
lastPageUrl: currentPathname,
290303
lastPageScrollLocation: $(window).scrollTop(),
291304
completionFlag: completionFlag,
292305
course: eBookConfig.course,
306+
isPtxBook: isPtxBook,
293307
};
294308
$(document).ajaxError(function (e, jqhxr, settings, exception) {
295309
console.log("Request Failed for " + settings.url);

0 commit comments

Comments
 (0)