how to create an event calendar in javascript

Solutions on MaxInterview for how to create an event calendar in javascript by the best coders in the world

showing results for - "how to create an event calendar in javascript"
Niclas
05 Aug 2016
1mobiscroll.settings = {
2    lang: ''
3    theme: 'ios',
4    themeVariant: 'light'
5};
6
7var monthInst,
8    dayInst,
9    popupInst,
10    dateInst,
11    preventSet,
12    allDaySwitch = document.getElementById('allDay'),
13    eventTextInput = document.getElementById('eventText'),
14    eventDescInput = document.getElementById('eventDesc'),
15    now = new Date(),
16    btn = '<button class="mbsc-btn mbsc-btn-outline mbsc-btn-danger md-delete-btn mbsc-ios">Delete</button>',
17    myData = [{
18        start: new Date(now.getFullYear(), now.getMonth(), 8, 13),
19        end: new Date(now.getFullYear(), now.getMonth(), 8, 13, 30),
20        text: 'Lunch @ Butcher\'s' + btn,
21        color: '#26c57d'
22    }, {
23        start: new Date(now.getFullYear(), now.getMonth(), now.getDate(), 15),
24        end: new Date(now.getFullYear(), now.getMonth(), now.getDate(), 16),
25        text: 'General orientation' + btn,
26        color: '#fd966a'
27    }, {
28        start: new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1, 18),
29        end: new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1, 22),
30        text: 'Dexter BD' + btn,
31        color: '#37bbe4'
32    }, {
33        start: new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 10, 30),
34        end: new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 11, 30),
35        text: 'Stakeholder mtg.' + btn,
36        color: '#d00f0f'
37    }];
38
39function navigate(inst, val) {
40    if (inst) {
41        inst.navigate(val);
42    }
43}
44
45dateInst = mobiscroll.range('#eventDate', {
46    controls: ['date', 'time'],
47    dateWheels: '|D M d|',
48    endInput: '#endInput',
49    tabs: false,
50    responsive: {
51        large: {
52            touchUi: false
53        }
54    },
55    cssClass: 'md-add-event-range'
56});
57
58dayInst = mobiscroll.eventcalendar('#demo-add-event-day', {
59    display: 'inline',
60    view: {
61        eventList: { type: 'day' }
62    },
63    data: myData,
64    onPageChange: function (event, inst) {
65        var day = event.firstDay;
66        preventSet = true;
67        navigate(monthInst, day);
68        dateInst.setVal([day, new Date(day.getFullYear(), day.getMonth(), day.getDate(), day.getHours() + 2)], true);
69    },
70    onEventSelect: function (event, inst) {
71        if (event.domEvent.target.classList.contains('md-delete-btn')) {
72            mobiscroll.confirm({
73                title: 'Confirm Deletion',
74                message: 'Are you sure you want to delete this item?',
75                okText: 'Delete',
76                callback: function (res) {
77                    if (res) {
78                        inst.removeEvent([event.event._id]);
79                        monthInst.removeEvent([event.event._id]);
80                        mobiscroll.toast({
81                            message: 'Deleted'
82                        });
83                    }
84                }
85            });
86        }
87    }
88});
89
90monthInst = mobiscroll.eventcalendar('#demo-add-event-month', {
91    display: 'inline',
92    view: {
93        calendar: { type: 'month' }
94    },
95    data: myData,
96    onSetDate: function (event, inst) {
97        if (!preventSet) {
98            var day = event.date;
99            navigate(dayInst, day);
100            dateInst.setVal([day, new Date(day.getFullYear(), day.getMonth(), day.getDate(), day.getHours() + 2)], true);
101        }
102        preventSet = false;
103    }
104});
105
106document
107    .getElementById('allDay')
108    .addEventListener('change', function () {
109        var allDay = this.checked;
110
111        dateInst.option({
112            controls: allDay ? ['date'] : ['date', 'time'],
113            dateWheels: (allDay ? 'MM dd yy' : '|D M d|')
114        });
115    });
116
117popupInst = mobiscroll.popup('#demo-add-event-popup', {
118    display: 'center',
119    cssClass: 'mbsc-no-padding',
120    buttons: [{
121            text: 'Add event',
122            handler: 'set'
123        },
124        'cancel'
125    ],
126    headerText: 'Add new event',
127    onSet: function (event, inst) {
128        var eventDates = dateInst.getVal(),
129            events = {
130                start: eventDates[0],
131                end: eventDates[1],
132                text: (eventTextInput.value || 'New Event') + btn,
133                title: eventTextInput.value || 'New Event',
134                description: eventDescInput.value,
135                allDay: allDaySwitch.checked,
136                free: document.querySelector('input[name="free"]:checked').value == 'true'
137            };
138        monthInst.addEvent(events);
139        dayInst.addEvent(events);
140        eventTextInput.value = '';
141        eventDescInput.value = '';
142        // Navigate the calendar to the new event's start date
143        monthInst.navigate(eventDates[0], true);
144    }
145});
146
147document
148    .getElementById('showAddEventPopup')
149    .addEventListener('click', function () {
150        popupInst.show();
151    }, false);
queries leading to this page
event calendar examplesadd event to calendarcalendar javascriptdemo event calendarjavascript calendar create evencreate the events calendarevent calendar jshow to create event calendar sectiongoogle calendar events on javascript calendarsj events calendarjavascript calendar of eventscanvas create calendar eventhow to create event calendarcalendar with eventsevent calendar javascript codehow we code calendar with event using html using javascriptjavascript add event to calendarevent calendar javascriptadd events to calendar javascriptjavascript calendar add eventshtml add event to calendarhow to add event to calendar jsthe event calendarhow to create an event calendarjavascript calendar events icaljavascript event calendar libraryhow to create event calendar in html using javascriptwho is the calendar in eventscreate calender eventevent js calendar event on calendarnew calendar eventcalender event in htmljavascript calendar eventscreate calendar for eventevents calendar jswork day scheduler html examplehow to add events in calendarcalendar and event detailpure javascript event calendarmake javascript calendaradd event to calendar javascriptscript to create calendar eventsthe events calendar how to usehow to add event to calendarcalendar js add eventjs create event calendarhow we add event to the calendar using htmlhow to add events to a calendar using javascriptcalendar with events javascriptcreate calendar event javascripthow to code calendar event javascript htmljavascript event library with calendarcalendar eventevent calendar websitehow to create an event calendar in javascriptevent calendar funcrtionsjs api add event to calendarevent to calendar javascriptcalendar library with events javascripthow to event calendar htmlevent calendarcalendar eventsjavascript event calendar w3schoolscreate a calendar and add events htmlhow to add event in window calendarhow to make an event calendar in htmlcreate event calendar in javascriptcalendar js add eventdynamic calendar javascriptjs calendar return eventadd event calendaradd event calendar javascript htmljavascript event calendar source codeevent calendarjavascript create event calendarjavascript event mothly calendarjs create calendar eventjavascript calendar create eventhow to make add to calendar link javascriptjavascript create calendar eventhtml calendar with events addevent scheduler weekly calendarjavascript event calendarhow to create calendar of eventshow event calendar html how to generate calendar eventjs calendar eventswhere can i find the events calendar event pagehtml add calendar eventcreate calendar javascripthow to build calendar with event jsbuilding a calendar with javascriptcreate a calendar in javascript and add events into itadd the event calendar to pagehow to add events to javascript calendarcreate working calendar with events javascriptevents calendar examplejavascript code calendarevents on a calendarcreate event dynamically in calendar in javascriptimplement calendar and show events javascripthow to create dynamic event calendar in html and jshtml events calendarevent insert calendar function jshow to use calendar js to make a calendarhow to make calendar jscreate calendar with javascriptevents calendar tutorialcalendar add eventhtml event calendar codecreate a calendar javascriptjavascript calendar with eventshow to add events in calendar using javascripteasy javascript event calendar with codejavascript event calendar tutorialhow to create an events calendarevent calendar html 27create calendar event programmaticallyevents on calendarcalendar with events jshow to add a calendar event manuallyevent in calendar event calendarplugin calendario js add eventhow to create calendar event programmaticallycreate calendar eventhtml working event calendarhtml calendar with events jsmake an event page with calendar htmladd calendar eventevent calendar htmlhow to create a calender eventcalendar new event boxthe events calendar demoadd event to calendar htmladd an events calendar on a website javascriptjavascript event calendarcreate a calendar and add eventsevent calendar demohow to create event calendar in javascriptcalendar of events jshow to add event click in calendarcreate a calendar eventadd a calendar event into your website in javascriptcreate an event calendar websitejavascript scheduler projectgetting events from calendar jsadd event in calendar using js and htmlhow to manage your events in event calendarcreate calendar with events html using javascriptevent calendar wdjavascript calendarthe calendar eventadd calendar with events 22the events calendar 22html event calendarevent calendar pageevent calendar for website htmljavascript calendar event planereasy to use calendar for eventcalendar events javascripthtml calendar with eventscreate event calendarhow to create an event calendar in javascript