-
Notifications
You must be signed in to change notification settings - Fork 0
/
Database.html
121 lines (93 loc) · 3.41 KB
/
Database.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>DataBase homeWork</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="https://www.w3schools.com/w3css/4/w3.css" />
<script src="Database.js"></script>
</head>
<body>
<form>
Select your query:
<select id="mySelect" onchange="choosen()">
</select>
<br><br>
<input type="text" id="inputData" value="">
<br>
<br><br>
<input type="button" onclick="show()" value="Get the query">
</form>
<p id="myData"></p>
</body>
<script>
let ar = [
"A random student"
, "Number of students above a given GPA",
"Courses taken by a given student",
"Exam schedule for a given student",
"Student list taking a given course",
"Course list for a given exam room",
"Total number of courses in a given room",
"One more query of your choice"]
ar.forEach(opt => {
let option = document.createElement("option");
option.text = opt;
document.getElementById("mySelect").add(option);
});
// document.getElementById('inum').type = 'number';
function choosen() {
let selectNo = document.getElementById("mySelect").selectedIndex;
if (selectNo == 0 || selectNo == 7) {
document.getElementById("inputData").style.display = 'none';
}
if (1 <= selectNo && selectNo < 4) {
document.getElementById("inputData").style.display = 'block';
document.getElementById("inputData").type = 'number';
}
if (4 <= selectNo && selectNo < 7) {
document.getElementById("inputData").style.display = 'block';
document.getElementById("inputData").type = 'text';
}
}
this.choosen();
function show() {
let selectNo = document.getElementById("mySelect").selectedIndex;
let p = document.getElementById("myData");
let given = document.getElementById("inputData").value;
switch (selectNo) {
case 0:
p.innerText = db.getRandomStudent();
break;
case 1:
p.innerText = db.getAboveGPA(given).size;
break;
case 2:
p.innerText = db.getStudentCourse(given);
break;
case 3:
p.innerText = Array.from(db.examStudent(given)).join('\n')
break;
case 4:
p.innerText = Array.from(db.getStudentByCourse(given)).join('\n')
break;
case 5:
p.innerText = Array.from(db.roomCourse(given)).join('\n')
break;
case 6:
p.innerText = db.roomCourse(given).size;
break;
case 7:
// return stumap -> show only GPA and letter.
let temp=""
for (let s of db.stumap.values()) {
temp +=s.name+"\t" +s.letter+"\n"
}
p.innerText = temp
break;
}
};
// this.hideInputs();
</script>
</html>