// js/CalendarModalView.js class CalendarModalView { constructor(data) { this.modal = ''; if (data.mode !== 'show' && data.mode !== 'new' && data.mode !== 'edit') { throw new Error("unknown mode in CalendarModal's constructor"); } this.data = data; } getView() { switch (this.data.mode) { case 'show': this.makeShowView(); break; case 'new': case 'edit': this.makeEditView(); break; default: throw new Error("unknown mode set in CalendarModal"); } return this.modal; } makeShowView() { if (this.data.mode !== 'show') { throw new Error(''); } if (this.data.all_day) { this.data.end.setDate(this.data.end.getDate() - 1); // jour de fin modifié pour ne pas faire bizarre pour l'utilisateur } this.modal += `
` + this.escapeHtml(this.data.description) + `
`; // allDay un jour if (this.data.all_day && (this.data.start.getTime() === this.data.end.getTime())) { // comparaison des timestamps this.modal += `le ` + this.escapeHtml(this.displayDate(this.data.start)) + `
`; // affichage simplifié évènement d'un jour } // allDay plusieurs jours else if (this.data.all_day) { this.modal += `du ` + this.escapeHtml(this.displayDate(this.data.start)) + `
au ` + this.escapeHtml(this.displayDate(this.data.end)) + `
du ` + this.escapeHtml(this.displayDate(this.data.start)) + `
à ` + this.escapeHtml(this.displayHour(this.data.start)) + `
au ` + this.escapeHtml(this.displayDate(this.data.end)) + `
à ` + this.escapeHtml(this.displayHour(this.data.end)) + `