1import { toYMD } from '../../../common/scripts/utility/date.js'; 2export class ReservationFormController { 3 #form; 4 /** 5 * ãã§ãã¯ã¤ã³ãã£ã¼ã«ã 6 */ 7 #checkin; 8 /** 9 * ãã§ãã¯ã¤ã³ã®é ããã£ã¼ã«ãï¼ãµã¼ãã¼éä¿¡ç¨ï¼ 10 */ 11 #checkinHidden; 12 /** 13 * ãã§ãã¯ã¢ã¦ããã£ã¼ã«ã 14 */ 15 #checkout; 16 /** 17 * ãã§ãã¯ã¢ã¦ãã®é ããã£ã¼ã«ãï¼ãµã¼ãã¼éä¿¡ç¨ï¼ 18 */ 19 #checkoutHidden; 20 /** 21 * åä¾ã®äººæ°ãã£ã¼ã«ã 22 */ 23 #children; 24 /** 25 * åä¾ã®äººæ°ã®é ããã£ã¼ã«ãï¼ãµã¼ãã¼éä¿¡ç¨ï¼ 26 */ 27 #childrenHidden; 28 /** 29 * @constructor 30 * @param form 宿æ³äºç´ãã©ã¼ã 31 */ 32 constructor(form) { 33 this.#form = form; 34 this.#checkin = this.#form.querySelector('.fn-reservation-form__checkin'); 35 this.#checkinHidden = this.#form.querySelector('.fn-reservation-form__checkinHidden'); 36 this.#checkout = this.#form.querySelector('.fn-reservation-form__checkout'); 37 this.#checkoutHidden = this.#form.querySelector('.fn-reservation-form__checkoutHidden'); 38 this.#children = this.#form.querySelector('.fn-reservation-form__children'); 39 this.#childrenHidden = this.#form.querySelector('.fn-reservation-form__childrenHidden'); 40 } 41 init() { 42 this.#bindEvents(); 43 this.#setTodayDates(); 44 } 45 /** 46 * ç¾å¨æ¥ä»ã®åæ 47 */ 48 #setTodayDates() { 49 if (!this.#checkin || !this.#checkout) { 50 return; 51 } 52 const today = new Date(); 53 const tomorrow = new Date(today); 54 tomorrow.setDate(today.getDate() + 1); 55 const todayStr = toYMD(today); 56 const tomorrowStr = toYMD(tomorrow); 57 this.#checkin.value = todayStr; 58 this.#checkout.value = tomorrowStr; 59 // NOTE: å ¥åå¯è½ãªæå°æ¥ä»ãè¨å® 60 this.#checkin.min = todayStr; 61 this.#checkout.min = tomorrowStr; 62 } 63 /** 64 * ã¤ãã³ãç»é² 65 */ 66 #bindEvents() { 67 this.#form.addEventListener('formdata', (event) => { 68 if (!this.#checkin || !this.#checkout) { 69 return; 70 } 71 const checkinDate = new Date(this.#checkin.value); 72 const checkoutDate = new Date(this.#checkout.value); 73 event.formData.set('checkin', toYMD(checkinDate, '/')); 74 event.formData.set('checkout', toYMD(checkoutDate, '/')); 75 event.formData.set('kids_tiers', `[{"code":"D","children":${this.#children?.value || '0'}}]`); 76 }); 77 } 78} 79(() => { 80 const forms = document.querySelectorAll('.js-reservation-form'); 81 if (forms.length === 0) { 82 return; 83 } 84 for (const form of forms) { 85 const reservationFormController = new ReservationFormController(form); 86 reservationFormController.init(); 87 } 88})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.