attributeName="transform" dur="2s" repeatCount="indefinite" type="rotate" values="0 12 12;360 12 12"/> `; document.querySelector('.flatpickr-calendar').append(calendarLoading); } else { this.calendar.set('enable', allowed); this.calendar.redraw(); } // }) } }, collectFilters() { let alliance = [] if (this.staralliance) alliance.push('SA') if (this.skyteam) alliance.push('ST') if (this.oneworld) alliance.push('OW') const carrierString = Object.keys(this.carrier) .map(key => `${this.carrier[key]}`) .join(',') const countryString = Object.keys(this.selectedCountries) .map(key => `${this.selectedCountries[key]}`) .join(',') const daysString = Object.keys(this.days) .map(key => `${key}`) .join(',') const classesString = Object.keys(this.classes) .map(key => `${key}`) .join(',') const aircraftsString = Object.keys(this.selectedaircrafts) .map(key => `${key}`) .join(',') let data = {} if (!!this.durationFrom) data.durationFrom = this.durationFrom if (!!this.durationTo) data.durationTo = this.durationTo if (!!this.priceFrom) data.priceFrom = this.priceFrom if (!!this.priceTo) data.priceTo = this.priceTo if (!!this.departureFrom) data.timeFrom = this.timeToMinutes(this.departureFrom) if (!!this.departureTo) data.timeTo = this.timeToMinutes(this.departureTo) if (!!this.arrivalFrom) data.arrivalFrom = this.timeToMinutes(this.arrivalFrom) if (!!this.arrivalTo) data.arrivalTo = this.timeToMinutes(this.arrivalTo) if (!!this.lowcost) data.lowcost = 1 if (!!this.businessOnly) data.business_only = 1 if (!!this.from) data.from = this.from if (!!carrierString) data.airlines = carrierString if (!!daysString) data.days = daysString if (!!classesString) data.classes = classesString if (!!countryString) data.countries = countryString if (!!this.distanceFrom) data.distanceFrom = this.distanceFrom if (!!this.distanceTo) data.distanceTo = this.distanceTo // Aircrafts if (!!aircraftsString) data.aircrafts = this.selectedaircrafts data.entityType = this.entityType data.take = this.schedulesOffset; data.selectedDate = this.selectedDate ?? null data.dateMethod = 'month'; data.sorting = this.sortingType console.log(this.sortingDirection) data.sortingDirection = this.sortingDirection if(!this.selectedMonth) { const todayStr = (new Date()).toISOString().slice(0,10); const { dateFrom, dateTo } = this.computeGridRangeForMonth(null, todayStr); data.dateFrom = dateFrom; data.dateTo = dateTo; } else { const todayStr = (new Date()).toISOString().slice(0,10); const { dateFrom, dateTo } = this.computeGridRangeForMonth(this.selectedMonth, todayStr); data.dateFrom = dateFrom; data.dateTo = dateTo; } return data }, showMoreSchedules() { this.schedulesOffset += 50; this.updateFilter(); }, updateFilter(sortAfter = true) { if (!this.isInit) return false const data = this.collectFilters(); let queryString = Object.keys(data).map(key => key + '=' + data[key]).join('&'); this.isLoading = true if (queryString === 'from=' + this.from) this.showAll = true else this.showAll = false if (this.airportRequest) { this.airportRequest.cancel('canceled by new request') } // создаём новый источник отмены this.airportRequest = axios.CancelToken.source() axios.get('/api/airport/' + this.from + '?' + queryString + '&rand=' + Math.random(), { cancelToken: this.airportRequest.token }).then((res) => { this.isLoading = false if (res.data.response) { console.log('updated filter'); this.destinations = Object.values(res.data.response.routes) if(this.entityType === 'departures' || this.entityType === 'arrivals') { this.schedules = res.data.response.schedule.result this.schedulesCount = res.data.response.schedule.total this.updateDatepicker(res, 'updateFilter'); this.date = res.data.response.schedule.firstdate } this.airlines = res.data.response.filters.airlines.result this.countries = res.data.response.filters.countries.result this.airlines.sort((a, b) => (Object.values(this.carrier).includes(a.carrier)) ? -1 : 1) this.countries.sort((a, b) => (Object.values(this.selectedCountries).includes(a.country_code)) ? -1 : 1) this.airlinesToShow = this.airlines.slice(0, this.airlinesToShowCount) this.countriesToShow = this.countries.slice(0, this.countriesToShowCount) this.destCount = Object.values(this.destinations).length window.history.pushState({}, "", this.from + '?' + queryString + '&state=1') this.filters = res.data.response.filters if (parseInt(this.durationFrom) > 0 || parseInt(this.durationTo) > 0) { timeslider.noUiSlider.updateOptions({ range: { min: res.data.response.filters.duration.min_duration, max: res.data.response.filters.duration.max_duration }, start: [this.durationFrom, this.durationTo] }) mobtimeslider.noUiSlider.updateOptions({ range: { min: res.data.response.filters.duration.min_duration, max: res.data.response.filters.duration.max_duration }, start: [this.durationFrom, this.durationTo] }) } if (parseInt(this.distanceFrom) > 0 || parseInt(this.distanceTo) > 0) { mobdistance.noUiSlider.updateOptions({ range: { min: res.data.response.filters.distance.min_distance, max: res.data.response.filters.distance.max_distance }, start: [this.distanceFrom, this.distanceTo] }) } if (parseInt(this.departureFrom) > 0 || parseInt(this.departureTo) > 0) { departure.noUiSlider.updateOptions({ range: { min: res.data.response.filters.timeofday.min_time, max: res.data.response.filters.timeofday.max_time }, start: [this.timeToMinutes(this.departureFrom), this.timeToMinutes(this.departureTo)] }) mobdeparture.noUiSlider.updateOptions({ range: { min: res.data.response.filters.timeofday.min_time, max: res.data.response.filters.timeofday.max_time }, start: [this.timeToMinutes(this.departureFrom), this.timeToMinutes(this.departureTo)] }) } if (parseInt(this.arrivalFrom) > 0 || parseInt(this.arrivalTo) > 0) { mobarrival.noUiSlider.updateOptions({ range: { min: res.data.response.filters.arrival.min_time, max: res.data.response.filters.arrival.max_time }, start: [this.timeToMinutes(this.arrivalFrom), this.timeToMinutes(this.arrivalTo)] }) mobarrival.noUiSlider.updateOptions({ range: { min: res.data.response.filters.arrival.min_time, max: res.data.response.filters.arrival.max_time }, start: [this.timeToMinutes(this.arrivalFrom), this.timeToMinutes(this.arrivalTo)] }) } if (parseInt(this.priceFrom) > 0 || parseInt(this.priceTo) > 0) { mobpriceslider.noUiSlider.updateOptions({ range: { min: 0, max: 420 }, start: [this.priceFrom, this.priceTo] }) } // Aircrafts let ac = res.data.response.filters.aircrafts.result; let acs = []; for (let i = 0; i < ac.length; i++) { acs.push(ac[i].filterValue); } this.activeaircrafts = acs; this.aircraftsToShow = acs; if(sortAfter) this.changeSorting(this.sortingType) // console.log(Object.keys(this.carrier).length) if (Object.keys(this.carrier).length == 0 && this.lowcost) this.destinations = [] } }).catch((error) => { if (axios.isCancel(error)) { console.log('Request canceled', error.message); } else { console.error('Error fetching data:', error); } }); } } }).mount('#vue-app')