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) { 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 (!/^(\+48|48|)\d{9}$/.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 181 display_selected_pkt(pkt); 182 ajax_selected_pkt(pkt); 183 184 if(pkt != null && ruch_display_map_as_popup) { 185 $('.ruch-widget-map-container-full-screen').unbind('click.ruch-remove-widget-map-container-full-screen'); 186 $('.ruch-widget-map-container-full-screen').remove(); 187 } 188} 189 190function ajax_selected_pkt(pkt) { 191 if(pkt != null) { 192 id = pkt.id; 193 t = pkt.t; 194 ruch_lpay = pkt.c;
195 cache_selected_pkt(pkt); 196 } 197 else { 198 id = 0; 199 t = ''; 200 ruch_lpay = 0; 201 } 202 203 var d = {token: ruch_token, a: 's', pkt: id, typ: t}; 204 var s = $.ajax({ 205 url: ruch_ajax_uri, 206 type: 'POST', 207 dataType: "json", 208 contentType: "application/json; charset=utf-8", 209 data: JSON.stringify(d), 210 async: false 211 }).responseText; 212} 213 214function cache_selected_pkt(pkt) { 215 if(pkt != null) { 216 switch (ruch_check_service(ruch_selector_for_service)) { 217 case 'ruch_serv': 218 sessionStorage.removeItem('ruchSelectedPktSession'); 219 sessionStorage.setItem('ruchSelectedPktSession', btoa(unescape(encodeURIComponent(JSON.stringify(pkt))))); 220 break; 221 case 'ruch_codserv': 222 sessionStorage.removeItem('ruchSelectedPktCodSession'); 223 sessionStorage.setItem('ruchSelectedPktCodSession', btoa(unescape(encodeURIComponent(JSON.stringify(pkt))))); 224 break; 225 } 226 } 227} 228 229function set_selected_pkt_from_cache() { 230 var sessionValue; 231 232 switch (ruch_check_service(ruch_selector_for_service)) { 233 case 'ruch_serv': 234 sessionValue = sessionStorage.getItem('ruchSelectedPktSession'); 235 break; 236 case 'ruch_codserv': 237 sessionValue = sessionStorage.getItem('ruchSelectedPktCodSession'); 238 break; 239 } 240 241 if (sessionValue == null) return; 242 243 var selected_pkt = JSON.parse(decodeURIComponent(escape(atob(sessionValue)))); 244 if (selected_pkt != null) 245 { 246 ruch_lpay = selected_pkt.c;
247 display_selected_pkt(selected_pkt); 248 ajax_selected_pkt(selected_pkt); 249 } 250} 251 252function display_selected_pkt(pkt) { 253 254 if(pkt != null) { 255 ruch_selpkt = pkt.id; 256 $('#ruch_selpkt_desc').html('<b>Wybrany punkt: ' + pkt.a + '</b>'); 257 $('#ruch_selpkt_desc').show(); 258 } 259} 260 261 262function ruch_check_service(selector) { 263 var val = $(selector).val(); 264 if(!val) return; 265 var id = parseInt(val.substr(0, val.length - 1)); 266 if(ruch_codserv.indexOf(id) != -1) { 267 return 'ruch_codserv' 268 } 269 else if(ruch_serv.indexOf(id) != -1) { 270 return 'ruch_serv' 271 } 272}
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.