44
55import "../css/user-highlights.css" ;
66
7-
87function getCompletions ( ) {
98 // Get the completion status
109 if (
@@ -43,10 +42,10 @@ function getCompletions() {
4342 }
4443 $ ( "#main-content" ) . append (
4544 '<div style="text-align:center"><button class="btn btn-lg ' +
46- completionClass +
47- '" id="completionButton">' +
48- completionMsg +
49- "</button></div>"
45+ completionClass +
46+ '" id="completionButton">' +
47+ completionMsg +
48+ "</button></div>"
5049 ) ;
5150 }
5251 } ) ;
@@ -57,8 +56,8 @@ function showLastPositionBanner() {
5756 if ( typeof lastPositionVal !== "undefined" ) {
5857 $ ( "body" ) . append (
5958 '<img src="../_static/last-point.png" style="position:absolute; padding-top:55px; left: 10px; top: ' +
60- parseInt ( lastPositionVal ) +
61- 'px;"/>'
59+ parseInt ( lastPositionVal ) +
60+ 'px;"/>'
6261 ) ;
6362 $ ( "html, body" ) . animate ( { scrollTop : parseInt ( lastPositionVal ) } , 1000 ) ;
6463 }
@@ -168,95 +167,100 @@ function decorateTableOfContents() {
168167 window . location . href . toLowerCase ( ) . indexOf ( "toc.html" ) != - 1 ||
169168 window . location . href . toLowerCase ( ) . indexOf ( "index.html" ) != - 1
170169 ) {
171- jQuery . get ( ` ${ eBookConfig . new_server_prefix } /logger/getAllCompletionStatus` , function (
172- data
173- ) {
174- var subChapterList ;
175- if ( data != "None" ) {
176- subChapterList = data . detail ;
170+ jQuery . get (
171+ ` ${ eBookConfig . new_server_prefix } /logger/getAllCompletionStatus` ,
172+ function ( data ) {
173+ var subChapterList ;
174+ if ( data != "None" ) {
175+ subChapterList = data . detail ;
177176
178- var allSubChapterURLs = $ ( "#main-content div li a" ) ;
179- $ . each ( subChapterList , function ( index , item ) {
180- for ( var s = 0 ; s < allSubChapterURLs . length ; s ++ ) {
181- if (
182- allSubChapterURLs [ s ] . href . indexOf (
183- item . chapterName + "/" + item . subChapterName
184- ) != - 1
185- ) {
186- if ( item . completionStatus == 1 ) {
187- $ ( allSubChapterURLs [ s ] . parentElement )
188- . addClass ( "completed" )
189- . append (
190- '<span class="infoTextCompleted">- Completed this topic on ' +
191- item . endDate +
192- "</span>"
193- )
194- . children ( )
195- . first ( )
196- . hover (
197- function ( ) {
198- $ ( this )
199- . next ( ".infoTextCompleted" )
200- . show ( ) ;
201- } ,
202- function ( ) {
203- $ ( this )
204- . next ( ".infoTextCompleted" )
205- . hide ( ) ;
206- }
207- ) ;
208- } else if ( item . completionStatus == 0 ) {
209- $ ( allSubChapterURLs [ s ] . parentElement )
210- . addClass ( "active" )
211- . append (
212- '<span class="infoTextActive">Last read this topic on ' +
213- item . endDate +
214- "</span>"
215- )
216- . children ( )
217- . first ( )
218- . hover (
219- function ( ) {
220- $ ( this )
221- . next ( ".infoTextActive" )
222- . show ( ) ;
223- } ,
224- function ( ) {
225- $ ( this )
226- . next ( ".infoTextActive" )
227- . hide ( ) ;
228- }
229- ) ;
177+ var allSubChapterURLs = $ ( "#main-content div li a" ) ;
178+ $ . each ( subChapterList , function ( index , item ) {
179+ for ( var s = 0 ; s < allSubChapterURLs . length ; s ++ ) {
180+ if (
181+ allSubChapterURLs [ s ] . href . indexOf (
182+ item . chapterName + "/" + item . subChapterName
183+ ) != - 1
184+ ) {
185+ if ( item . completionStatus == 1 ) {
186+ $ ( allSubChapterURLs [ s ] . parentElement )
187+ . addClass ( "completed" )
188+ . append (
189+ '<span class="infoTextCompleted">- Completed this topic on ' +
190+ item . endDate +
191+ "</span>"
192+ )
193+ . children ( )
194+ . first ( )
195+ . hover (
196+ function ( ) {
197+ $ ( this )
198+ . next ( ".infoTextCompleted" )
199+ . show ( ) ;
200+ } ,
201+ function ( ) {
202+ $ ( this )
203+ . next ( ".infoTextCompleted" )
204+ . hide ( ) ;
205+ }
206+ ) ;
207+ } else if ( item . completionStatus == 0 ) {
208+ $ ( allSubChapterURLs [ s ] . parentElement )
209+ . addClass ( "active" )
210+ . append (
211+ '<span class="infoTextActive">Last read this topic on ' +
212+ item . endDate +
213+ "</span>"
214+ )
215+ . children ( )
216+ . first ( )
217+ . hover (
218+ function ( ) {
219+ $ ( this )
220+ . next ( ".infoTextActive" )
221+ . show ( ) ;
222+ } ,
223+ function ( ) {
224+ $ ( this )
225+ . next ( ".infoTextActive" )
226+ . hide ( ) ;
227+ }
228+ ) ;
229+ }
230230 }
231231 }
232- }
233- } ) ;
232+ } ) ;
233+ }
234234 }
235- } ) ;
235+ ) ;
236236 var data = { course : eBookConfig . course } ;
237- jQuery . get ( `${ eBookConfig . new_server_prefix } /logger/getlastpage` , data , function ( data ) {
238- var lastPageData ;
239- if ( data != "None" ) {
240- lastPageData = data . detail ;
241- if ( lastPageData . lastPageChapter != null ) {
242- $ ( "#continue-reading" )
243- . show ( )
244- . html (
245- '<div id="jump-to-chapter" class="alert alert-info" ><strong>You were Last Reading:</strong> ' +
246- lastPageData . lastPageChapter +
247- ( lastPageData . lastPageSubchapter
248- ? " > " +
249- lastPageData . lastPageSubchapter
250- : "" ) +
251- ' <a href="' +
252- lastPageData . lastPageUrl +
253- "?lastPosition=" +
254- lastPageData . lastPageScrollLocation +
255- '">Continue Reading</a></div>'
256- ) ;
237+ jQuery . get (
238+ `${ eBookConfig . new_server_prefix } /logger/getlastpage` ,
239+ data ,
240+ function ( data ) {
241+ var lastPageData ;
242+ if ( data != "None" ) {
243+ lastPageData = data . detail ;
244+ if ( lastPageData . lastPageChapter != null ) {
245+ $ ( "#continue-reading" )
246+ . show ( )
247+ . html (
248+ '<div id="jump-to-chapter" class="alert alert-info" ><strong>You were Last Reading:</strong> ' +
249+ lastPageData . lastPageChapter +
250+ ( lastPageData . lastPageSubchapter
251+ ? " > " +
252+ lastPageData . lastPageSubchapter
253+ : "" ) +
254+ ' <a href="' +
255+ lastPageData . lastPageUrl +
256+ "?lastPosition=" +
257+ lastPageData . lastPageScrollLocation +
258+ '">Continue Reading</a></div>'
259+ ) ;
260+ }
257261 }
258262 }
259- } ) ;
263+ ) ;
260264 }
261265}
262266
@@ -268,7 +272,7 @@ function enableCompletions() {
268272}
269273
270274// call enable user highlights after login
271- $ ( document ) . bind ( "runestone:login" , enableCompletions ) ;
275+ $ ( document ) . on ( "runestone:login" , enableCompletions ) ;
272276
273277// _ processPageState
274278// -------------------------
0 commit comments