Skip to content

Commit

Permalink
Fix medialesson (if you go back to the page after visiting)
Browse files Browse the repository at this point in the history
  • Loading branch information
torinfo committed May 4, 2018
1 parent f7b0131 commit afbc2c4
Show file tree
Hide file tree
Showing 6 changed files with 230 additions and 167 deletions.
Expand Up @@ -1068,6 +1068,10 @@ function XTSetPageScoreJSON(page_nr, score)

function XTSetViewed(page_nr, name, score)
{
if (isNaN(score) || typeof score != "number")
{
score = 0.0;
}
state.setPageScore(page_nr, score);
}

Expand All @@ -1088,15 +1092,6 @@ function XThelperConsolidateSegments(videostate)
}
csegments.push(segment);
}
var segstr = "[";
for (var i=0; i<csegments.length; i++)
{
if (i>0)
segstr += ", ";
segstr += "(" + csegments[i].start + ", " + csegments[i].end + ")";
}
segstr += "]";
console.log("Consolidated segments: " + segstr);
return csegments;
}

Expand All @@ -1108,7 +1103,11 @@ function XThelperDetermineProgress(videostate)
{
videoseen += csegments[i].end - csegments[i].start;
}
return Math.round(videoseen / videostate.duration * 10000.0)/100.0;
// normalized between 0 and 1
if (!isNaN(videostate.duration) && videostate.duration > 0) {
return Math.round(videoseen / videostate.duration * 100.0) / 100.0;
}
return 0.0;
}

function XTVideo(page_nr, name, block_name, verb, videostate) {
Expand Down

0 comments on commit afbc2c4

Please sign in to comment.