PageSourceSearch

https://taxi-avtosfera.ru/modules/mod_taxi_call/mod_taxi_call.js

js taxi-avtosfera.ru collected 2026-10-06 11:04:09 UTC 22,953 bytes, 627 lines download raw bytes

1var myMap2, myPlacemark2, address_type, autocenter, saveAddress, saveCoords, orderDelay, confirm,
2hours, hours_top, active_hour, minutes, minutes_top, active_minute;
3
4jQuery(function()
5{
6    function tData(dplus)
7    {
8        var s;
9        var t   = new Date();
10        var y   = t.getFullYear();
11        var d   = t.getDate()+dplus;
12        var mon = t.getMonth();
13
14        switch (mon)
15        {
16            case 0:     s = 'января';     break;
17            case 1:     s = 'февраля';    break;
18            case 2:     s = 'марта';      break;
19            case 3:     s = 'апреля';     break;
20            case 4:     s = 'мая';        break;
21            case 5:     s = 'июня';       break;
22            case 6:     s = 'июля';       break;
23            case 7:     s = 'августа';    break;
24            case 8:     s = 'сентября';   break;
25            case 9:     s = 'октября';    break;
26            case 10:    s = 'ноября';     break;
27            case 11:    s = 'декабря';    break;
28        }
29
30        return  d + ' ' + s + ' ' + y;
31    }
32
33    // счётчик-время вверх
34    jQuery('.slide-block .top').click(function()
35    {
36        lastli = jQuery(this).parent('.slide-block').find('ul li.active');
37        
38        if (lastli.prev('li').length > 0)
39        {
40            /* */
41            if (jQuery('#datepicker').val() == today)
42            {
43                var click_num = jQuery(this).parent('.slide-block').find('ul').attr('num');
44                var hash = 0;
45                
46                if (click_num == '1')
47                {
48                    // уменьшают часы
49                    hash = parseInt(lastli.prev('li').html().replace(/D/g, '')) * 60 + parseInt(jQuery('.selecttime:eq(1)').find('li.active').html().replace(/D/g, ''));
50                }
51                else
52                {
53                    // уменьшают минуты
54                    hash = parseInt(jQuery('.selecttime:eq(0)').find('li.active').html().replace(/D/g, '')) * 60 + parseInt(lastli.prev('li').html().replace(/D/g, ''));
55                }
56                
57                //console.log(hash);
58                
59                if (hash < parseInt(jQuery('input[name="abc123"]').val()))
60                {
61                    return false;
62                }
63            }
64            /* */
65            
66            var newtop = parseInt(lastli.parent('ul').css('top'));
67            lastli.parent('ul').animate({top: (newtop+25)},100);
68            lastli.prev('li').addClass('active');
69            var time = lastli.prev('li').html();
70            lastli.removeClass('active');
71            jQuery(this).parent('.slide-block').find('input').val(time);
72        }
73    });
74    
75    // счётчик-время вниз
76    jQuery('.slide-block .bottom').click(function()
77    {
78        lastli = jQuery(this).parent('.slide-block').find('ul li.active');
79        
80        if (lastli.next('li').length > 0)
81        {
82            var newtop = parseInt(lastli.parent('ul').css('top'));
83            lastli.parent('ul').animate({top: (newtop-25)},100);
84            lastli.next('li').addClass('active');
85            var time = lastli.next('li').html();
86            lastli.removeClass('active');
87            jQuery(this).parent('.slide-block').find('input').val(time);
88        }
89    });
90    
91    jQuery('.today').html('(сегодня ' + tData(0) + ')');
92    jQuery('#datepicker').val(unprettyDate(tData(0)));
93    
94    jQuery('.when .now').click(function(e)
95    {
96        e.preventDefault();
97        
98        setLimits();
99        
100        jQuery('#datepicker').val(unprettyDate(tData(0)));
101        jQuery(this).addClass('active');
102        jQuery('.when .tomorow').removeClass('active');
103        jQuery('.show-date').removeClass('active');
104        jQuery('.today').html('(сегодня '+tData(0)+')');        
105	});
106    
107    jQuery('.when .tomorow').click(function(e)
108    {
109        e.preventDefault();
110        jQuery('#datepicker').val(unprettyDate(tData(1)));
111        jQuery(this).addClass('active');
112        jQuery('.when .now').removeClass('active');
113        jQuery('.show-date').removeClass('active');
114        jQuery('.today').html('(завтра '+tData(1)+')');       
115	});
116    
117    jQuery('#datepicker').datepicker({ dateFormat: 'yy-mm-dd', firstDay: 1, onSelect: function(date) {jQuery('.today').html('(дата: ' + prettyDate(date) + ')'); if (jQuery('#datepicker').val() == today){ setLimits(); } }});
118    //jQuery('#datepicker').datepicker({ dateFormat: "dd MM yy" , onSelect: function(date) {jQuery('.today').html('(дата: '+date+')');}});
119    
120    jQuery('.show-date').click(function(e){
121        e.preventDefault();
122        jQuery('#datepicker').datepicker('show');
123        jQuery('.when .tomorow').removeClass('active');
124        jQuery('.when .now').removeClass('active');
125        jQuery(this).addClass('active');
126        
127	});
128    
129    jQuery('#form form input[type="submit"]').click(function(e) {
130        e.preventDefault();
131                
132        if (jQuery('input[name="from_string"]').val() && !jQuery('input[name="from[region]"]').val()) {
133            orderDelay = 1;
134            address_type = 'from';
135            getResult(jQuery('input[name="from_string"]').val());
136        }
137        else if (jQuery('input[name="to_string"]').val() && !jQuery('input[name="to[region]"]').val()) {
138            orderDelay = 1;
139            address_type = 'to';
140            getResult(jQuery('input[name="to_string"]').val());
141        } else {
142            var regexp = /^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{7,10}$/;
143            var phone_val = jQuery('input[name="phone"]').val();
144            
145            if (!regexp.test(phone_val)) {
146                alert('Некорректный телефон');
147                return false;
148            }
149            
150            var from_string = jQuery('input[name="from_string"]').val();
151            if (!from_string) {
152                alert('Откуда едем-то ?');
153                return false;
154            }
155            
156            var to_string = jQuery('input[name="to_string"]').val();
157            if (!to_string) {
158                alert('Куда едем-то ?');
159                return false;
160            }
161            
162            var from_region_val = jQuery('input[name="from[region]"]').val();
163            var from_city_val = jQuery('input[name="from[city]"]').val();
164            
165            if (!from_region_val || !from_city_val) {
166                alert('Некорректный адрес подачи');
167                return false;
168            }
169            
170            var to_region_val = jQuery('input[name="to[region]"]').val();
171            var to_city_val = jQuery('input[name="to[city]"]').val();
172            
173            if (!to_region_val || !to_city_val) {
174                alert('Некорректный адрес назначения');
175                return false;
176            }
177            
178            var notes_val = jQuery('textarea[name="notes"]').val();
179            
180            var from_street_val = jQuery('input[name="from[street]"]').val();
181            var from_house_val  = jQuery('input[name="from[house]"]').val();
182            
183            if (!from_street_val && !from_house_val && !notes_val) {
184                alert('Уточните адрес подачи на карте или в комментариях к заказу');
185                return false;
186            }
187            
188            var to_street_val = jQuery('input[name="to[street]"]').val();
189            var to_house_val  = jQuery('input[name="to[house]"]').val();
190            
191            if (!to_street_val && !to_house_val && !notes_val) {
192                alert('Уточните адрес назначения на карте или в комментариях к заказу');
193                return false;
194            }
195            
196            if (checkChaspik() && !confirm) {
197                /* уведомлялка о часпике */
198                showMessage('<p id="notice_text">' + jQuery('#time_notice').html() + '</p><div class="notice_action button red" id="unconfirm_notice">отказываюсь</div><div class="notice_action button green" id="confirm_notice">согласен</div>');
199                return false;
200            }
201            
202            confirm = 0;
203
204            var data = jQuery('#form form').serialize();
205            //console.log(data); return false;
206            
207            text = 'Идёт отправка заказа, подождите..';
208            
209            if (jQuery('.km-message').size()) {
210                jQuery('.km-message').html(text);
211            } else {
212                showMessage(text);
213            }
214            
215            jQuery.ajax({
216                type: 'get',
217                url: URI_ROOT+'/modules/mod_taxi_call/add_call.php',
218                data: data,
219                success: function(result) {
220                    if (result == '1') {
221                        jQuery('#form form .inputbox').val('');
222                        result = 'Ваш заказ принят. Оператор свяжется с Вами в ближайшее время. Спасибо, что выбрали нас.';
223                    }
224                    
225                    jQuery('.km-message').html(result).delay(4000).fadeOut(500, function(){jQuery('.km-message').remove()});
226                }
227            });
228        }    
229        
230        return false;
231    });
232    
233    jQuery('#unconfirm_notice').live('click', function() {
234        jQuery('.km-message').html('').hide('fast', function(){ jQuery('.km-message').remove() });
235    });
236    
237    jQuery('#confirm_notice').live('click', function() {
238        confirm = 1;
239        jQuery('#form form .button').trigger('click');
240    });
241    
242    jQuery('input[name="from_string"]').blur(function() {
243        if (!jQuery(this).val() || jQuery('input[name="from[region]"]').val()) {
244            return false;
245        }
246        
247        address_type = 'from';
248        saveAddress = 0;
249        saveCoords = 1;
250        
251        getResult(jQuery(this).val());
252    });
253    
254    jQuery('input[name="from_string"]').keyup(function() {
255        jQuery('input[name^="from["]').val('');
256    });
257    
258    jQuery('input[name="to_string"]').blur(function() {
259        if (!jQuery(this).val() || jQuery('input[name="to[region]"]').val())
260        {
261            return false;
262        }
263        
264        address_type = 'to';
265        saveAddress = 0;
266        saveCoords = 1;
267        
268        getResult(jQuery(this).val());
269    });
270    
271    jQuery('input[name="to_string"]').keyup(function() {
272        jQuery('input[name^="to["]').val('');
273    });
274
275    jQuery('.onmap').click(function() {
276        address_type = jQuery(this).attr('type');
277        
278        if (!myMap2) {
279            // инициализация карты
280            myMap2 = new ymaps.Map('order_map',
281            {
282                center: [55.991567,37.214793],
283                zoom: 12
284            });
285            
286            myMap2.controls.add('mapTools').add('typeSelector').add('scaleLine').add('zoomControl');
287            myMap2.behaviors.enable('scrollZoom');
288            
289            myMap2.events.add('click', function (e)
290            {                
291                /* очистим сегменты старого адреса */
292                jQuery('input[name="' + address_type + '_string"]').val('');
293                jQuery('input[name^="' + address_type + '["]').val('');
294                /* */
295                
296                coordinates = e.get('coords');
297                                
298                autocenter = 0;
299                createPlacemark(coordinates);
300                
301                coordinates_string = coordinates.join(',');
302                jQuery('input[name="' + address_type + '[coordinates]"]').val(coordinates_string);
303                
304                saveAddress = 1;
305                saveCoords = 0;
306                
307                getResult(coordinates_string);
308            });
309        }
310        
311        address = jQuery('input[name="' + address_type + '_string"]').val();
312        
313        if (address) {
314            coordinates = jQuery('input[name="' + address_type + '[coordinates]"]').val();
315            
316            if (coordinates) {
317                coordinates = coordinates.split(',');
318                autocenter = 1;
319                createPlacemark([parseFloat(coordinates[0]), parseFloat(coordinates[1])]);
320            } else {
321                jQuery.ajax({
322                    url: 'http://geocode-maps.yandex.ru/1.x/?callback=onmapResult',
323                    dataType: 'jsonp',
324                    data: {'geocode' : address, 'results' : 1, 'format' : 'json'}
325                });
326            }
327        }
328        else if (myPlacemark2) {
329            myMap2.geoObjects.remove(myPlacemark2);
330        }
331        
332        // показываем карту пользователю
333        jQuery('#order_map_container').fadeIn();
334    });
335    
336    jQuery('#order_map_container .close').click(function() {
337        jQuery('#order_map_container').hide();
338    });
339    
340    hours = jQuery('ul[class="selecttime"][num="1"]');
341    hours_top = hours.css('top');
342    active_hour = hours.find('li.active');
343    
344    minutes = jQuery('ul[class="selecttime"][num="2"]');
345    minutes_top = minutes.css('top');
346    active_minute = minutes.find('li.active');
347});
348
349function onmapResult(answer) {
350    if (answer.response.GeoObjectCollection.featureMember.length && answer.response.GeoObjectCollection.featureMember[0].GeoObject.metaDataProperty.GeocoderMetaData.AddressDetails.Country.CountryNameCode == 'RU') {
351        // ставим метку на карте
352        coordinates = answer.response.GeoObjectCollection.featureMember[0].GeoObject.Point.pos.split(' ');
353
354        jQuery('input[name="' + address_type + '[coordinates]"]').val(coordinates[1] + ',' + coordinates[0]);
355        autocenter = 1;
356        createPlacemark([parseFloat(coordinates[1]), parseFloat(coordinates[0])]);
357    }
358}
359
360function setLimits() {
361    jQuery('ul[class="selecttime"][num="1"]').css('top', hours_top);
362    jQuery('ul[class="selecttime"][num="2"]').css('top', minutes_top);
363    
364    jQuery('.selecttime li.active').removeClass('active');
365    active_hour.addClass('active');
366    active_minute.addClass('active');
367}
368
369function showMessage(message) {
370	jQuery('.km-message').remove();
371	jQuery('body').append('<div class="km-message">' + message + '</div>');
372    jQuery('.km-message').fadeIn(500);
373}
374
375function getResult(geocode) {
376    jQuery.ajax({
377        url: 'http://geocode-maps.yandex.ru/1.x/?callback=getResult2',
378        dataType: 'jsonp',
379        data: {'geocode' : geocode, 'sco' : 'latlong', 'results' : 1, 'format' : 'json'}
380    });
381}
382
383function getResult2(answer) {
384    if (!answer.response.GeoObjectCollection.featureMember.length) {
385        return;
386    }
387
388    var address_details = answer.response.GeoObjectCollection.featureMember[0].GeoObject.metaDataProperty.GeocoderMetaData.AddressDetails;
389    console.log(address_details);
390
391    if (address_details.Country.CountryNameCode != 'RU') {
392        alert('Адрес '+geocode+' находится не в России..');
393        return;
394    }
395
396    if (!('AdministrativeArea' in address_details.Country)) {
397        return false;
398    }
399
400    area = address_details.Country.AdministrativeArea;
401    if (!('AdministrativeAreaName' in area)) {
402        return false;
403    }
404
405    region = area.AdministrativeAreaName;
406    jQuery('input[name="'+address_type+'[region]"]').val(region);
407
408    city     = '';
409    district = '';
410    street   = '';
411    house    = '';
412
413    if ('SubAdministrativeArea' in area) {
414        area = area.SubAdministrativeArea;
415        if (!('Locality' in area)) {
416            return false;
417        }
418        if ('LocalityName' in area.Locality) {
419            city = area.Locality.LocalityName;  
420        } else {
421            city = area.SubAdministrativeAreaName;
422        }
423        if ('Thoroughfare' in area.Locality) {
424            street = area.Locality.Thoroughfare.ThoroughfareName;
425            if ('Premise' in area.Locality.Thoroughfare) {
426                house = area.Locality.Thoroughfare.Premise.PremiseNumber;
427            }
428        } else if ('Premise' in area.Locality) {
429            house = area.Locality.Premise.PremiseNumber;
430        }
431    } else {
432        if (!('Locality' in area)) {
433            return false;
434        }
435        if ('LocalityName' in area.Locality) {
436            city = area.Locality.LocalityName;  
437        } else {
438            city = region;
439        }
440        if ('DependentLocality' in area.Locality) {
441            if ('DependentLocalityName' in area.Locality.DependentLocality) {
442                district = area.Locality.DependentLocality.DependentLocalityName;
443            }
444            if ('Premise' in area.Locality.DependentLocality) {
445                house = area.Locality.DependentLocality.Premise.PremiseName;
446            }
447            if ('Thoroughfare' in area.Locality.DependentLocality) {
448                street = area.Locality.DependentLocality.Thoroughfare.ThoroughfareName;
449                if ('Premise' in area.Locality.DependentLocality.Thoroughfare) {
450                    house = area.Locality.DependentLocality.Thoroughfare.Premise.PremiseNumber;
451                }
452            }
453        } else {                
454            if ('Thoroughfare' in area.Locality) {
455                street = area.Locality.Thoroughfare.ThoroughfareName;
456                if ('Premise' in area.Locality.Thoroughfare) {
457                    house = area.Locality.Thoroughfare.Premise.PremiseNumber;
458                }
459            } else if ('Premise' in area.Locality) {
460                house = area.Locality.Premise.PremiseNumber;
461            }
462        }
463    }
464
465    address = [];
466    if (city) {
467        jQuery('input[name="'+address_type+'[city]"]').val(city);
468        address.push(city);
469    }
470    if (district) {
471        jQuery('input[name="'+address_type+'[district]"]').val(district);
472        address.push(district);
473    }
474    if (street) {
475        jQuery('input[name="'+address_type+'[street]"]').val(street);
476        address.push(street);
477    }
478    if (house) {
479        jQuery('input[name="'+address_type+'[house]"]').val(house);
480        address.push(house);
481    }
482
483    if (saveAddress) {
484        address = address.join(', ');
485        jQuery('input[name="'+address_type+'_string"]').val(address);
486        myPlacemark2.properties.set('iconContent', address);
487    }
488
489    if (saveCoords) {
490        coordinates = answer.response.GeoObjectCollection.featureMember[0].GeoObject.Point.pos.split(' ');
491        jQuery('input[name="'+address_type+'[coordinates]"]').val(coordinates[1]+','+coordinates[0]);
492    }
493
494    if (orderDelay) {
495        jQuery('#form form .button').trigger('click');
496    }
497}
498
499function createPlacemark(coorditanes) {
500    if (myPlacemark2) {
501        myMap2.geoObjects.remove(myPlacemark2);
502    }
503
504    myPlacemark2 = new ymaps.Placemark(coorditanes, {
505        'iconContent' : jQuery('input[name="' + address_type + '_string"]').val()
506    },
507    {
508        preset: 'twirl#blueStretchyIcon',
509        draggable : true
510    });
511    
512    myPlacemark2.events.add('dragend', function(e) {
513        /* очистим сегменты старого адреса */
514        jQuery('input[name="' + address_type + '_string"]').val('');
515        jQuery('input[name^="' + address_type + '["]').val('');
516        /* */
517        
518        coordinates = e.get('target').geometry.getCoordinates();
519        
520        coordinates_string = coordinates.join(',');
521        jQuery('input[name="' + address_type + '[coordinates]"]').val(coordinates_string);
522        
523        saveAddress = 1;
524        saveCoords = 0;
525        
526        getResult(coordinates_string);
527    });
528    
529    myMap2.geoObjects.add(myPlacemark2);
530    
531    if (autocenter) {
532        myMap2.setCenter(coorditanes);  
533    }   
534}
535
536function getLog (variable, prefix) {
537    depth  = 10;
538    result = '';
539                 
540    for (k in variable) {
541        result += prefix + ' ' + k + ': ' + variable[k] + "\r\n";
542        
543        if (variable[k] && typeof variable[k] === 'object' && prefix.length < depth - 1) {
544            result += getLog (variable[k], prefix += '-');
545        }
546    }
547    
548    return result;
549}
550
551function prettyDate(unprettyDate) {
552    var date = unprettyDate.split('-');
553    
554    switch (parseInt(date[1])) {
555        case 1:  date[1] = 'января';   break;
556        case 2:  date[1] = 'февраля';  break;
557        case 3:  date[1] = 'марта';    break;
558        case 4:  date[1] = 'апреля';   break;
559        case 5:  date[1] = 'мая';      break;
560        case 6:  date[1] = 'июня';     break;
561        case 7:  date[1] = 'июля';     break;
562        case 8:  date[1] = 'августа';  break;
563        case 9:  date[1] = 'сентября'; break;
564        case 10: date[1] = 'октября';  break;
565        case 11: date[1] = 'ноября';   break;
566        case 12: date[1] = 'декабря';  break;
567    }
568    
569    if (date[2].charAt(0) == '0') {
570        date[2] = date[2].charAt(1);
571    }
572    
573    return date[2] + ' ' + date[1] + ' ' + date[0];
574}
575
576function unprettyDate(prettyDate) {
577    var date = prettyDate.split(' ');
578    
579    switch (date[1]) {
580        case 'января':   date[1] = '01';  break;
581        case 'февраля':  date[1] = '02';  break;
582        case 'марта':    date[1] = '03';  break;
583        case 'апреля':   date[1] = '04';  break;
584        case 'мая':      date[1] = '05';  break;
585        case 'июня':     date[1] = '06';  break;
586        case 'июля':     date[1] = '07';  break;
587        case 'августа':  date[1] = '08';  break;
588        case 'сентября': date[1] = '09';  break;
589        case 'октября':  date[1] = '10';  break;
590        case 'ноября':   date[1] = '11';  break;
591        case 'декабря':  date[1] = '12';  break;
592    }
593    
594    if (date[0].length == 1) {
595        date[0] = '0' + date[0];
596    }
597    
598    return date[2] + '-' + date[1] + '-' + date[0];
599}
600
601function checkChaspik() {
602    date = jQuery('#datepicker').val().split('-');
603    
604    date[1] = parseInt(date[1]) - 1;
605    date[2] = parseInt(date[2]);
606    
607    dayWeek = new Date(date[0], date[1], date[2]).getDay();
608    
609    if (!dayWeek) {
610        dayWeek = 1;
611    }
612    
613    var selected_time = parseInt(jQuery('.selecttime:eq(0)').find('li.active').html().replace(/D/g, '')) * 60 + parseInt(jQuery('.selecttime:eq(1)').find('li.active').html().replace(/D/g, ''));
614    
615    var chaspik = jQuery('input[name="chaspik[' + dayWeek + ']"]').val().split(';');
616    var notice  = 0;
617    
618    for (i=0; i<chaspik.length; i++) {
619        hours = chaspik[i].split('-');
620        
621        if (selected_time >= (hours[0] * 60) && selected_time <= (hours[1] * 60)) {
622            notice = 1;
623        }
624    }
625    
626    return notice;
627}

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.