PageSourceSearch

https://carental.ru/js/scripts.js

js carental.ru collected 2026-10-08 09:32:17 UTC 3,488 bytes, 110 lines download raw bytes

1  var alertFocus = null;
2
3$(document).ready(function(){
4
5  var screen_res = screen.width + 'x' + screen.height;
6  $.cookie('screen_res', screen_res, { expires: 7, path: '/' });
7
8  // Modern Splide Carousel
9  var carouselSlider = null;
10  var carouselResizeTimer = null;
11
12  function initOrUpdateCarousel() {
13    var carouselElement = document.getElementById('car-carousel');
14    if (!carouselElement) {
15      return;
16    }
17
18    // Destroy existing instance if any
19    if (carouselSlider) {
20      carouselSlider.destroy();
21      carouselSlider = null;
22    }
23
24    // Initialize Splide
25    var Splide = window.Splide;
26    if (typeof Splide !== 'undefined') {
27      carouselSlider = new Splide('#car-carousel', {
28        type: 'loop',
29        perPage: 5,
30        perMove: 1,
31        gap: 15,
32        autoplay: true,
33        interval: 5000,
34        pauseOnHover: true,
35        arrows: true,
36        pagination: false,
37        breakpoints: {
38          1100: { perPage: 4 },
39          900: { perPage: 3 },
40          640: { perPage: 2, arrows: false },
41          480: { perPage: 1, arrows: false }
42        }
43      }).mount();
44    }
45  }
46
47  // Splide is loaded via <script defer> before this file; init immediately.
48  initOrUpdateCarousel();
49
50  // Reinitialize on resize (debounced)
51  $(window).on('resize orientationchange', function() {
52    clearTimeout(carouselResizeTimer);
53    carouselResizeTimer = setTimeout(initOrUpdateCarousel, 200);
54  });
55
56  $('.bxslider').bxSlider({
57    pagerCustom: '#bx-pager',
58    mode: 'fade',
59    adaptiveHeight: false,  // Fixed height prevents CLS
60    controls: false
61  });
62
63  try {
64    jQuery('input[placeholder], textarea[placeholder]').placeholder();
65  } catch(e) {}
66
67  jQuery('#fast_order').on('click', function() {
68    var fio = jQuery('input[name=fio]');
69    var valid = true;
70    alertFocus = null;
71    if (fio.val().length < 3) { alertMsg('Укажите ваши Ф.И.О.'); alertFocus = fio; valid = false; }
72    var email = jQuery('input[name=email]');
73    var phone = jQuery('input[name=phone]');
74    if (valid == true && email.val().length < 10 && phone.val().length < 5) { alertMsg('Укажите телефон или email'); alertFocus = phone; valid = false; }
75    var msg = jQuery('textarea[name=msg]');
76    if (valid == true && msg.val().length < 6) { alertMsg('Укажите сообщение'); alertFocus = msg; valid = false; }
77    if (valid == true) jQuery('#form_fast_order').attr('ac' + 'tion', '/feed'+'back/fast'+'_order');
78    return valid;
79  });
80
81  $('#price_no_driver th').click(function(){
82    var table = $(this).parents('table').eq(0);
83    var rows = table.find('tr:gt(0)').toArray().sort(comparer($(this).index()));
84    this.asc = !this.asc;
85    $('#price_no_driver th').css('backgroundImage', 'url("/img/sort/unsorted.gif")');
86    if (!this.asc) {
87      rows = rows.reverse();
88      $(this).css('backgroundImage', 'url("/img/sort/asc.gif")');
89    } else {
90      $(this).css('backgroundImage', 'url("/img/sort/desc.gif")');
91    }
92    for (var i = 0; i < rows.length; i++) table.append(rows[i]);
93  })
94
95
96});
97
98  function alertMsg(msg) {
99    alert(msg);
100    if (alertFocus != null) alertFocus.focus();
101  }
102
103  function comparer(index) {
104    return function(a, b) {
105        var valA = getCellValue(a, index), valB = getCellValue(b, index);
106        return $.isNumeric(valA) && $.isNumeric(valB) ? valA - valB : valA.localeCompare(valB)
107    }
108  }
109
110  function getCellValue(row, index){ return $(row).children('td').eq(index).text() }

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.