PageSourceSearch

https://www.ecoreseau.fr/wp-content/plugins/memberpress/js/mpvat.js?ver=7.1.2

js ecoreseau.fr collected 2026-10-01 11:35:54 UTC 3,407 bytes, 104 lines download raw bytes

1(function($) {
2  const mepr_ssl_geoip_services = {
3    caseproof: {
4      url:    'https://cspf-locate.herokuapp.com?callback=?',
5      cindex: 'country_code',
6      sindex: 'region_code',
7      used:   false,
8      type:   'jsonp', // Eventually move to CORS to prevent blocking
9    }
10  }
11
12  class GeoLocation {
13    constructor() {
14      this.country = '';
15      this.state = '';
16    }
17
18    // Calls the geoip service to get the location.
19    // Updates dropdowns and mepr-geo-country hidden field
20    locate() {
21      let source_key = 'caseproof';
22      let source = mepr_ssl_geoip_services[source_key];
23
24      $.ajax({
25        url: source.url,
26        method: 'GET',
27        timeout: 2000,
28        dataType: source.type,
29      })
30      .done (function(data) {
31        if(data[source.cindex] !== undefined) this.country = data[source.cindex];
32        if(data[source.sindex] !== undefined) this.state   = data[source.sindex];
33
34        // Method resides in i18njs
35        mepr_set_locate_inputs(this.country, this.state);
36      });
37
38      return false;
39    }
40  }
41
42  $(document).ready(function($) {
43    new GeoLocation().locate();
44
45    var mepr_show_vat_number = function(form) {
46      if ($.inArray(form.find('select[name="mepr-address-country"]').val(),MpVat.countries) >= 0) {
47        form.find('.mepr_vat_customer_type_row').slideDown();
48        if (form.find('.mepr_vat_customer_type-consumer').is(':checked')) {
49          form.find('.mepr_vat_number_row').slideUp();
50        }
51        else if (form.find('.mepr_vat_customer_type-business').is(':checked')) {
52          form.find('.mepr_vat_number_row').slideDown();
53        }
54
55        var tmpDate = new Date();
56
57        if (
58          MpVat.should_apply_gb_brexit_rule
59          && form.find('select[name="mepr-address-country"]').val() !== 'GB'
60          && MpVat.vat_country === 'GB'
61          && tmpDate.getFullYear() > 2020
62        ) {
63          form.find('.mepr_vat_customer_type_row').slideUp();
64          form.find('.mepr_vat_number_row').slideUp();
65        }
66      }
67      else {
68        form.find('.mepr_vat_customer_type_row').slideUp();
69        form.find('.mepr_vat_number_row').slideUp();
70      }
71    };
72
73    $.each($('.mepr-countries-dropdown'), function(i,obj) {
74      var form = $(obj).closest('.mepr-form');
75      mepr_show_vat_number(form);
76    });
77
78    $('.mepr_vat_customer_type-consumer, .mepr_vat_customer_type-business').on('click', function(e) {
79      var form = $(this).closest('.mepr-form');
80      mepr_show_vat_number(form);
81    });
82
83    $('.mepr-countries-dropdown').on('change mepr-geolocated', function(e) {
84      var form = $(this).closest('.mepr-form');
85      mepr_show_vat_number(form);
86    });
87
88    $('.mepr-form input[name="mepr_vat_number"]').on('mepr-validate-input', function (e) {
89      var form = $(this).closest('.mepr-form');
90
91      var country = form.find('select[name="mepr-address-country"]').val();
92      var is_business = form.find('.mepr_vat_customer_type-business').is(':checked');
93      var vat_number = form.find('input[name="mepr_vat_number"]').val();
94
95      vat_number = vat_number.replace(/[-.●]/g,'');
96
97      var invalid = ($.inArray(country,MpVat.countries) >= 0 &&
98                     is_business && vat_number.length > 0 &&
99                     !vat_number.match(new RegExp('^'+MpVat.rates[country].fmt+'$'), 'i'));
100
101      mpToggleFieldValidation($(this), !invalid);
102    });
103  });
104})(jQuery);

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.