PageSourceSearch

https://pinacoteca.org.br/wp-content/plugins/infixs-correios-autom…/js/autofill-address.js?ver=1785937477

js pinacoteca.org.br collected 2026-10-01 12:03:34 UTC 2,207 bytes, 103 lines download raw bytes

1/**
2 * Infixs Correios Automático - Autofill Address JS Modeule Front-End.
3 *
4 * @since   1.0.0
5 */
6
7jQuery(function ($) {
8  /**
9   * Autofill class.
10   */
11  const InfixsCorreiosAutomaticoAutofillAddress = {
12    /**
13     * Initialize actions.
14     */
15    init() {
16      $(document.body).on(
17        "blur",
18        "#billing_postcode",
19        this.autofill.bind(this, "billing")
20      );
21      $(document.body).on(
22        "blur",
23        "#shipping_postcode",
24        this.autofill.bind(this, "shipping")
25      );
26    },
27
28    /**
29     * Autofill address.
30     *
31     * @param {string} field
32     * @param {Event} event
33     *
34     * @return {void}
35     */
36    autofill(field, event) {
37      const target = $(event.target);
38      const postcode = target.val().replace(/\D/g, "");
39
40      if (!postcode) {
41        return;
42      }
43
44      $.ajax({
45        url: woocommerce_params.ajax_url,
46        type: "POST",
47        data: {
48          action: "infixs_correios_automatico_autofill_address",
49          postcode: postcode,
50          nonce: infxsCorreiosAutomatico.nonce,
51        },
52        success: (response) => {
53          if (!response.success) {
54            return;
55          }
56
57          this.fillFields(field, response.data);
58        },
59        error: (error) => {},
60        complete: () => {},
61      });
62    },
63
64    /**
65     * Fill fields.
66     *
67     * @param {string} field
68     * @param {Object} data
69     */
70    fillFields(field, data) {
71      if (data.address) {
72        $("#" + field + "_address_1")
73          .val(data.address)
74          .trigger("change");
75      }
76
77      // Neighborhood
78      if (data.neighborhood) {
79        if ($("#" + field + "_neighborhood").length) {
80          $("#" + field + "_neighborhood")
81            .val(data.neighborhood)
82            .trigger("change");
83        } else {
84          $("#" + field + "_address_2")
85            .val(data.neighborhood)
86            .trigger("change");
87        }
88      }
89
90      // City
91      $("#" + field + "_city")
92        .val(data.city)
93        .trigger("change");
94
95      // State
96      $("#" + field + "_state")
97        .val(data.state)
98        .trigger("change");
99    },
100  };
101
102  InfixsCorreiosAutomaticoAutofillAddress.init();
103});

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.