PageSourceSearch

https://www.cotraj.ru/wp-content/plugins/measoft/js/scripts.js?ver=3.22

js cotraj.ru collected 2026-10-04 23:56:32 UTC 10,760 bytes, 295 lines download raw bytes

1jQuery(document).ready(function() {
2	
3
4    jQuery('body').on('change', 'input[name="payment_method"]', function (e) {
5
6        jQuery('#payment').block({ message: null });
7
8        jQuery.ajax({
9            type: "POST",
10            url: myajax.url,
11            data: {
12                action		: 'measoft_pay_type_set',
13                paytype     : jQuery('input[name="payment_method"]:checked').val()
14            },
15            success: function(response) {
16                jQuery('#payment').unblock();
17                jQuery('body').trigger('update_checkout');
18            }
19        });
20    });
21
22    jQuery('#calc_shipping_city, #billing_city, #shipping_city').autocomplete({
23        minChars: 2,
24        source: function(term, suggest) {
25            try {
26                searchRequest.abort();
27            } catch (e) {}
28            searchRequest = jQuery.post(myajax.url, {
29                search: term,
30                action: 'ks2008_city_autocomplete'
31            }, function(res) {
32                suggest(res.data);
33            });
34        }
35    });
36
37    jQuery('#billing_address_1, #shipping_address_1').autocomplete({
38        minChars: 2,
39        source: function(term, suggest) {
40            try {
41                searchRequest.abort();
42            } catch (e) {}
43            var town = jQuery('#' + _getCityFieldId()).val();   
44			
45            searchRequest = jQuery.post(myajax.url, {
46                search: term,
47                town: town,
48                action: 'ks2008_adress_autocomplete'
49            }, function(res) {
50                suggest(res.data);
51            });
52        }
53    });
54
55    jQuery('body').on('click', '.ui-menu-item', function() {
56        jQuery(document.body).trigger("update_checkout");
57    });
58
59    function isMeaPickupChecked() { 
60        let result = false;
61
62        if (
63            jQuery('.woocommerce-shipping-methods input[value="KC2008_Pickup_Method"]').is(':checked')
64            ||
65            ((jQuery('.woocommerce-shipping-methods input').length == 1) && (jQuery('.woocommerce-shipping-methods input').val() == 'KC2008_Pickup_Method'))
66        ) {
67            result = true;
68        }
69
70        return result;
71    }
72
73    jQuery('.woocommerce-shipping-methods input').on('change', function() {
74        if (jQuery(this).val() == 'KC2008_Pickup_Method') {
75            jQuery('.ks2008_pvzname, .ks2008_pvzcode,').css('display', 'block');
76        }
77    });
78
79	setInterval(() => { 
80		if (isMeaPickupChecked()) {
81			jQuery('.ks2008_pvzname, .ks2008_pvzcode').css('display', 'block');
82		} 
83	}, 500);
84    
85
86    jQuery(document.body).on("update_checkout", function() {
87		
88        if (isMeaPickupChecked()) {
89            jQuery('.ks2008_pvzname, .ks2008_pvzcode').css('display', 'block');
90        } else {
91            jQuery('.ks2008_pvzname, .ks2008_pvzcode').css('display', 'none');
92        }
93    });
94
95	
96    var billing_city = document.querySelector('#' + _getCityFieldId());
97
98
99
100    if (jQuery('#ks2008_pvz_map_block').length > 0) {
101        if (!ks2008client.weight) {
102            ks2008client.weight = 0.1;
103        }
104
105        if (billing_city.value != '') {
106
107
108            var measoftObject = measoftMap.config({
109                'pvzCodeSelector': '#pvzcode',
110                'mapSearchZoom': 10,
111                'pvzAddressSelector': '#pvzname',
112                'mapBlock': 'ks2008_pvz_map_block',				
113                'townBlock': _getCityFieldId(),
114                'windowFixedPosition': 1,
115                'client_id': ks2008client.id, // Сюда нужно указать код extra курьерской службы
116				'client_code': ks2008client.code,
117                'mapSize': { // Размер карты
118                    'width': ks2008client.map_width,
119                    'height': ks2008client.map_height
120                },
121                'centerCoords': ['55.755814', '37.617635'],
122                'showMapButton': '1',
123                'showMapButtonCaption': ks2008client.choosepickuppoint,
124                'filter': {
125                    'acceptcard': 'YES',
126                    'maxweight': ks2008client.weight
127                },
128                'allowedFilterParams': ['acceptcash', 'acceptcard', 'acceptfitting'],
129				'choicePvzCallback': function(code){
130
131                         var pvzData = measoftMap.getSelectedPvzData();
132
133                         jQuery.post(myajax.url, {
134                              townCode: jQuery('#pvz_towncode').val() || '',
135                              pvzData: pvzData,
136                              townto: jQuery('#' + _getCityFieldId()).val() || '',
137                              action: 'ks2008_recalc'
138                         }, function(resp){
139                              jQuery('body').trigger('update_checkout');
140                         });
141
142                    },
143            }).init();
144        } else {
145            var measoftObject = measoftMap.config({
146                'pvzCodeSelector': '#pvzcode',
147                'mapSearchZoom': 10,
148                'pvzAddressSelector': '#pvzname',
149                'mapBlock': 'ks2008_pvz_map_block',
150				'windowFixedPosition': 1,
151                'client_id': ks2008client.id, // Сюда нужно указать код extra курьерской службы
152				'client_code': ks2008client.code,
153                'mapSize': { // Размер карты
154                    'width': ks2008client.map_width,
155                    'height': ks2008client.map_height
156                },
157                'centerCoords': ['55.755814', '37.617635'],
158                'showMapButton': '1',
159                'showMapButtonCaption': ks2008client.choosepickuppoint,
160                'filter': {
161                    'acceptcard': 'YES',
162                    'maxweight': ks2008client.weight
163                },
164                'allowedFilterParams': ['acceptcash', 'acceptcard', 'acceptfitting'],
165				'choicePvzCallback': function(code){
166				
167
168                         var pvzData = measoftMap.getSelectedPvzData();
169
170                         jQuery.post(myajax.url, {
171                              townCode: jQuery('#pvz_towncode').val() || '',
172                              pvzData: pvzData,
173                              townto: jQuery('#' + _getCityFieldId()).val() || '',
174                              action: 'ks2008_recalc'
175                         }, function(resp){
176                              jQuery('body').trigger('update_checkout');
177                         });
178
179                },
180            }).init();
181        }
182
183        var ks2008_pvz_checkout = jQuery('#ks2008_pvz_checkout');	
184       
185		
186            ks2008_pvz_checkout.css('display', 'block');
187            var ks2008_pvz_map_block = jQuery('#ks2008_pvz_map_block');
188            jQuery('#ks2008_pvz_map_block').remove();
189            jQuery('.ks2008_pvzcode').append(ks2008_pvz_map_block);
190			
191			 
192
193
194        jQuery("#pvzcode").change(function() {
195
196            var $this = jQuery(this);
197
198            if (jQuery("select#pvz_select option[value='" + $this.val() + "']").length > 0) {
199                jQuery("select#pvz_select").val($this.val());
200            } else {
201                setTimeout(function() {
202                    jQuery("select#pvz_select").append('<option value="' + $this.val() + '">' + jQuery('#pvzname').val() + '</option>');
203                    jQuery("select#pvz_select").val($this.val());
204                }, 1000);
205            }
206        });
207    }
208
209    // visual reforming on client side
210    if (document.querySelector('#pvzname_field')) {
211        let pvzcode_field = document.querySelector('#pvzcode_field');
212        let pvzname_field = document.querySelector('#pvzname_field');
213        let pvzname = document.querySelector('#pvzname');
214        let map_block = document.querySelector('#ks2008_pvz_map_block');
215        let reset_btn = document.createElement('div');
216        reset_btn.classList.add('reset_btn');       
217        let resultBlock = document.createElement('div');
218        resultBlock.classList.add('resultBlock');
219        pvzname.setAttribute('readonly', 'true');
220        pvzname.setAttribute('placeholder', '');
221        pvzname_field.insertAdjacentElement('beforeend', resultBlock);
222
223        resultBlock.appendChild(pvzname);
224        resultBlock.appendChild(map_block);
225        resultBlock.appendChild(reset_btn);
226
227        billing_city.addEventListener('change', resetMap);
228
229        reset_btn.addEventListener('click', function() {
230            pvzname.value = '';
231        });
232		
233		
234	
235		
236		
237    }
238
239    function resetMap() {
240        var measoftObject = measoftMap.config({
241            'pvzCodeSelector': '#pvzcode',
242            'mapSearchZoom': 10,
243            'pvzAddressSelector': '#pvzname',
244            'mapBlock': 'ks2008_pvz_map_block',
245			'windowFixedPosition': 1,
246            'townBlock': _getCityFieldId(),
247            'client_id': ks2008client.id, // Сюда нужно указать код extra курьерской службы
248			'client_code': ks2008client.code,
249            'mapSize': { // Размер карты
250                'width': ks2008client.map_width,
251                'height': ks2008client.map_height
252            },
253            'centerCoords': ['55.755814', '37.617635'],
254            'showMapButton': '1',
255            'showMapButtonCaption': ks2008client.choosepickuppoint,
256            'filter': {
257                'acceptcard': 'YES',
258                'maxweight': ks2008client.weight
259            },
260            'allowedFilterParams': ['acceptcash', 'acceptcard', 'acceptfitting'],
261			'choicePvzCallback': function(code){
262					
263
264                         var pvzData = measoftMap.getSelectedPvzData();
265
266                         jQuery.post(myajax.url, {
267                              townCode: jQuery('#pvz_towncode').val() || '',
268                              pvzData: pvzData,
269                              townto: jQuery('#' + _getCityFieldId()).val() || '',
270                              action: 'ks2008_recalc'
271                         }, function(resp){
272                              jQuery('body').trigger('update_checkout');
273                         });
274
275            },
276        }).init();
277    }
278
279    jQuery(document).on('change', '#pvzname', function(){
280        if (isMeaPickupChecked()) {
281            jQuery('#billing_address_1, #shipping_address_1').val(jQuery(this).val());
282        }
283    });
284	
285	function _getCityFieldId(){
286		let result = '';
287		if (jQuery('#billing_city').length){
288			result = 'billing_city';	
289		}else{
290			result = 'shipping_city';
291		}	
292		return result;		
293	}	
294
295});

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.