diff options
author | maxbr <maxbr@mi.fu-berlin.de> | 2016-08-19 17:10:31 +0200 |
---|---|---|
committer | maxbr <maxbr@mi.fu-berlin.de> | 2016-08-19 17:10:31 +0200 |
commit | 79aec84973032e15ae9d36fcbd7d7d42af3283d1 (patch) | |
tree | c02fbd44cd53b0eed105bc648c743b10c62bfeb4 /pharos-dashboard/static/js/booking-calendar.js | |
parent | 639cd5db77064c275253828780c17ae59551d95c (diff) |
Split the dashboard into different apps, add tests
JIRA: RELENG-12
Signed-off-by: maxbr <maxbr@mi.fu-berlin.de>
Diffstat (limited to 'pharos-dashboard/static/js/booking-calendar.js')
-rw-r--r-- | pharos-dashboard/static/js/booking-calendar.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/pharos-dashboard/static/js/booking-calendar.js b/pharos-dashboard/static/js/booking-calendar.js new file mode 100644 index 0000000..f8a9a0f --- /dev/null +++ b/pharos-dashboard/static/js/booking-calendar.js @@ -0,0 +1,36 @@ +function parseCalendarEvents(bookings) { + var events = []; + for (var i = 0; i < bookings.length; i++) { + // convert ISO 8601 timestring to moment, needed for timezone handling + start = moment(bookings[i]['start']); + end = moment(bookings[i]['end']); + event = { + id: bookings[i]['id'], + title: bookings[i]['purpose'], + start: start, + end: end, + }; + events.push(event); + } + return events; +} + +function loadEvents(url) { + $.ajax({ + url: url, + type: 'get', + success: function (data) { + $('#calendar').fullCalendar('addEventSource', parseCalendarEvents(data['bookings'])); + }, + failure: function (data) { + alert('Error loading booking data'); + } + }); +} + +$(document).ready(function () { + $('#calendar').fullCalendar(calendarOptions); + loadEvents(bookings_url); + $('#starttimepicker').datetimepicker(timepickerOptions); + $('#endtimepicker').datetimepicker(timepickerOptions); +});
\ No newline at end of file |