# Hiding Weekends (JavaScript Event Calendar) | DayPilot Pro for JavaScript Demo

> Team planning. Weekends are hidden. Select dates to book time; drag or resize a booking to change it. [Documentation](https://doc.daypilot.org/calendar/business-hours/).

## Links

- Canonical HTML: /demo/calendar/hideweekends.html
- Source HTML folder: /demo/calendar/
- Catalog root: /demo/
- Catalog: /demo/llms.txt

## Source

### Inline demo script 1

```javascript
const app = {
            eventsByPeriod: new Map(),
            elements: {
                status: document.querySelector("#status"),
                period: document.querySelector("#period"),
                previous: document.querySelector("#previous"),
                next: document.querySelector("#next"),
                showWeekends: document.querySelector("#show-weekends"),
                skipNonBusiness: document.querySelector("#skip-nonbusiness")
            },
            init() {
                this.showPeriod();
                this.addEventHandlers();
            },
            addEventHandlers() {
                this.elements.showWeekends.addEventListener("change", () => {
                    this.applyFilters();
                });
                this.elements.skipNonBusiness.addEventListener("change", ev => {
                    dp.update({ eventMoveSkipNonBusiness: ev.target.checked });
                });
                this.elements.previous.addEventListener("click", () => {
                    this.navigate(-1);
                });
                this.elements.next.addEventListener("click", () => {
                    this.navigate(1);
                });
            },
            applyFilters() {
                dp.clearSelection();
                dp.update({ showNonBusiness: this.elements.showWeekends.checked });
            },
            colors: {
                planning: { background: "#edf3fc", border: "#c9d8ed", text: "#294b76", accent: "#5b83bb" },
                design: { background: "#edf7f3", border: "#c5dfd4", text: "#28594c", accent: "#4f9680" },
                research: { background: "#f4f0fa", border: "#dcd0eb", text: "#594171", accent: "#9472b7" },
                delivery: { background: "#fcf5e8", border: "#e9d7b1", text: "#71542a", accent: "#bd944f" },
                support: { background: "#f0f3f6", border: "#d4dce4", text: "#49596c", accent: "#8394a7" }
            },
            eventDetails(data) {
                const start = new DayPilot.Date(data.start);
                const end = new DayPilot.Date(data.end);
                const compact = end.ticks - start.ticks <= 86400000;
                const label = start.toString("MMM d") + " – " + end.addDays(-1).toString("MMM d");
                return { compact, label };
            },
            renderEvent(args) {
                const data = args.data;
                const color = this.colors[data.tags?.category] || this.colors.planning;
                const details = this.eventDetails(data);
                data.cssClass = "booking-card" + (details.compact ? " booking-card-compact" : "");
                data.backColor = color.background;
                data.borderColor = color.border;
                data.fontColor = color.text;
                data.barColor = color.accent;
                data.barBackColor = color.background;
                data.toolTip = data.text + "\n" + details.label;
                let html = '<div class="booking-content">';
                html += '<div class="booking-title">' + DayPilot.Util.escapeHtml(data.text) + '</div>';
                if (!details.compact) {
                    html += '<div class="booking-meta">' + DayPilot.Util.escapeHtml(details.label) + '</div>';
                }
                data.html = html + '</div>';
            },
            exportEvent(args) {
                const data = args.e.data;
                const details = this.eventDetails(data);
                const color = this.colors[data.tags?.category] || this.colors.planning;
                args.text = data.text + (details.compact ? "" : "\n" + details.label);
                args.fontColor = color.text;
                args.fontSize = 12;
            },
            month: DayPilot.Date.today().firstDayOfMonth(),
            events() {
                const monday = this.month.addDays((8 - this.month.dayOfWeek()) % 7);
                const friday = monday.addDays(4);
                const plans = [
                    ["planning", "A", "Sprint planning", 0, 2, "planning"],
                    ["handover", "A", "Website discovery", 4, 2, "research"],
                    ["review", "B", "Design review", 1, 2, "design"],
                    ["followup", "C", "Client follow-up", 7, 2, "delivery"],
                    ["prototype", "B", "Prototype", 7, 4, "design"],
                    ["research", "C", "User interviews", 2, 2, "research"],
                    ["build", "A", "Development", 14, 5, "planning"],
                    ["testing", "B", "Usability sessions", 16, 2, "research"],
                    ["release", "C", "Launch planning", 21, 3, "delivery"],
                    ["brand", "D", "Brand concepts", 0, 3, "design"],
                    ["interface", "D", "Interface design", 7, 3, "design"],
                    ["system", "D", "Design system", 14, 4, "design"],
                    ["handoff", "D", "Asset handoff", 21, 2, "delivery"],
                    ["api-plan", "E", "API planning", 1, 2, "planning"],
                    ["integration", "E", "Integration", 4, 3, "planning"],
                    ["api-build", "E", "API development", 10, 3, "planning"],
                    ["code-review", "E", "Code review", 17, 2, "design"],
                    ["release-prep", "E", "Release prep", 25, 1, "delivery"],
                    ["interviews", "F", "User interviews", 0, 2, "research"],
                    ["journey", "F", "Journey mapping", 3, 2, "research"],
                    ["synthesis", "F", "Research synthesis", 8, 3, "research"],
                    ["feedback", "F", "Prototype feedback", 15, 3, "design"],
                    ["calls", "F", "Follow-up calls", 22, 2, "delivery"],
                    ["architecture", "G", "Architecture", 0, 4, "planning"],
                    ["feature", "G", "Feature build", 7, 5, "planning"],
                    ["quality", "G", "Quality review", 16, 3, "design"],
                    ["release-test", "G", "Release testing", 23, 2, "delivery"],
                    ["content-plan", "H", "Content planning", 1, 3, "planning"],
                    ["copy", "H", "Copywriting", 7, 3, "design"],
                    ["content-review", "H", "Content review", 11, 1, "research"],
                    ["editorial", "H", "Editorial pass", 14, 2, "design"],
                    ["launch-assets", "H", "Launch assets", 21, 4, "delivery"]
                ];
                const events = plans.map(([id, resource, text, offset, days, category]) => {
                    const start = monday.addDays(offset);
                    let end = start;
                    for (let remaining = days; remaining > 0; end = end.addDays(1)) {
                        if (end.dayOfWeek() !== 0 && end.dayOfWeek() !== 6) {
                            remaining--;
                        }
                    }
                    return { id, resource, text, start, end, tags: { category } };
                });
                events.push({
                    id: "weekend",
                    moveSkipNonBusinessDisabled: true,
                    resource: "C",
                    text: "On-call support",
                    start: friday.addDays(1),
                    end: friday.addDays(3),
                    tags: { category: "support" }
                });
                return events;
            },
            changed(action, event) {
                const start = event.start().toString("ddd M/d");
                const end = event.end().addDays(-1).toString("ddd M/d");
                this.elements.status.textContent = `${action}: ${event.text()} · ${start} – ${end}`;
                this.showPeriod();
            },
            showPeriod() {
                this.elements.period.textContent = this.month.toString("MMMM yyyy");
            },
            navigate(months) {
                this.eventsByPeriod.set(this.month.toString(), dp.events.list);
                this.month = this.month.addMonths(months);
                const events = this.eventsByPeriod.get(this.month.toString()) || this.events();
                dp.clearSelection();
                dp.update({startDate: this.month, days: this.month.daysInMonth(), events});
                dp.scrollToY(0);
                this.showPeriod();
            }
        };
        const dp = new DayPilot.Calendar("dp", {
            startDate: app.month,
            days: app.month.daysInMonth(),
            viewType: "Resources",
            scale: "Day",
            heightSpec: "Fixed",
            height: 520,
            cellHeight: 44,
            hourWidth: 95,
            businessBeginsHour: 0,
            businessEndsHour: 24,
            useEventBoxes: "Always",
            eventBorderRadius: 5,
            columnMarginLeft: 2,
            columnMarginRight: 4,
            eventMoveSkipNonBusiness: true,
            columns: [
                { id: "A", name: "Alex Morgan" }, { id: "B", name: "Blair Chen" },
                { id: "C", name: "Casey Patel" }, { id: "D", name: "Dana Brooks" },
                { id: "E", name: "Ellis Reed" }, { id: "F", name: "Frankie Park" },
                { id: "G", name: "Jordan Lee" }, { id: "H", name: "Taylor Kim" }
            ],
            events: app.events(),
            showNonBusiness: false,
            timeHeaders: [{ groupBy: "Cell", format: "ddd M/d", width: 95 }],
            onBeforeEventRender: args => app.renderEvent(args),
            onBeforeEventExport: args => app.exportEvent(args),
            onTimeRangeSelected: async (args) => {
                const modal = await DayPilot.Modal.prompt("New booking:", "Booking");
                dp.clearSelection();
                if (modal.canceled || !modal.result) {
                    return;
                }
                const event = new DayPilot.Event({
                    id: DayPilot.guid(),
                    resource: args.resource,
                    text: modal.result,
                    start: args.start,
                    end: args.end,
                    backColor: "#d9eaf7"
                });
                dp.events.add(event);
                app.changed("Created", event);
            },
            onEventMoved: args => app.changed("Moved", args.e),
            onEventResized: args => app.changed("Resized", args.e)
        });
        dp.init();
        app.init();
```

