PageSourceSearch

https://www.tvsmotor.com/assets/js/userManual.js?17-09-26-3

js tvsmotor.com collected 2026-10-01 11:25:09 UTC 8,528 bytes, 202 lines download raw bytes

1
2
3$(document).ready(function () {
4
5
6    var wrappers = document.querySelectorAll('.filterListWrap');
7    for (var i = 0; i < wrappers.length; i++) {
8        wrappers[i].hidden = true;
9    }
10    // ─── 0️⃣ Track current selections ───
11    var selectedType = null;
12    var selectedNameVal = null;
13    var selectedDateVal = null;
14    var selectedNameId = null;
15    var selectedDateId = null;
16    var selectedNameClass = null;
17    // ─── 1️⃣ Cache dropdown button containers ───
18    var $typeBtn = $('.selectBtn').filter(function () {
19        return $(this).find('span').text() === 'Vehicle Type';
20    });
21    var $nameBtn = $('.selectBtn').filter(function () {
22        return $(this).find('span').text() === 'Vehicle Name';
23    });
24    var $dateBtnWrap = $('.custSelctWrap').has('span:contains("Manufactured Date")'); // ─── NEW ───
25    var $dateBtn = $dateBtnWrap.find('.selectBtn');                                    // ─── NEW ───
26    var $searchBtn = $('.searchBlueBtn button');
27    var $nameItems = $nameBtn.find('.custSelectItems ul li');
28    var $wrappers = $('.filterListWrap');  // all PDF containers
29
30    // ─── 2️⃣ Placeholder texts ───
31    var placeholder = {
32        type: 'Select Vehicle Type',
33        name: 'Select Vehicle Name',
34        date: 'Select Vehicle Manufactured Date'
35    };
36
37    // ─── 3️⃣ Initial state ───
38    $nameItems.hide();
39    $nameBtn.find('.defSel').addClass('disabled');
40    $dateBtn.find('.defSel').addClass('disabled');
41    $searchBtn.prop('disabled', true);
42
43    // ─── 4️⃣ Dropdown‐toggle logic ───
44    $('.defSel').on('click', function (e) {
45        var label = $(this).siblings('span').text();
46        if (label === 'Vehicle Name' && !selectedType) return;
47        if (label === 'Manufactured Date' && !selectedNameVal) return;
48        e.stopPropagation();
49        var $dd = $(this).siblings('.custSelectItems');
50        $('.custSelectItems').not($dd).slideUp(100);
51        $dd.slideToggle(100);
52    });
53
54    // ─── 5️⃣ Handle item clicks ───
55    $('.selectBtn ul li').on('click', function (e) {
56        e.stopPropagation();
57        var text = $(this).text();
58        var $btn = $(this).closest('.selectBtn');
59        var label = $btn.find('span').text();
60        var $def = $btn.find('.defSel');
61
62        // 5.a Update button, mark selected
63        $def.text(text).addClass('selected');
64        $btn.find('.custSelectItems').slideUp(100);
65
66        // 5.b Branch logic
67        if (label === 'Vehicle Type') {
68            selectedType = text;
69
70            // ─── NEW: hide/show Date picker when Electric ───
71            if (selectedType === 'Electric') {
72                // hide entire date dropdown & clear any selection
73                $dateBtnWrap.hide();
74                selectedDateVal = selectedDateId = null;
75                $dateBtn.find('.defSel').text(placeholder.date).removeClass('selected');
76            } else {
77                $dateBtnWrap.show();
78            }
79            // ────────────────────────────────────────────────
80
81            // filter names
82            $nameItems.hide().filter('[data-type="' + text + '"]').show();
83
84            // reset downstream
85            $nameBtn.find('.defSel')
86                .text(placeholder.name)
87                .removeClass('selected disabled');
88            if (selectedType !== 'Electric') {
89                $dateBtn.find('.defSel')
90                    .text(placeholder.date)
91                    .removeClass('selected disabled');
92            }
93            selectedNameVal = selectedDateVal = selectedNameId = selectedDateId = null;
94            $searchBtn.prop('disabled', true);
95
96            // enable Name
97            $nameBtn.find('.defSel').removeClass('disabled');
98        }
99        else if (label === 'Vehicle Name') {
100            selectedNameVal = text;
101            selectedNameId = this.id || null;
102            selectedNameClass = $(this).data('class') || null;
103            // special hide/show for ScootyPep+
104            if (selectedNameClass === 'hideDate') {
105                $dateBtnWrap.hide();
106                selectedDateVal = selectedDateId = null;
107                $dateBtn.find('.defSel').text(placeholder.date).removeClass('selected');
108            } else {
109                $dateBtnWrap.show();
110            }
111            if (text === 'TVS ScootyPep+') {
112                $dateBtn.find('#afterApr2025').hide();
113                if (selectedDateId === 'afterApr2025') {
114                    selectedDateVal = selectedDateId = null;
115                    $dateBtn.find('.defSel')
116                        .text(placeholder.date)
117                        .removeClass('selected');
118                    $searchBtn.prop('disabled', true);
119                }
120            } else {
121                $dateBtn.find('#afterApr2025').show();
122            }
123            // special hide/show for TVS Apache RTR.
124            if (text === 'TVS Apache RTR') {
125                $dateBtn.find('#afterAug2025').show();
126
127            } else {
128                if (selectedDateId === 'afterAug2025') {
129                    selectedDateVal = selectedDateId = null;
130                    $dateBtn.find('.defSel')
131                        .text(placeholder.date)
132                        .removeClass('selected');
133                    $searchBtn.prop('disabled', true);
134                }
135                $dateBtn.find('#afterAug2025').hide();
136            }
137            // enable Date ONLY if not Electric
138            if (selectedType !== 'Electric') {
139                $dateBtn.find('.defSel').removeClass('disabled');
140            }
141
142        }
143        else if (label === 'Manufactured Date') {
144            selectedDateVal = text;
145            selectedDateId = this.id || null;
146        }
147
148        // 5.c Enable Search when ready
149        var typeOk = selectedType && selectedType !== placeholder.type;
150        var nameOk = selectedNameVal && selectedNameVal !== placeholder.name;
151        var dateOk = selectedDateVal && selectedDateVal !== placeholder.date;
152        // ─── NEW: skip date requirement for Electric ───
153        var enableSearch = typeOk && nameOk && (dateOk || selectedType === 'Electric' || selectedNameClass === 'hideDate');
154        $searchBtn.prop('disabled', !enableSearch);
155        // ──────────────────────────────────────────────
156    });
157
158    // ─── 6️⃣ Search button logic ───
159    $searchBtn.off('click').on('click', function (e) {
160        e.preventDefault();
161
162        // update header
163        if (selectedType) {
164            $wrappers.find('h3').text(selectedType);
165        }
166
167        // hide all...
168        $wrappers.each(function () {
169            this.hidden = true;
170        });
171
172        // ─── NEW: Electric ⇒ show ALL matches by name only ───
173        if (selectedType === 'Electric' && selectedNameId) {
174            $wrappers
175                .filter('[data-name-id="' + selectedNameId + '"]')
176                .each(function () { this.hidden = false; });
177        } else if (selectedNameClass === 'hideDate' && selectedNameId) {
178            $wrappers
179                .filter('[data-name-id="' + selectedNameId + '"]')
180                .each(function () { this.hidden = false; });
181        }
182        else if (selectedNameId && selectedDateId) {
183            // original behavior
184            var sel = '[data-name-id="' + selectedNameId +
185                '"][data-date-id="' + selectedDateId + '"]';
186            var match = document.querySelector(sel);
187            if (match) match.hidden = false;
188        }
189        // ────────────────────────────────────────────────────
190    });
191
192    // ─── 7️⃣ Close dropdowns on outside click ───
193    $(document).on('click', function () {
194        $('.custSelectItems').slideUp(100);
195    });
196
197    // ─── 8️⃣ Download links open in new tab ───
198    $(document).on('click', '.manualDownLoad', function (e) {
199        e.preventDefault();
200        window.open($(this).attr('href'), '_blank');
201    });
202});

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.