Agent-readable demo data

Title
JavaScript Event Calendar | DayPilot Pro for JavaScript Demo
Tree
DayPilot JavaScript Demo
Catalog root
Default
Description
Read more about the calendar zoom.

Inline demo script 1

const dp = new DayPilot.Calendar("dp", {
            startDate: DayPilot.Date.today(),
            viewType: "Week",
            onTimeRangeSelected: async (args) => {
                const modal = await DayPilot.Modal.prompt("New event name:", "Event");
                dp.clearSelection();
                if (modal.canceled) return;
                dp.events.add({
                    start: args.start,
                    end: args.end,
                    id: DayPilot.guid(),
                    resource: args.resource,
                    text: name
                });
                dp.message("Created");
            },
            zoomLevels: [
                {
                    name: "30min",
                    properties: {
                        cellDuration: 30,
                        cellHeight: 30,
                    },

                },
                {
                    name: "15min",
                    properties:
                    {
                        cellDuration: 15,
                        cellHeight: 20,
                    }
                },
                {
                    name: "10min",
                    properties :{
                        cellDuration: 10,
                        cellHeight: 20,
                    }
                },
            ]
        });
        dp.init();

        const app = {
            init() {
                this.addEventHandlers();
                this.loadEventData();

                app.applyLevel(0);
            },
            addEventHandlers() {
                document.querySelector("#zoomLevel").addEventListener("input", function(ev) {
                    var level = parseInt(this.value);
                    app.applyLevel(level);
                });
            },
            applyLevel(level) {
                document.querySelector("#label").innerText = dp.zoomLevels[level].name;
                dp.zoom.setActive(level);
            },
            loadEventData() {
                const first = DayPilot.Date.today().firstDayOfWeek("en-us").addDays(1);
                const events = [
                    {
                        start: first.addHours(12),
                        end: first.addHours(15),
                        id: DayPilot.guid(),
                        text: "Event 1",
                        barColor: "#3c78d8",
                        barBackColor: "#a4c2f4"
                    },
                    {
                        start: first.addDays(1).addHours(10),
                        end: first.addDays(1).addHours(12),
                        id: DayPilot.guid(),
                        text: "Event 2",
                        barColor: "#6aa84f",
                        barBackColor: "#b6d7a8"
                    },
                    {
                        start: first.addDays(1).addHours(13),
                        end: first.addDays(1).addHours(15),
                        id: DayPilot.guid(),
                        text: "Event 3",
                        barColor: "#f1c232",
                        barBackColor: "#ffe599"
                    },
                    {
                        start: first.addDays(2).addHours(11),
                        end: first.addDays(2).addHours(16),
                        id: DayPilot.guid(),
                        text: "Event 4",
                        barColor: "#cc0000",
                        barBackColor: "#ea9999"
                    },
                ];
                dp.update({events});
            }
        };
        app.init();