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

Commit 3cf96c7

Browse files
committed
fix updatelastpage
1 parent 3fbc9ee commit 3cf96c7

1 file changed

Lines changed: 16 additions & 13 deletions

File tree

runestone/common/js/user-highlights.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ function getCompletions() {
2525
var data = { lastPageUrl: currentPathname };
2626
jQuery
2727
.ajax({
28-
url: eBookConfig.ajaxURL + "getCompletionStatus",
28+
url: "/logger/getCompletionStatus",
2929
data: data,
3030
async: false,
3131
})
3232
.done(function (data) {
3333
if (data != "None") {
34-
var completionData = $.parseJSON(data);
34+
var completionData = data.detail;
3535
var completionClass, completionMsg;
3636
if (completionData[0].completionStatus == 1) {
3737
completionClass = "buttonConfirmCompletion";
@@ -165,12 +165,12 @@ function decorateTableOfContents() {
165165
window.location.href.toLowerCase().indexOf("toc.html") != -1 ||
166166
window.location.href.toLowerCase().indexOf("index.html") != -1
167167
) {
168-
jQuery.get(eBookConfig.ajaxURL + "getAllCompletionStatus", function (
168+
jQuery.get("/logger/getAllCompletionStatus", function (
169169
data
170170
) {
171171
var subChapterList;
172172
if (data != "None") {
173-
subChapterList = $.parseJSON(data);
173+
subChapterList = data;
174174

175175
var allSubChapterURLs = $("#main-content div li a");
176176
$.each(subChapterList, function (index, item) {
@@ -234,21 +234,21 @@ function decorateTableOfContents() {
234234
jQuery.get("/logger/getlastpage", data, function (data) {
235235
var lastPageData;
236236
if (data != "None") {
237-
lastPageData = $.parseJSON(data);
238-
if (lastPageData[0].lastPageChapter != null) {
237+
lastPageData = data.detail;
238+
if (lastPageData.lastPageChapter != null) {
239239
$("#continue-reading")
240240
.show()
241241
.html(
242242
'<div id="jump-to-chapter" class="alert alert-info" ><strong>You were Last Reading:</strong> ' +
243-
lastPageData[0].lastPageChapter +
244-
(lastPageData[0].lastPageSubchapter
243+
lastPageData.lastPageChapter +
244+
(lastPageData.lastPageSubchapter
245245
? " &gt; " +
246-
lastPageData[0].lastPageSubchapter
246+
lastPageData.lastPageSubchapter
247247
: "") +
248248
' <a href="' +
249-
lastPageData[0].lastPageUrl +
249+
lastPageData.lastPageUrl +
250250
"?lastPosition=" +
251-
lastPageData[0].lastPageScrollLocation +
251+
lastPageData.lastPageScrollLocation +
252252
'">Continue Reading</a></div>'
253253
);
254254
}
@@ -287,8 +287,11 @@ function processPageState(completionFlag) {
287287
console.log(e);
288288
});
289289
jQuery.ajax({
290-
url: eBookConfig.ajaxURL + "updatelastpage",
291-
data: data,
290+
url: "/logger/updatelastpage",
291+
contentType: "application/json; charset=utf-8",
292+
dataType: "json",
293+
data: JSON.stringify(data),
294+
method: "POST",
292295
async: true,
293296
});
294297
}

0 commit comments

Comments
 (0)