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.