Agent-readable demo data
- Title
- Green CSS Theme (Open-Source JavaScript Monthly Event Calendar) | DayPilot Lite for JavaScript Demo
- Tree
- DayPilot JavaScript Demo
- Catalog root
- Lite
- Description
- A green CSS theme.
You can customize the Green Theme in DayPilot Theme Designer.
Inline demo script 1
const dp = new DayPilot.Month("dp", {
theme: "month_green",
startDate: "2027-08-01",
onTimeRangeSelected: (args) => app.createEvent(args),
onEventClicked: function (args) {
DayPilot.Modal.alert(DayPilot.Util.escapeHtml("clicked: " + args.e.id()));
},
onBeforeEventRender: args => {
args.data.areas = [
{
right: 2,
top: 2,
width: 20,
height: 20,
padding: 2,
symbol: "../icons/daypilot.svg#x-2",
onClick: args => {
dp.events.remove(args.source);
}
}
];
}
});
const app = {
async createEvent(args) {
const modal = await DayPilot.Modal.prompt("New event name:", "Event");
const name = modal.canceled ? null : modal.result;
dp.clearSelection();
if (!name) {
return;
}
const e = new DayPilot.Event({
start: args.start,
end: args.end,
id: DayPilot.guid(),
text: name
});
dp.events.add(e);
},
loadData() {
for (let i = 0; i < 10; i++) {
const duration = Math.floor(Math.random() * 1.2);
const start = Math.floor(Math.random() * 6) - 3; // -3 to 2
const e = new DayPilot.Event({
start: new DayPilot.Date("2027-08-04T00:00:00").addDays(start),
end: new DayPilot.Date("2027-08-04T12:00:00").addDays(start).addDays(duration),
id: DayPilot.guid(),
text: "Event " + i
});
dp.events.add(e);
}
},
init() {
this.loadData();
dp.init();
}
};
app.init();