-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
96 lines (83 loc) · 3.28 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>UIUC Prereqs</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cytoscape.min.js"></script>
<script src="https://unpkg.com/[email protected]/klay.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/cytoscape-klay.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/umd/popper.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/cytoscape-popper.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/tippy-bundle.iife.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/tippy.css" />
<link rel="stylesheet" href="https://unpkg.com/[email protected]/themes/light.css" />
<link rel="stylesheet" href="https://unpkg.com/[email protected]/themes/translucent.css" />
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,700;1,500&display=swap" rel="stylesheet">
<style>
html, body {
margin: 0;
height: 100%;
width: 100%;
font-family: Roboto, sans-serif;
}
body {
display: flex;
flex-direction: column;
}
#last-updated {
text-align: right;
margin-right: 20px;
}
#container {
flex: 1;
width: 100%;
}
</style>
</head>
<body>
<div id="container"></div>
<p id="last-updated">Loading...</p>
<script src="common.js"></script>
<script src="cytoscape.js"></script>
<script src="elgrapho.js"></script>
<script>
fetch('./data.json').then(res => res.json()).then(data => {
const term = data['ns2:subject'].parents[0].term[0]['_'];
document.getElementById('last-updated').innerText = `Last Updated For: ${term}`;
const courses = data['ns2:subject']['cascadingCourses'][0]['cascadingCourse'];
const graph = {
nodes: [], // [{ label: 'CS 241', group: 2, name: 'Systems Programming' }]
edges: [], // [{ from: 0, to: 23 }] (0 and 23 are indices from `nodes`)
}
courses.forEach(course => {
const courseName = course['$'].id;
const [_, courseNumber] = courseName.split(' ');
graph.nodes.push({
label: courseName,
group: Number(courseNumber[0]), // first digit of course number
title: course.label[0],
description: course.description[0],
hours: parseInt(course.creditHours[0]),
href: course['$'].href.replace('cisapp/explorer/catalog', 'schedule').slice(0, -4)
});
});
courses.forEach((course, courseIndex) => {
if (course.courseSectionInformation) {
const prereqIndex = course.courseSectionInformation[0].indexOf('Prerequisite:');
if (prereqIndex > -1) {
const prereqInfo = course.courseSectionInformation[0].slice(prereqIndex);
graph.nodes.forEach((prereq, prereqIndex) => {
if (courseIndex !== prereqIndex && prereqInfo.includes(prereq.label)) {
graph.edges.push({ from: prereqIndex, to: courseIndex });
}
});
}
}
});
createCytoScape(graph);
});
</script>
</body>
</html>