-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhome-teacher.js
35 lines (28 loc) · 1.03 KB
/
home-teacher.js
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
document.addEventListener('DOMContentLoaded',(e)=>{
//generate random id
auth.onAuthStateChanged(user=>{
if(user==null)
window.location.replace("faculty-login.html");
else
console.log(user);
});
function makeid(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
const addBtn= document.getElementById('addClass');
addBtn.addEventListener('click',(e)=>{
e.preventDefault();
const section = document.getElementById('section').value;
const sub= document.getElementById('subject').value;
db.collection('classes').doc(makeid(6)).set({
section: section,
subject: sub
});
});
});