1 /*****************************************************************************
2 * Copyright (c) 2016 Max Breitenfeldt and others.
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Apache License, Version 2.0
6 * which accompanies this distribution, and is available at
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *****************************************************************************/
11 function parseCalendarEvents(bookings) {
13 for (var i = 0; i < bookings.length; i++) {
14 // convert ISO 8601 timestring to moment, needed for timezone handling
15 start = moment(bookings[i]['start']);
16 end = moment(bookings[i]['end']);
18 installer = bookings[i]['installer__name'];
19 if (installer === null) {
23 scenario = bookings[i]['scenario__name'];
24 if (scenario === null) {
27 title = bookings[i]['purpose'] + ' ' + installer + ' ' + scenario;
30 id: bookings[i]['id'],
40 function loadEvents(url) {
44 success: function (data) {
45 $('#calendar').fullCalendar('addEventSource', parseCalendarEvents(data['bookings']));
47 failure: function (data) {
48 alert('Error loading booking data');
53 $(document).ready(function () {
54 $('#calendar').fullCalendar(calendarOptions);
55 loadEvents(bookings_url);
56 $('#starttimepicker').datetimepicker(timepickerOptions);
57 $('#endtimepicker').datetimepicker(timepickerOptions);