PageSourceSearch

https://www.tvsmotor.com/assets/HomePage/js/script.js?=17-09-26-3

js tvsmotor.com collected 2026-09-24 09:16:37 UTC 21,479 bytes, 579 lines download raw bytes

1$(window).resize(function (e) {
2    815 >= $(window).width() ? $("body").attr("class", "mobile") : $("body").attr("class", "desktop")
3}).resize(),
4    function (e) {
5        e("body").hasClass("desktop") ? e(".asideBrandList").length && e(".vehiclesHome .leve2 .asideBrandList").mCustomScrollbar() : e(".asideBrandList").length && e(".vehiclesHome .leve2 .asideBrandList").mCustomScrollbar("destroy"), t = function (t, i) {
6            e("." + t).slick(i)
7        };
8        var t, i, a = {
9            infinite: !1,
10            slidesToShow: 3,
11            arrows: !0,
12            lazyLoad: "ondemand"
13        };
14        (i = function (t, i) {
15            e("#" + t).slick(i)
16        })("hero-slider", e.extend({}, a, {
17            infinite: !0,
18            slidesToShow: 1,
19            dots: !0,
20            arrows: !0,
21            autoplay: !1,
22            autoplaySpeed: 5e3,
23            pauseOnHover: !1
24        })), $(".slide3Col").on("init", function (e, t) {
25            0 === t.currentSlide && $(".slide3Col .slick-prev").hide()
26        }), t("slide3Col", e.extend({}, a, {
27            arrows: !0,
28            slidesToScroll: 3,
29            responsive: [{
30                breakpoint: 815,
31                settings: {
32                    infinite: !0,
33                    slidesToShow: 2,
34                    arrows: !1,
35                    centerMode: !0,
36                    centerPadding: "30px"
37                }
38            }, {
39                breakpoint: 480,
40                settings: {
41                    infinite: !0,
42                    slidesToShow: 1,
43                    arrows: !1,
44                    centerMode: !0,
45                    centerPadding: "30px"
46                }
47            }, {
48                breakpoint: 1365,
49                settings: {
50                    infinite: !0,
51                    slidesToShow: 3,
52                    slidesToScroll: 1,
53                    arrows: !1,
54                    centerMode: !0,
55                    centerPadding: "20px"
56                }
57            }, {
58                breakpoint: 1400,
59                settings: {
60                    infinite: !0,
61                    slidesToShow: 4,
62                    slidesToScroll: 4,
63                    arrows: !0,
64                    centerMode: !0,
65                    centerPadding: "20px"
66                }
67            },]
68        })), $(".slide3Col").on("afterChange", function (e, t, i) {
69            let a = t.slideCount,
70                o = a % 3;
71            o > 0 ? a -= o : a -= 3, i === a ? $(".slide3Col .slick-next").hide() : 0 === i ? $(".slide3Col .slick-prev").hide() : ($(".slide3Col .slick-prev").show(), $(".slide3Col .slick-next").show())
72        }), t("slide4Col", e.extend({}, a, {
73            slidesToShow: 3,
74            arrows: !0,
75            centerPadding: "30px",
76            responsive: [{
77                breakpoint: 815,
78                settings: {
79                    infinite: !0,
80                    slidesToShow: 2,
81                    arrows: !1,
82                    centerMode: !0,
83                    centerPadding: "30px"
84                }
85            }, {
86                breakpoint: 480,
87                settings: {
88                    infinite: !0,
89                    slidesToShow: 1,
90                    arrows: !1,
91                    centerMode: !0,
92                    centerPadding: "30px"
93                }
94            },]
95        })), e(".dealerVehicleCate").slick({
96            centerMode: !0,
97            centerPadding: "0",
98            slidesToShow: 4,
99            focusOnSelect: !0,
100            arrows: !1,
101            dots: !1,
102            responsive: [{
103                breakpoint: 815,
104                settings: {
105                    centerPadding: "25px",
106                    slidesToShow: 1
107                }
108            }]
109        }), t("imgSlideWrap", e.extend({}, a, {
110            fade: !0,
111            speed: 500,
112            dots: !0,
113            cssEase: "linear",
114            slidesToShow: 1,
115            arrows: !1,
116            autoplay: !1,
117            autoplaySpeed: 8e3,
118            pauseOnHover: !1
119        })), e(".vehicleCards"), t("vehicleCards", e.extend({}, a, {
120            slidesToShow: 1,
121            responsive: [{
122                breakpoint: 815,
123                settings: {
124                    infinite: !0,
125                    slidesToShow: 1,
126                    arrows: !1,
127                    centerMode: 0,
128                    centerPadding: "0"
129                }
130            }]
131        })), e(".vehiclesHome ul.nav-tabs a").click(function (t) {
132            $('.vehiclesCol').slick('slickGoTo', 0);
133            if (t.preventDefault(), e(this).tab("show"), $(".addVehicleId").length > 0) {
134                var i = $(".addVehicleId a").attr("href").split("?")[0];
135                $(".addVehicleId a").attr("href", i + "?" + $(".vehiclesHome ul.nav-tabs li.active a").attr("href").split("#").pop()), $(".addVehicleId a").html($(".addVehicleId a").html().substring(0, 9) + $(".vehiclesHome ul.nav-tabs li.active a").html())
136            }
137            e(".vehicleCards").slick("refresh"), setTimeout(function () {
138                e(".vehicleCards").slick("refresh"), equalheight(".vehicleWrap")
139            }, 100)
140        }), e(".navbar-toggle ").on("click", function (t) {
141            t.preventDefault(), e(this).toggleClass("collapsed")
142        }), e(".desktop nav .dropdown").hover(function () {
143            e(".dropdown-menu", this).stop(!0, !0).fadeIn("fast"), e(this).toggleClass("open")
144        }, function () {
145            e(".dropdown-menu", this).stop(!0, !0).fadeOut("fast"), e(this).toggleClass("open")
146        });
147        var o = e(".secondaryMenu");
148        3 === o.find("li").length && o.addClass("noLogin"), e("#firstOverlay, .imageBox #closeBtn").click(function (t) {
149            t.preventDefault(), e("body").css("overflow", "inherit"), e("#firstOverlayWrapper").fadeOut("fast"), e("#firstOverlayWrapper .imageBox iframe").attr("src", "")
150        }), e("body").on("click", ".videOverLay", function (t) {
151            t.preventDefault(), e("body").css("overflow", "hidden");
152            var i = e(this).data("videoid"),
153                a = e(this).data("videoidmobile"),
154                o = e("body").hasClass("desktop") ? i : a,
155                n = YouTubeGetID(o);
156            e("#firstOverlayWrapper, #firstOverlayWrapper .video-close-btn").fadeIn("fast"), e("#firstOverlayWrapper .imageBox iframe").attr("src", "https://www.youtube.com/embed/" + n + "?autoplay=1&rel=0&d;showinfo=0&amp")
157        }), e("video").on("click", function () {
158            playVideo()
159        }), e(".productAmount").length && e(".productAmount").each(function () {
160            var t = e(this).text().replace(/(\d)(?=(\d\d)+\d$)/g, "$1 ");
161            e(this).text(t)
162        }), e('input[type="text"]').change(function () {
163            this.value = e.trim(this.value)
164        }), e(".homeHero, #hero-slider, .slide4Col, .vehicleCards, .dealerVehicleCate").on("init reInit afterChange", function (e, t, i, a) {
165            lazyLoad()
166        })
167    }(jQuery), document.addEventListener("fullscreenchange", function () {
168        document.fullscreenElement || $(".accessories-slider-nav").slick("refresh")
169    }, !1), $(window).on("load", function () {
170        $(".homeHero, .imgSlideWrap, #hero-slider").slick("slickSetOption", "autoplay", !0, !0), $(".homeHero, .imgSlideWrap, #hero-slider").slick("refresh"), scrollTrigger = Math.round(.7 * $(document).height()), equalheight(".vehicleWrap"), $(".eqHeight").length && equalheight(".eqHeight")
171    }), $(window).resize(function () {
172        equalheight(".vehicleWrap"), $(".eqHeight").length && equalheight(".eqHeight")
173    });
174var scrollTrigger, previousScroll = 0;
175
176function playVideo() {
177    var e = document.querySelector("video");
178    e.addEventListener("ended", function () {
179        v = e.currentSrc, e.src = "", e.src = v
180    })
181}
182
183function updateButton() {
184    $(".vehiclesHome ul.nav-tabs a").click(function (t) {
185        t.preventDefault();
186        $(this).tab("show");
187        if ($(".addVehicleId").length > 0) {
188            var baseHref = $(".addVehicleId a").attr("href").split("?")[0];
189            $(".addVehicleId a").attr("href", baseHref + "?" + $(".vehiclesHome ul.nav-tabs li.active a").attr("href").split("#").pop());
190            $(".addVehicleId a").html($(".addVehicleId a").html().substring(0, 9) + $(".vehiclesHome ul.nav-tabs li.active a").html());
191        }
192        $(".vehicleCards").slick("refresh");
193        setTimeout(function () {
194            $(".vehicleCards").slick("refresh");
195            equalheight(".vehicleWrap");
196        }, 100);
197    });
198}
199
200
201function YouTubeGetID(e) {
202    var t = "";
203    return void 0 !== (e = e.replace(/(>|<)/gi, "").split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/))[2] ? (t = e[2].split(/[^0-9a-z_\-]/i))[0] : e
204}
205$(window).scroll(function () {
206    var e = $(this).scrollTop();
207    e > previousScroll ? e > 65 && $(".secondaryMenuWrapper").removeClass("fixPos") : $(".secondaryMenuWrapper").addClass("fixPos"), previousScroll = e
208}).scroll(), equalheight = function (e) {
209    var t, i = 0,
210        a = 0,
211        o = [];
212    $(e).each(function () {
213        if (t = $(this), $(t).height("auto"), a != (topPostion = t.position().top)) {
214            for (currentDiv = 0; currentDiv < o.length; currentDiv++) o[currentDiv].height(i);
215            o.length = 0, a = topPostion, i = t.height(), o.push(t)
216        } else o.push(t), i = i < t.height() ? t.height() : i;
217        for (currentDiv = 0; currentDiv < o.length; currentDiv++) o[currentDiv].height(i)
218    })
219};
220var bottomCtaSticky = "#aogJoinCommunity .joinCommunityWrapper, #aogJoinCommunity .exp-register-sec";
221
222function savCookie() {
223    localStorage.setItem("cookieenabled", "Yes"), $(".cookie_bot").fadeOut(), $(bottomCtaSticky).addClass("nocookie"), $(bottomCtaSticky).removeClass("yescookie")
224}
225
226function countryDropdown(e) {
227    var t = $(e),
228        i = $(e + "-drop");
229    t.click(function (e) {
230        t.toggleClass("open"), i.toggle(), e.stopPropagation(), e.preventDefault()
231    }), i.find("li").click(function () {
232        t.removeClass("open"), i.hide();
233        var e = $(this);
234        t.html(e.html()), $(".dropdown").find("li").removeClass("active"), e.addClass("active")
235    })
236}
237
238function delete_cookie(e) {
239    document.cookie = e + "=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;"
240}
241setTimeout(function () {
242    if ("undefined" != typeof Storage) {
243        if ("Yes" == localStorage.getItem("cookieenabled")) $(".cookie_bot").hide(), $(bottomCtaSticky).addClass("nocookie"), $(bottomCtaSticky).removeClass("yescookie");
244        else {
245            $(".cookie_bot").css("visibility", "visible"), $(bottomCtaSticky).addClass("yescookie");
246            var e = $(".cookie_bot").height();
247            $(".yescookie").css({
248                bottom: e
249            })
250        }
251    }
252}), countryDropdown("#country"), countryDropdown("#countryMobile"), $('body').click(function () {
253    $("#country-drop").hide(), $("#countryMobile-drop").hide()
254}), registerListener("load", setLazy), registerListener("load", lazyLoad), registerListener("scroll", lazyLoad);
255var lazy = [];
256
257function setLazy() {
258    lazy = document.getElementsByClassName("lazy")
259}
260
261function lazyLoad() {
262    for (var e = 0; e < lazy.length; e++) isInViewport(lazy[e]) && lazy[e].getAttribute("data-src") && (lazy[e].src = lazy[e].getAttribute("data-src"), lazy[e].removeAttribute("data-src"), $(lazy[e]).addClass("lazyloaded"));
263    cleanLazy()
264}
265
266function cleanLazy() {
267    lazy = Array.prototype.filter.call(lazy, function (e) {
268        return e.getAttribute("data-src")
269    })
270}
271
272function isInViewport(e) {
273    var t = e.getBoundingClientRect();
274    return t.bottom >= 0 && t.right >= 0 && t.top <= (window.innerHeight || document.documentElement.clientHeight) && t.left <= (window.innerWidth || document.documentElement.clientWidth)
275}
276
277function registerListener(e, t) {
278    window.addEventListener ? window.addEventListener(e, t) : window.attachEvent("on" + e, t)
279}
280
281function dl_push(e, t, i, a, o, n) {
282    var r = {};
283    e && (r.event = e), t && (r.eventCategory = t), i && (r.eventAction = i), a && (r.eventLabel = a), o && (r.BrandName = o), n && (r.VariantName = n), dataLayer.push(r)
284}
285
286function countryDropdown(e) {
287    var t = $(e),
288        i = $(e + "-drop");
289    t.click(function (e) {
290        t.toggleClass("open"), i.toggle(), e.stopPropagation(), e.preventDefault()
291    }), i.find("li").click(function () {
292        t.removeClass("open"), i.hide();
293        var e = $(this);
294        t.html(e.html()), $(".dropdown").find("li").removeClass("active"), e.addClass("active")
295    })
296}
297
298function validateNumberInput(e) {
299    e.value = e.value.replace(/\D/g, ""), e.value.length > 10 && (e.value = e.value.slice(0, 10))
300}
301
302function validateOTPInput(e) {
303    e.value = e.value.replace(/\D/g, ""), e.value.length > 10 && (e.value = e.value.slice(0, 4))
304}
305
306function validateTextInput(e) {
307    e.value = e.value.replace(/[^A-Za-z\s]/g, "").replace(/\s{2,}/g, " "), e.value.length > 50 && (e.value = e.value.slice(0, 50))
308}
309
310function lazyLoadImage(e) {
311    var t = $((e ? e + " " : "") + "img[data-src]");
312    $(t).each(function () {
313        $(this).data("src")
314    })
315}
316
317function dynamicIndianPriceForLandingPage() {
318    $(".productAmount").each(function () {
319        var e = $(this).text().split("/-")[0].replace(/(\d)(?=(\d\d)+\d$)/g, "$1 ") + "/-";
320        $(this).text(e)
321    })
322}
323$('.all-brand-cta a[data-toggle="collapse"]').click(function () {
324    let e = $(this).attr("href");
325    setTimeout(() => {
326        $("#collapse-list-parent div.in").each(function () {
327            e != "#" + $(this).attr("id") && $(this).removeClass("in"), $(this).closest("li").find("a").attr("aria-expanded", "false")
328        })
329    }, 300)
330}), countryDropdown("footer .country"), countryDropdown("#countryMobileFooter"), $('body').click(function () {
331    $("#countryMobile-drop").hide(), $("#countryMobileFooter-drop").hide()
332}), $("#countryMobileFooter-drop a").on("click", function () {
333    let e = "";
334    e = $(this).attr("href") ? $(this).attr("href") : "", window.open(e, "_blank")
335}), $(document).ready(function () {
336    if ($(".addVehicleId").length > 0) {
337        var e = $(".addVehicleId a").attr("href").split("?")[0];
338        $(".addVehicleId a").attr("href", e + "?" + $(".vehiclesHome ul.nav-tabs li.active a").attr("href").split("#").pop()), $(".addVehicleId a").text($(".addVehicleId a").text().substring(0, 9) + $(".vehiclesHome ul.nav-tabs li.active a").html())
339    }
340});
341$('.dropdown').click(function () {
342    if (($(this).hasClass('open'))) {
343        $(this).find('a').addClass('hideit');
344    }
345    else {
346        $(this).find('a').removeClass('hideit');
347    }
348})
349$('.navbar-toggle').click(function () {
350    setTimeout(function () {
351        if ($('.navbar-toggle').hasClass('collapsed')) {
352            $('body').removeClass('noScroll')
353        } else {
354            $('body').addClass('noScroll')
355        }
356    }, 100);
357});
358$('#countryMobile').click(function () {
359    $('.navBorder .dropdown').removeClass('open');
360})
361
362$(document).on('click', '.navWrap a[href^="#"]', function (e) {
363    e.preventDefault();
364    var _this = this;
365    setTimeout(function () {
366        $('.navWrap li a').removeClass('active');
367        $('.navWrap li').removeClass('active');
368        $(_this).parent('li').addClass('active');
369        $(_this).parent('li').find('a').addClass('active');
370    }, 100);
371    var myScrollPos = $(this).offset().left
372        + $(this).outerWidth(true) / 2
373        + $('.navWrap').scrollLeft()
374        - $('.navWrap').width() / 2;
375    $('.navWrap').animate({ scrollLeft: myScrollPos }, 300);
376});
377
378
379
380var activateSlider;
381var activateSliderid;
382activateSlider = function (className, optionsObj) {
383    // var sliderProperties = getSliderProperties (className);
384    $("." + className).slick(optionsObj);
385};
386activateSliderid = function (idName, optionsObj) {
387    // var sliderProperties = getSliderProperties (className);
388    $("#" + idName).slick(optionsObj);
389};
390
391var options = {
392    infinite: false,
393    slidesToShow: 3,
394    arrows: true,
395    lazyLoad: 'ondemand'
396};
397
398var vehiclesHomeObj = {
399    dots: false,
400    infinite: false,
401    slidesToShow: 3.2,
402    "centerMode": false,
403    arrows: false,
404    centerPadding: '25%',
405    "responsive": [{
406        breakpoint: 1300,
407        settings: {
408            slidesToShow: 2.5,
409            adaptiveHeight: true,
410        }
411    },
412    {
413        breakpoint: 941,
414        settings: {
415            slidesToShow: 1.3,
416            adaptiveHeight: true,
417        }
418    },
419    {
420        breakpoint: 815,
421        settings: {
422            slidesToShow: 1.1,
423            adaptiveHeight: true,
424            centerMode: false,
425        }
426    },
427
428    {
429        breakpoint: 480,
430        settings: {
431            slidesToShow: 1,
432            centerPadding: '16px',
433            adaptiveHeight: true,
434            centerMode: false,
435        }
436    }
437    ]
438};
439
440
441// Home achievments Slider
442var achivObj = {
443    "slidesToShow": 2.3,
444    "arrows": false,
445    "infinite": false,
446    "centerMode": false,
447    "responsive": [{
448        breakpoint: 992,
449        settings: {
450            "slidesToShow": 1.8,
451            "arrows": false,
452            centerPadding: '20px',
453
454        }
455    },
456    {
457        breakpoint: 815,
458        settings: {
459            "slidesToShow": 1.3,
460            "arrows": false,
461            adaptiveHeight: true,
462        }
463    },
464    {
465        breakpoint: 360,
466        settings: {
467            "slidesToShow": 1.1,
468            "arrows": false,
469            centerPadding: '20px',
470            adaptiveHeight: true,
471        }
472    }
473    ]
474};
475activateSlider('achivCol', $.extend({}, options, achivObj));
476activateSlider('vehiclesCol', $.extend({}, options, vehiclesHomeObj));
477
478
479
480$(".prev").click(function () {
481    $(".vehiclesCol").slick("slickPrev");
482});
483
484$(".next").click(function () {
485    $(".vehiclesCol").slick("slickNext");
486});
487
488
489
490
491$('.timerOuter').css('opacity', '0');
492$(window).on('load', function () {
493    $('.timerOuter').css('opacity', '1');
494    if ($(window).width() > 816) {
495        let sliderTimeout;
496        $("#hero-slider").on('click', '.slick-prev, .slick-next, .slick-dots', function () {
497            $('.timerOuter').css('opacity', '0');
498            $('#hero-slider').slick('slickPause');
499            clearTimeout(sliderTimeout);
500
501            sliderTimeout = setTimeout(() => {
502                $('.timerOuter').css('opacity', '1');
503                $('#hero-slider').slick('slickPlay');
504                $('#hero-slider').slick('slickNext');
505            }, 10000);
506        });
507    } else {
508        setInterval(function () {
509            $('#hero-slider').slick('slickNext');
510        }, 5500);
511    }
512});
513
514$(window).on("load", function () {
515    $(".home-hero-banner, .vehiclesHome .vehiclesCol").css("height", "auto");
516});
517
518//
519$("#stateDrpHomePage").change(function () {
520    var state = $("#stateDrpHomePage").val();
521
522    $.ajax({
523        type: "POST",
524        url: "/api/VehiclePrice",
525        data: { StateID: state },
526        success: function (response) {
527            if (response.success) {
528                updatePrices(response.vehicles);
529            } else {
530                console.error('Error: API returned success = false');
531            }
532        },
533        error: function (xhr, status, error) {
534            console.error('Error fetching vehicle prices:', error);
535        }
536    });
537});
538
539function updatePrices(vehicles) {
540    if (!vehicles || vehicles.length === 0) return;
541
542    vehicles.forEach(vehicle => {
543        const vehicleName = vehicle.Title?.trim();
544        const vehiclePrice = vehicle.Price;
545
546        if (vehicleName && vehiclePrice != null) {
547            document.querySelectorAll('.bike-details-main .bike-text-details').forEach(card => {
548                const titleElement = card.querySelector('h3');
549                if (titleElement && titleElement.innerText.trim() === vehicleName) {
550                    const priceElement = card.querySelector('.productAmount');
551                    if (priceElement) {
552                        priceElement.innerText = formatPrice(vehiclePrice);
553                    }
554                }
555            });
556        }
557    });
558}
559
560function formatPrice(price) {
561    let priceStr = price.toString();
562
563    var number = parseFloat(priceStr);
564    if (isNaN(number)) {
565        return priceStr; // Return the original string if parsing fails
566    }
567    if (priceStr.length > 3) {
568        const lastThree = priceStr.substring(priceStr.length - 3);
569        const otherNumbers = priceStr.substring(0, priceStr.length - 3);
570        return "\u20B9 " + otherNumbers.replace(/\B(?=(\d{2})+(?!\d))/g, " ") + " " + lastThree + " /-";
571    } else {
572        return "\u20B9 " + priceStr + " /-";
573    }
574}
575$('.productAmount').each(function () {
576    var rawPrice = $(this).text();
577    var formattedPrice = formatPrice(rawPrice);
578    $(this).html(`${formattedPrice}`);
579});

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.