# Event Customization (Monthly Event Calendar) | DayPilot Pro for JavaScript Demo

> Read more about [event customization](https://doc.daypilot.org/month/event-customization/) [doc.daypilot.org].

## Links

- Canonical HTML: /demo/month/eventcustomization.html
- Source HTML folder: /demo/month/
- Catalog root: /demo/
- Catalog: /demo/llms.txt

## Source

### Inline demo script 1

```javascript
const dp = new DayPilot.Month("dp", {
            startDate: DayPilot.Date.today(),
            eventHeight: 40,
            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(),
                    text: modal.result
                });
                dp.message("Created");
            },
            contextMenu: new DayPilot.Menu({
                items: [
                    {
                        text: "Edit...",
                        onClick: args => app.editEvent(args.source)
                    },
                    {
                        text: "Delete",
                        onClick: args => {
                            dp.events.remove(args.source);
                            dp.message("Deleted");
                        }
                    }
                ]
            }),
            onBeforeEventRender: args => {
                args.data.backColor = args.data.backColor || "#4a86e8";
                args.data.fontColor = "#ffffff";
                args.data.barColor = DayPilot.ColorUtil.darker(args.data.backColor, 2);
                args.data.borderColor = args.data.barColor;

                args.data.areas = [
                    {
                        right: 10,
                        top: 10,
                        width: 20,
                        height: 20,
                        style: "border-radius: 50%; background-color: #ffffff; color: " + args.data.barColor,
                        symbol: "../icons/daypilot.svg#threedots-h",
                        action: "ContextMenu"
                    }
                ];
            }
        });
        dp.init();


        const app = {
            init() {
                this.loadData();
            },
            async editEvent(event) {
                const form = [
                    {name: "Text", id: "text"}
                ];
                const modal = await DayPilot.Modal.form(form, event.data);
                if (modal.canceled) {
                    return;
                }
                event.text(modal.result.text);
                dp.events.update(event);
                dp.message("Updated");
            },
            loadData() {
                const events = [];
                let start = DayPilot.Date.today().firstDayOfMonth();
                for (let i = 0; i < 15; i++) {
                    const add = Math.floor(Math.random() * 2);
                    start = start.addDays(add);
                    if (start.getDayOfWeek() === 6) {
                        start = start.addDays(2);
                    }
                    if (start.getDayOfWeek() === 0) {
                        start = start.addDays(1);
                    }

                    events.push({
                        start: start,
                        end: start.addDays(1),
                        id: DayPilot.guid(),
                        backColor: app.barColor(i),
                        text: "Event " + (i + 1)
                    });
                }
                dp.update({events});
            },
            barColor(i) {
                const colors = ["#4a86e8", "#6aa84f", "#f1c232", "#e69138"];
                return colors[i % colors.length];
            },
        };
        app.init();
```

