PageSourceSearch

https://www.vauthiermont.fr/assets/controllers/signalement-options…troller-0894a5c4b88906f1b2ba3e8cc80dd637.js

js vauthiermont.fr collected 2026-10-03 01:52:37 UTC 1,833 bytes, 58 lines download raw bytes

1import { Controller } from '@hotwired/stimulus';
2import { errorSwal } from 'swal-utils';
3import { trans } from 'translator';
4
5/* stimulusFetch: 'lazy' */
6export default class extends Controller {
7    static values = {
8        stationSlug: String,
9    }
10    static targets = ['optionReponseAuto', 'loader']
11
12    connect() {
13        this.optionReponseAutoTarget.addEventListener('change', (event) => this.changeOptionReponseAuto(event));
14    }
15
16    changeOptionReponseAuto(event) {
17        const optionReponseAuto = event.target;
18        const newStatus = optionReponseAuto.checked;
19        
20        this.showLoader();
21        const url = Routing.generate('moncompte_station_change_reponse_option', {slug: this.stationSlugValue});
22
23        fetch(url, {
24            method: "POST",
25            headers: {
26                'Content-Type': 'application/json'
27            },
28            body: JSON.stringify({'newStatus': newStatus})
29        })
30            .then(response => {
31                if(response.ok) {
32                    return response;
33                }
34                throw new Error(response.status + " " + response.statusText);
35            })
36            .then((response) => response.json())
37            .then((data) => {
38                this.hideLoader();
39                optionReponseAuto.checked = data.state;
40            })
41            .catch(error => {
42                this.hideLoader();
43                optionReponseAuto.checked = !newStatus;
44                errorSwal(trans('une erreur est survenue'), error)
45            })
46    }
47
48    showLoader() {
49        this.optionReponseAutoTarget.classList.add('d-none');
50        this.loaderTarget.classList.remove('d-none');
51    }
52
53    hideLoader() {
54        this.optionReponseAutoTarget.classList.remove('d-none');
55        this.loaderTarget.classList.add('d-none');
56    }
57
58}

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.