PageSourceSearch

https://piw.pl/modules/ruch/views/js/cart.js?v=1.249322

js piw.pl collected 2026-10-02 11:07:08 UTC 7,806 bytes, 267 lines download raw bytes

1/**
2 * @author    Marcin Bogdański
3 * @copyright OpenNet 2021
4 * @license   license.txt
5 */
6
7var ruch_wid;
8var ruch_cod;
9var ruch_c;
10var ruch_lpay;
11function start_widget(el, cod, c) {
12    ruch_cod = cod;
13    ruch_c = c;
14    $(el).after(ruch_html);
15	$('#ruch_widget').on('click', function (event) {event.stopPropagation()});
16
17    ruch_wid = new RuchWidget('ruch_widget',
18        {
19            readyCb: on_ready,
20            selectCb: on_select,
21            initialAddress: ruch_initial_address,
22            baseLink: ruch_baseLink,
23            sandbox: ruch_sandbox,
24            showCodFilter: ruch_showCodFilter,
25            showPointTypeFilter: ruch_showPointTypeFilter
26        }
27    );
28    ruch_wid.init();
29}
30
31function testPkt(val) {
32	var id = parseInt(val.substr(0, val.length - 1));
33    if(ruch_serv.indexOf(id) == -1) return true;
34
35	if (!$('#ruch_selpkt').val()) {
36    	if (!!$.prototype.fancybox)
37        	$.fancybox.open([
38                {
39                    type: 'inline',
40                    autoScale: true,
41                    minHeight: 30,
42                    content: '<p class="fancybox-error">' + ruch_msg_nopkt + '</p>'
43                }],
44                {
45                	padding: 0
46                }
47            );
48        else
49        {
50            if (ruch_async_carrier_loaded)
51                alert(ruch_msg_nopkt);
52            else
53            {
54                $('#ruch_validation_message').html('<b style="color: red;">' + ruch_msg_nopkt + '</b>').show();
55            }
56
57        }
58    	return false;
59    }
60
61	if ((ruch_codserv.indexOf(id) != -1) && !ruch_lpay && !ruch_async_carrier_loaded) {
62    	if (!!$.prototype.fancybox)
63        	$.fancybox.open([
64                {
65                    type: 'inline',
66                    autoScale: true,
67                    minHeight: 30,
68                    content: '<p class="fancybox-error">' + ruch_msg_nopayment + '</p>'
69                }],
70                {
71                	padding: 0
72                }
73            );
74        else
75        {
76            if (ruch_async_carrier_loaded)
77                alert(ruch_msg_nopayment);
78            else
79                $('#ruch_validation_message').html('<b style="color: red;">' + ruch_msg_nopayment + '</b>').show();
80        }
81    	return false;
82	}
83
84	if (ruch_tel == '' && !ruch_async_carrier_loaded) {
85    	if (!!$.prototype.fancybox)
86        	$.fancybox.open([
87                {
88                    type: 'inline',
89                    autoScale: true,
90                    minHeight: 30,
91                    content: '<p class="fancybox-error">' + ruch_msg_notel + '</p>'
92                }],
93                {
94                	padding: 0
95                }
96            );
97        else
98        {
99            if (ruch_async_carrier_loaded)
100                alert(ruch_msg_notel);
101            else
102                $('#ruch_validation_message').html('<b style="color: red;">' + ruch_msg_notel + '</b>').show();
103        }
104    	return false;
105	}
106
107	if (!/^\d\d\d\d\d\d\d\d\d$/.test(ruch_tel) && !ruch_async_carrier_loaded) {
108    	if (!!$.prototype.fancybox)
109        	$.fancybox.open([
110                {
111                    type: 'inline',
112                    autoScale: true,
113                    minHeight: 30,
114                    content: '<p class="fancybox-error">' + ruch_msg_btel + '</p>'
115                }],
116                {
117                	padding: 0
118                }
119            );
120        else
121        {
122            if (ruch_async_carrier_loaded)
123                alert(ruch_msg_btel);
124            else
125                $('#ruch_validation_message').html('<b style="color: red;">' + ruch_msg_btel + '</b>').show();
126        }
127    	return false;
128	}
129
130	if (ruch_adr == 0 && !ruch_async_carrier_loaded) {
131    	if (!!$.prototype.fancybox)
132        	$.fancybox.open([
133                {
134                    type: 'inline',
135                    autoScale: true,
136                    minHeight: 30,
137                    content: '<p class="fancybox-error">' + ruch_msg_noadr + '</p>'
138                }],
139                {
140                	padding: 0
141                }
142            );
143        else
144        {
145            if (ruch_async_carrier_loaded)
146                alert(ruch_msg_noadr);
147            else
148                $('#ruch_validation_message').html('<b style="color: red;">' + ruch_msg_noadr + '</b>').show();
149        }
150    	return false;
151	}
152
153    $('#ruch_validation_message').empty();
154	$('#ruch_widget').html();
155	return true;
156}
157
158function on_ready() {
159    ruch_wid.showWidget(
160        ruch_cod,
161        {
162            'R': ruch_c[0],
163            'P': ruch_c[1],
164            'U': ruch_c[2],
165            'A': ruch_c[3]
166        },
167        {
168            'R': 'ruch_' + ruch_cod,
169            'P': 'partner_' + ruch_cod,
170            'U': 'partner_' + ruch_cod,
171            'A': 'orlen_' + ruch_cod
172        }
173    );
174    if (!ruch_display_map_as_popup)
175        set_selected_pkt_from_cache();
176}
177
178function on_select(pkt) {
179    var id, t;
180    if(pkt != null) {
181        id = pkt.id;
182        t = pkt.t;
183        ruch_lpay = pkt.c;
184        cache_selected_pkt(pkt);
185    }
186    else {
187        id = 0;
188        t = '';
189        ruch_lpay = 0;
190    }
191    display_selected_pkt(pkt);
192
193    var d = {token: ruch_token, a: 's', pkt: id, typ: t};
194    var s = $.ajax({
195        url: ruch_ajax_uri,
196        type: 'POST',
197        dataType: "json",
198        contentType: "application/json; charset=utf-8",
199        data: JSON.stringify(d),
200        async: false
201    }).responseText;
202
203    if(pkt != null && ruch_display_map_as_popup) {
204        $('.ruch-widget-map-container-full-screen').unbind('click.ruch-remove-widget-map-container-full-screen');
205        $('.ruch-widget-map-container-full-screen').remove();
206    }
207}
208
209function cache_selected_pkt(pkt) {
210    if(pkt != null) {
211        switch (ruch_check_service(ruch_selector_for_service)) {
212            case 'ruch_serv':
213                sessionStorage.removeItem('ruchSelectedPktSession');
214                sessionStorage.setItem('ruchSelectedPktSession', btoa(unescape(encodeURIComponent(JSON.stringify(pkt)))));
215                break;
216            case 'ruch_codserv':
217                sessionStorage.removeItem('ruchSelectedPktCodSession');
218                sessionStorage.setItem('ruchSelectedPktCodSession', btoa(unescape(encodeURIComponent(JSON.stringify(pkt)))));
219                break;
220        }
221    }
222}
223
224function set_selected_pkt_from_cache() {
225    var sessionValue;
226
227    switch (ruch_check_service(ruch_selector_for_service)) {
228        case 'ruch_serv':
229            sessionValue = sessionStorage.getItem('ruchSelectedPktSession');
230            break;
231        case 'ruch_codserv':
232            sessionValue = sessionStorage.getItem('ruchSelectedPktCodSession');
233            break;
234    }
235
236    if (sessionValue == null) return;
237
238    var selected_pkt = JSON.parse(decodeURIComponent(escape(atob(sessionValue))));
239    if (selected_pkt != null)
240    {
241        ruch_lpay = selected_pkt.c;
242        display_selected_pkt(selected_pkt);
243    }
244}
245
246function display_selected_pkt(pkt) {
247
248    if(pkt != null) {
249        $('#ruch_selpkt').val(pkt.id);
250        $('#ruch_selpkt_desc').html('<b>Wybrany punkt: ' + pkt.a + '</b>');
251        $('#ruch_selpkt_desc').show();
252    }
253    // else $('#ruch_selpkt_desc').html('');
254}
255
256
257function ruch_check_service(selector) {
258    var val = $(selector).val();
259    if(!val) return;
260    var id = parseInt(val.substr(0, val.length - 1));
261    if(ruch_codserv.indexOf(id) != -1) {
262        return 'ruch_codserv'
263    }
264    else if(ruch_serv.indexOf(id) != -1) {
265        return 'ruch_serv'
266    }
267}

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.