Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
39 lines (34 sloc) 1.46 KB
{% if site.format == "web" and page.progress != false %}<div class="progressContext">
<div id="yourProgress"></div>
{% assign pages = site.docs | where: "progress", true %}
{% assign progressPages = pages | sort: "weight" %}
{% for pg in progressPages %}
{% if pg.permalink == page.permalink %}
{% assign remainingPages = forloop.length | minus: forloop.index %}
{% assign totalPages = forloop.length %}
{% assign completedPages = forloop.index %}
<script>
$( document ).ready(function() {
var percentComplete = "width:" + ({{completedPages}} / {{totalPages}}) * 100 + "%";
var yourProgressSoFar = "<h2>Your progress through this course so far: " + Math.round(({{completedPages}} / {{totalPages}}) * 100) + "%</h2>";
// console.log("percentComplete:" + percentComplete);
$( "#progressBar" ).attr("style", percentComplete);
$( "#yourProgress" ).append(yourProgressSoFar);
});
</script>
<div class="progress">
<div id="progressBar" class="progress-bar" role="progressbar" aria-valuenow="{{forloop.index}}"
aria-valuemin="0" aria-valuemax="{{forloop.length}}">
<span class="sr-only">{{forloop.index}}% Complete</span>
</div>
</div>
{% break %}
{% endif %}
{% endfor %}
{% if remainingPages == 0 %}
You've completed the course!
{% else %}
<p>{{completedPages}}/{{totalPages}} pages complete. Only {{remainingPages}} more pages to go...</p>
{% endif %}
</div>
{% endif %}