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

Commit dbdcd5b

Browse files
author
Brad Miller
committed
Handle static books better
1 parent eed968a commit dbdcd5b

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

runestone/common/js/bookfuncs.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class PageProgressBar {
109109
constructor(actDict) {
110110
this.possible = 0;
111111
this.total = 1;
112-
this.activities = actDict;
112+
this.activities = actDict || {};
113113
this.calculateProgress();
114114
this.renderProgress()
115115

@@ -128,16 +128,22 @@ class PageProgressBar {
128128

129129

130130
renderProgress() {
131+
let value = 0;
131132
$("#scprogresstotal").text(this.total);
132133
$("#scprogressposs").text(this.possible);
134+
try {
135+
value = 100 * this.total / this.possible;
136+
} catch(e) {
137+
value = 0;
138+
}
133139
$( "#subchapterprogress" ).progressbar({
134-
value: 100 * this.total/this.possible
140+
value: value
135141
});
136142
}
137143

138144
updateProgress(div_id) {
139145
this.activities[div_id]++;
140-
// We only update the progress bar on the first interaction with an object.
146+
// Only update the progress bar on the first interaction with an object.
141147
if (this.activities[div_id] === 1) {
142148
this.total++;
143149
let val = 100 * this.total / this.possible;

0 commit comments

Comments
 (0)