5 {% include base_path.html %}
8 window.onload = function() {
9 var lesson_episodes = [
10 {% for episode in site.episodes %}
11 "{{ episode.url }}"{% unless forloop.last %},{% endunless %}
15 var xmlHttp = []; /* Required since we are going to query every episode. */
16 for (i=0; i < lesson_episodes.length; i++) {
18 xmlHttp[i] = new XMLHttpRequest();
19 xmlHttp[i].episode = lesson_episodes[i]; /* To enable use this later. */
20 xmlHttp[i].onreadystatechange = function() {
22 if (this.readyState == 4 && this.status == 200) {
23 var parser = new DOMParser();
24 var htmlDoc = parser.parseFromString(this.responseText,"text/html");
25 var htmlDocArticle = htmlDoc.getElementsByTagName("article")[0];
27 var article_here = document.getElementById(this.episode);
28 var images = htmlDocArticle.getElementsByTagName("img");
30 if (images.length > 0) {
31 var h1text = htmlDocArticle.getElementsByTagName("h1")[0].innerHTML;
33 var htitle = document.createElement('h2');
34 htitle.innerHTML = h1text;
35 article_here.appendChild(htitle);
38 for (let image of images) {
41 var title = document.createElement('p');
42 title.innerHTML = "<strong>Figure " + image_num + ".</strong> " + image.alt;
43 article_here.appendChild(title);
45 article_here.appendChild(image.cloneNode(false));
47 if (image_num < images.length) {
48 var hr = document.createElement('hr');
49 article_here.appendChild(hr);
55 episode_url = "{{ relative_root_path }}" + lesson_episodes[i];
56 xmlHttp[i].open("GET", episode_url);
57 xmlHttp[i].send(null);
62 Create anchor for each one of the episodes.
64 {% for episode in site.episodes %}
65 <article id="{{ episode.url }}" class="figures"></article>
68 {% include links.md %}