-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevents.html
164 lines (135 loc) · 6.59 KB
/
events.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<title>EVENTS</title>
<link rel="stylesheet" href="assets/css/Navigation-Dark-Clean.css">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link rel="stylesheet" href="assets/css/Google-Stylel-Login.css">
<link rel="stylesheet" href="assets/css/calendar.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/main.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/main.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/main.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/main.min.css">
</head>
</head>
<body>
<nav class="navbar navbar-dark navbar-expand-md bg-dark navigation-clean">
<div class="container">
<a class="navbar-brand" href="#">Student Placement System</a>
<button class="navbar-toggler" data-bs-toggle="collapse" data-bs-target="#navcol-1">
<span class="visually-hidden">Toggle navigation</span>
<span class="navbar-toggler-icon"></span>
</button>
<div id="navcol-1" class="collapse navbar-collapse">
<ul class="nav navbar-nav ms-auto">
</ul>
<button id="home" class="btn btn-secondary" type="button" href="home.html">Home</button>
<button id="out" class="btn btn-primary" type="button" href="index.html">Sign Out</button>
</div>
</div>
</nav>
<div class="container">
<div id='calendar'></div>
</div>
<script type="module">
// Import the functions you need from the SDKs you need
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.11/firebase-app.js";
import { getDatabase, ref, child, get, remove, onValue, update } from "https://www.gstatic.com/firebasejs/9.6.11/firebase-database.js";
import { collection, getFirestore, doc, getDocs, setDoc, deleteDoc } from "https://www.gstatic.com/firebasejs/9.6.11/firebase-firestore.js";
import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.6.11/firebase-analytics.js";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
//--------------------------CONFIGURATION----------------------------------------//
const firebaseConfig = {
apiKey: "AIzaSyAZVQZO8XWR0UTPoSMLrRN7nSltUDW9Xzs",
authDomain: "dfmpc-student-placement-system.firebaseapp.com",
databaseURL: "https://dfmpc-student-placement-system-default-rtdb.europe-west1.firebasedatabase.app",
projectId: "dfmpc-student-placement-system",
storageBucket: "dfmpc-student-placement-system.appspot.com",
messagingSenderId: "295214875936",
appId: "1:295214875936:web:546dcdb4f822d1c4c84345",
measurementId: "G-1JPG0HXVWQ"
};
const app = initializeApp(firebaseConfig);
function getData() {
firebaseConfig.da
}
const analytics = getAnalytics(app);
const db = getFirestore(); //firestore
//initialise array and variables to store events information
var start;
var end;
var id;
var events = [];
document.addEventListener('DOMContentLoaded', function () {
//initialise calendar element
var calendarEl = document.getElementById('calendar');
//function that retrieves all events from events table and adds them to events array
async function getEvents()
{
const querySnapshot = await getDocs(collection(db, "events"));
querySnapshot.forEach((doc) => {
name = doc.data().name;
start = doc.data().start_date;
end = doc.data().end_date;
events.push({
title: name,
start: start,
end: end
});
calendar.refetchEvents();
});
}
//call function to populate events array
getEvents();
console.log(events); //log events array to console
//Initialise and create calendar
var calendar = new FullCalendar.Calendar(calendarEl, {
schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source',
initialView: 'dayGridMonth', //initial view is month view
selectable: true, //day can be selected
editable: false, //calendar cannot be edited
headerToolbar: {
left: 'prev,next today, addEvent',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay'
},
customButtons: {
today: {
text: 'Today',
click: function () {
calendar.today(); //this button takes us to today's date. Only works when we are viewing another month, week or day
}
},
addEvent: {
text: 'Add Event',
click: function () {
document.location.href = "add_events.html"; //button takes us to add events form
}
},
},
//function to add schedule events to calendar
events: function(info, successCallback, failureCallback ) {
successCallback(events);
},
});
calendar.render();
});
</script>
<script>
var sign_out = document.getElementById("out");
sign_out.addEventListener("click", function () {
document.location.href = "index.html";
});
var home_element = document.getElementById("home");
home_element.addEventListener("click", function () {
document.location.href = "home.html";
});
</script>
</body>