-
Notifications
You must be signed in to change notification settings - Fork 0
/
teacher.html
193 lines (163 loc) · 5.58 KB
/
teacher.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/flatly.css">
<link rel="stylesheet" type="text/css" href="css/fonts/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<script type="text/javascript" src="js/jquery.min.js">
</script>
<script type="text/javascript" src="js/bootstrap.min.js">
</script>
<script type="text/javascript" src="js/script.js">
</script>
<script type="text/javascript" src="https://cdn.firebase.com/js/client/2.4.0/firebase.js">
</script>
<style>
.className1{
border: 1px solid;
padding: 20px;
width: 200px;
text-align: center;
background-color: #07a2e4;
color:#fff;
}
.classContainer {
width: 20%;
display: inline-block;
margin: 4% 5%;
}
</style>
<title>
Template
</title>
<script>
var fb = new Firebase("https://librabooks.firebaseio.com");
var uid;
fb.onAuth(function(authData) {
if(authData) {
uid = authData.uid;
}
else {
window.location = "login.html";
}
});
$(document).ready(function(){
loadClases();
});
function loadClases() {
$.ajax({
type: "GET",
url: "http://libra-vmcool09.c9users.io/users/info?userID="+uid,
success: function(data) {
var classes = JSON.parse(data).classes;
var keys = Object.keys(classes);
for(i=0; i<keys.length; i++) {
var classId = classes[keys[i]];
$.ajax({
type: "GET",
url: "http://libra-vmcool09.c9users.io/classroom/info?classID=" + classId,
success: function(data) {
$("#placeHolder").append('<div class="login classContainer"><h2 class="login-header">'+data.name+'</h2><button onclick="joinClass(\''+classId+'\')" class="block-button">View Class</button></div>');
},
error: function(data) {
alert("That is not a valid class ID!");
},
});
}
},
error: function(data) {
alert("Could not load classes");
},
});
}
var nme;
function info()
{
nme = document.getElementById('className').value;
search(nme);
}
function search(name)
{
$.ajax({
type: "GET",
url: "http://libra-vmcool09.c9users.io/classroom/add?teacherID="+ uid + "&className=" + name,
success: function(json)
{
location.reload();
}
,
error: function(data)
{
alert("Not valid info!");
}
,
}
);
}
</script>
</head>
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<img class="navbar-brand nav-logo" src="img/libra-white.png">
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li><a href="home.html">My Books</a></li>
<li><a href="search.html">Find Books</a></li>
<li><a href="joinClass.html">Join Class</a></li>
<li><a href="classes.html">My Classes</a></li>
</ul>
</div>
</div>
</nav>
<div id="placeHolder" style="text-align: center;"></div>
<div class="container-fluid">
<div class="row">
<div class="col-sm-15 col-sm-offset-3 col-md-1 col-md-offset-0 main">
<div type="button" class="btn btn-info fob" data-toggle="modal" data-target="#myModal">+</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">
×
</span>
</button>
<h4 class="modal-title" id="myModalLabel">
Create a Classroom
</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label class="control-label" for="focusedInput">
Name your classroom
</label>
<input class="form-control" id="className" value="Class name" type="text">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">
Cancel
</button>
<button type="button" onclick="info()" class="btn btn-success">
Create Classroom
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>