6 window.onload = function() {
7 var lesson_episodes = [
8 {% for episode in site.episodes %}
9 "{{ episode.url}}"{% unless forloop.last %},{% endunless %}
12 var xmlHttp = []; /* Required since we are going to query every episode. */
13 for (i=0; i < lesson_episodes.length; i++) {
14 xmlHttp[i] = new XMLHttpRequest();
15 xmlHttp[i].episode = lesson_episodes[i]; /* To enable use this later. */
16 xmlHttp[i].onreadystatechange = function() {
17 if (this.readyState == 4 && this.status == 200) {
18 var article_here = document.getElementById(this.episode);
19 var parser = new DOMParser();
20 var htmlDoc = parser.parseFromString(this.responseText,"text/html");
21 var htmlDocArticle = htmlDoc.getElementsByTagName("article")[0];
22 article_here.innerHTML = htmlDocArticle.innerHTML;
25 episode_url = "{{ page.root }}" + lesson_episodes[i];
26 xmlHttp[i].open("GET", episode_url);
27 xmlHttp[i].send(null);
32 Create anchor for each one of the episodes.
34 {% for episode in site.episodes %}
35 <article id="{{ episode.url }}"></article>