PageSourceSearch

https://www.dambenois.fr/_assets/31ae96d5c887550ddcb216502f61eb80/JavaScript/QualityWidget.js?1758111854

js dambenois.fr collected 2026-10-03 02:47:05 UTC 3,463 bytes, 100 lines download raw bytes

1/*jshint esversion: 6 */
2(function (global) {
3    "use strict";
4    function QualityWidget(args) {
5        this.args = args;
6        this.widget = $(this.args.selector);
7        this.hcaptcha = null;
8        this.hcaptchaToken = null;
9        this.bindForm();
10
11        return this;
12    }
13
14    QualityWidget.prototype.bindForm = function () {
15        let $this = this;
16        let form = this.widget.find('form');
17
18        let input = form.find('input');
19        let submit = form.find('input[type="submit"]');
20        this.hcaptcha = form.find('div.h-captcha');
21
22
23        let comment = $('#comment');
24        let commentTxt = $('#comment_txt');
25        let showCommentZone = $('#show_comment_zone');
26        let loader = $('#quality_loader');
27
28        form[0].reset();
29
30        input.on('change', function (e) {
31            e.preventDefault();
32            submit.prop('disabled', false).removeClass('is-hidden');
33            $this.hcaptcha.removeClass('is-hidden');
34
35            let checkedInput = form.find('input[value]:checked');
36
37            if (checkedInput.val() === 'Oui') {
38                commentTxt.prop('disabled', true).prop('required', false);
39                comment.addClass('is-hidden');
40                showCommentZone.attr('aria-expanded', 'false');
41            }
42
43            if (checkedInput.val() === 'Non') {
44                commentTxt.prop('disabled', false).prop('required', true);
45                comment.removeClass('is-hidden');
46                showCommentZone.attr('aria-expanded', 'true');
47            }
48        });
49
50        form.on('submit', function (e) {
51            e.preventDefault();
52            form.find("input[name='tx_cimquality_displayquality[hcaptchaTokenResponse]']").val(form.find('textarea[name="h-captcha-response"]').val());
53            loader.removeClass('display_none');
54            $this.submit(form);
55        });
56    };
57
58    QualityWidget.prototype.submit = function (form) {
59        let $this = this;
60        let url = this.widget.attr('data-url');
61        let successMessage = this.widget.attr('data-success-message');
62        let errorMessage = this.widget.attr('data-error-message');
63        this.hcaptchaToken = this.widget.find('textarea[name="h-captcha-response"]').val();
64
65        if(true || this.hcaptchaToken !== '' && $this.hcaptcha.length !== 0)
66        {
67            $.ajax({
68                method: 'POST',
69                url: url,
70                cache: false,
71                data: form.serialize(),
72                success: function (result) {
73                    let message;
74                    if(result.success) {
75                        message = successMessage;
76                    } else {
77                        message = errorMessage;
78                    }
79                    $this.widget.parent().prop('tabindex', -1).html("<p>" + message + "</p>");
80                    $this.widget.parent().focus();
81                },
82                error: function (jqXHR, textStatus, errorThrow) {
83                    console.log(jqXHR, textStatus, errorThrow);
84                    $this.widget.parent().prop('tabindex', -1).html("<p>" + errorMessage + "</p>");
85                    $this.widget.parent().focus();
86                }
87            });
88        }else{
89            $this.hcaptcha.append('<p>Merci de remplir ce champ !</p>')
90        }
91
92    };
93
94    let qualityWidget = function (args) {
95        return new QualityWidget(args);
96    };
97
98    global.qualityWidget = qualityWidget;
99
100}(this));

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.