Added calendar
This commit is contained in:
49
static/js/calendar.js
Normal file
49
static/js/calendar.js
Normal file
@@ -0,0 +1,49 @@
|
||||
var loadingDiv = document.getElementById('loading');
|
||||
var errorDiv = document.getElementById('error');
|
||||
var resultDiv = document.getElementById('result');
|
||||
const timeout = 10000;
|
||||
var emptyCoursesShown = false;
|
||||
var calendar;
|
||||
|
||||
function getTable() {
|
||||
// Send XHR to totalTable
|
||||
loadingDiv.style.display = "";
|
||||
errorDiv.style.display = "none";
|
||||
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.timeout = timeout;
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState === XMLHttpRequest.DONE) {
|
||||
if (xhr.status === 200) {
|
||||
let events = JSON.parse(xhr.responseText);
|
||||
setData(events);
|
||||
} else {
|
||||
setError();
|
||||
}
|
||||
}
|
||||
};
|
||||
xhr.open('GET', CALENDAR_URL, true);
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
function setData(events) {
|
||||
console.log(events);
|
||||
loadingDiv.style.display = "none";
|
||||
errorDiv.style.display = "none";
|
||||
calendar = new FullCalendar.Calendar(resultDiv, {
|
||||
events: events,
|
||||
defaultView: 'agendaWeek',
|
||||
minTime: "07:00:00",
|
||||
maxTime: "19:00:00",
|
||||
timeZone: 'UTC',
|
||||
});
|
||||
calendar.render();
|
||||
}
|
||||
|
||||
function setError() {
|
||||
loadingDiv.style.display = "none";
|
||||
errorDiv.style.display = "";
|
||||
}
|
||||
|
||||
document.getElementById('tryAgain').addEventListener('click', getTable);
|
||||
getTable();
|
||||
Reference in New Issue
Block a user