import { Controller } from '@hotwired/stimulus'; /* * The following line makes this controller "lazy": it won't be downloaded until needed * See https://github.com/symfony/stimulus-bridge#lazy-controllers */ /* stimulusFetch: 'lazy' */ export default class extends Controller { static values = { tmdbId: String, imdbId: String, season: String, episode: String, active: Boolean, }; static targets = ['list', 'count'] static outlets = ['loading-icon'] options = [] connect() { if (true === this.activeValue) { fetch(`/torrentio/tvshows/${this.tmdbIdValue}/${this.imdbIdValue}/${this.seasonValue}/${this.episodeValue}`) .then(res => res.text()) .then(response => { this.element.innerHTML = response; this.options = this.element.querySelectorAll('tbody tr'); this.loadingIconOutlet.increaseCount(); }); } } toggleList() { this.listTarget.classList.toggle('hidden'); } }