-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
107 lines (86 loc) · 3.86 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/main.css" type="text/css" media="screen, print"></link>
<title>W20 Course</title>
</head>
<body>
<script>
var lecdata = {};
function drawTable() {
var html = "";
html += "<table class=\"\">" +
"<tbody>";
var formatTitle = function(s) {
return "<a class='toc' target=\"w20win\" href='" + s["slide-url"] + "'>" + s.title + "</a>";
}
for (var i = 0; i < lecdata.lectures.length; i++) {
html += "<tr>";
html += "<td style='vertical-align: top'><b>" + (i + 1) + ".</b></td><td><b>" + lecdata.lectures[i].title +
"</b> <span style='font-size: 11px;'>[" +
"<a target=\"w20win\" href=\"" + lecdata.lectures[i]["slide-url"] + "\">HTML</a>, <a target=\"w20win\" href=\"" +
"pdf/" + lecdata.lectures[i]["slide-url"].replace(/.html.*$/, "-2p.pdf") + "\">PDF-2</a>, <a target=\"w20win\" href=\"" +
"pdf/" + lecdata.lectures[i]["slide-url"].replace(/.html.*$/, "-1p.pdf") + "\">PDF-1</a>]<br/><span class='toc'>";
var sections1 = lecdata.lectures[i].sections;
for (var j = 0; j < sections1.length; j++) {
html += formatTitle(sections1[j]) + (sections1[j].sections.length > 0 ? "" : (j == sections1.length - 1 ? "" : ", "));
var sections2 = sections1[j].sections;
if (sections2.length > 0) {
html += " (";
for (var k = 0; k < sections2.length; k++) {
html += formatTitle(sections2[k]) + (k == sections2.length - 1 ? "" : ", ");
}
html += ")" + (j == sections1.length - 1 ? "" : ", ");
}
}
html += "</span></td>";
html += "</tr>";
}
html += "</tbody>";
html += "</table>"
var e = document.getElementById("course-toc");
e.innerHTML = html;
}
function setLastModified() {
var mind = 0;
for (i = 0; i < lecdata.lectures.length; i++) {
var d = new Date(lecdata.lectures[i].lastModified);
if (d > mind)
mind = d;
}
var e = document.getElementById("lastModified");
e.innerHTML = "last modified: " + mind;
}
var handler = function() {
if (this.readyState == 4 && this.status == 200) {
lecdata = JSON.parse(this.responseText);
drawTable(lecdata);
setLastModified(lecdata)
}
};
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = handler;
xhr.open("GET", "toc.json");
xhr.send();
</script>
<style>
.center {
margin: auto;
width: 800px;
padding: 10px;
}
#lastModified {
margin-top: 11px;
font-size: 12px;
color: #444444;
}
</style>
<div class="container center">
<h1 id="web-20-course-slides">Web 2.0 Course Content</h1>
<div id="course-toc"></div>
<div id="lastModified"></div>
</div>
</body>
</html>