-
Notifications
You must be signed in to change notification settings - Fork 0
/
course-description.html
103 lines (87 loc) · 2.56 KB
/
course-description.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
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
Catalog = require('catalog')
catalog = Catalog.fromLocalStorage();
</script>
<dom-module id = "course-description">
<template>
<style type="text/css">
</style>
<h2>[[name]]</h2>
<strong>[[credit]]</strong>
<p id="description"></p>
<strong>[[gened]]</strong>
<br>
<strong>[[prerequisite]]</strong>
</template>
<script>
Polymer({
is:"course-description",
properties:{
course: {
type: String,
notify: true,
reflectToAttribute: true,
observer: "courseChanged"
},
name: String,
dept: String,
number: String,
description: String,
credit: String,
prerequisite: String,
gened:String
},
ready: function() {
this.courseChanged();
},
courseChanged: function(course){
if (!course)
course = this.course;
var course = Catalog.parseCourseCode(course);
try{
this.dept = course.dept;
this.number = course['number'];
this.name = catalog['courses'][this.dept][this.number]['title'];
// this.description = catalog['courses'][this.dept][this.number]['description'];
this.$.description.innerHTML = catalog['courses'][this.dept][this.number]['description'];
this.$.description.querySelectorAll("a").forEach((a_course, idx, arr) => {
arr[idx].href="#";
a_course.addEventListener("click", (function() {
this.course = a_course.innerText;
}).bind(this));
})
this.credit = 'credit: ' + catalog['courses'][this.dept][this.number]['credit'][0] + " hours";
this.gened = "GenEd: " + catalog['courses'][this.dept][this.number]['requirements']['gened'];
this.prerequisite = "Prerequisites: " + catalog['courses'][this.dept][this.number]['requirements']['depend'];
}
catch(e){
this.name = "Not Applicable";
this.dept = "";
this.number = "";
// this.description = "";
this.$.description.innerHTML = "";
this.credit = "";
this.gened = "";
this.prerequisite = ""
}
}
});
// function(){
// $.ajax({
// type: "POST",
// url: "~/extratedInfo.py",
// data: { param: "CS 440"}
// }).done(function() {
// console.log(data)
// });
//var courseName = document.getElementById("course-course");
//Course = require('catalog')
//console.log(courseName)
//console.log(Course.fromLocalStorage().courses['CS']['126']['description'])
</script>
</dom-module>
</head>
</html>>