-
Notifications
You must be signed in to change notification settings - Fork 0
/
cw4.html
57 lines (40 loc) · 1.3 KB
/
cw4.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Course</title>
</head>
<body>
<h1>Course</h1>
<p>Course Name:
<input type="text" onchange="findCourse(value)">
</p>
<div id=doki></div>
<script>
let courses = []
fetch("https://maeyler.github.io/JS/data/Courses.txt").then(r => r.text()).then(str => str.split('\n'))
.then(lines => {
lines.forEach(line => {
blocks = line.split('\t')
courses.push(new Course(blocks[0], blocks[1], blocks[2], blocks.slice(3)))
});
})
class Course {
constructor(name, time, date, room) {
this.name = name
this.time = time
this.date = date
this.room = room
}
}
function findCourse(name) {
name = name.toUpperCase()
courses.forEach(c => {
if (c.name == name) doki.innerText = "Name: "+c.name + "\n" +"Time: "+ c.time + "\n" +"Date: "+ c.date + "\n" +"Room: "+ c.room.toString()
});
}
</script>
</body>
</html>