PageSourceSearch

https://www.garagekeptmotors.com/wp-content/themes/aanWordpress/scripts/my_garage.js?=1734685291

js garagekeptmotors.com collected 2026-10-02 10:26:01 UTC 14,077 bytes, 356 lines download raw bytes

1let registerPopup = () => {
2    insertForm('form_register', 'register');
3    $('.mygarage-auth-section .inner #form_register').parents(".form").show();
4    $('.mygarage-auth-section .inner #form_login').parents(".form").hide();
5    $('.mygarage-auth-section').fadeIn();
6},
7loginPopup = () => {
8    insertForm('form_login', 'login');
9    $('.mygarage-auth-section .inner #form_login').parents(".form").show();
10    $('.mygarage-auth-section').fadeIn();
11},
12checkPinned = () => {
13    var i = 0;
14    while (pinned_vehicles[i]) {
15        $(".pin_"+ pinned_vehicles[i].id).addClass("active");
16        i++;
17    }
18    var count = pinned_vehicles.length;
19    if (count != 10) {
20        count = count;
21    }
22    $(".pincount .text").text(count);
23},
24isSaved = (vid) => {
25    return pinned_vehicles.some((v) => {
26            return v.id == vid;    
27    })
28},
29pinIt = (obj) => {
30    let vid = $(obj).attr("data-pin");
31    if (!$(obj).hasClass("pincount")) {
32        $.post("/api/?module=my_garage", {
33            action: isSaved(vid) ? "delete_save" : "pin_it",
34            car_id: vid
35        }, function(data, status) {
36            if (status !== "success")
37                return;
38
39            if (data.type === 'success') {
40                var count = pinned_vehicles.length;
41                if (isSaved(vid)) {
42                    pinned_vehicles = pinned_vehicles.filter(function(el) { 
43                        return el.id != vid; 
44                    });
45                    if ($(".saved_cars_bl").length)
46                        $(".saved_cars_bl .pin_" + data.id).parents(".save_car").remove();
47                
48                    count = count - 1;
49
50                    $(".pincount .text").text(count);
51                    $(".hpincount .text").text(count);
52                    $(".pin_"+ data.id).removeClass("active");
53
54                } else {
55                    if ($(".saved_cars_bl").length)
56                        insert_save_car(data.message);
57                    
58                    pinned_vehicles.push(data);
59
60                    $(".pin_"+ data.id).addClass("active");
61                    
62                    count = count + 1;
63
64                    $(".pincount .text").text(count);
65                    $(".hpincount .text").text(count);
66                }
67            } else if (data.type === 'error') {
68                if (data.message == 'no_user')
69                    loginPopup();
70                else
71                    alert(data.message);
72            }
73        });
74    }
75},
76insert_save_car = (data) => { 
77console.log(data);
78    $(".saved_cars_bl .savelist").append(getTile(data));
79},
80login_submit = () => {
81    $('#login_submit').attr('disabled', 'disabled').text('Processing');
82    $.post("/api/?module=user", $('#login_form').serializeArray(), function(text) {
83
84        if (text == 'OK') {
85            setTimeout(function() {
86                location.href = "";
87            }, 3000);
88        } else {
89            $("#login_form .mgg_error_txt").text("Incorrect login information. Please check your credentials and try again.");
90            $('#login_submit').removeAttr('disabled').text('Login');
91        }
92    });
93    return false;
94},
95mgg_register_submit = () => {
96    $('#register_submit').attr('disabled', 'disabled').text('Processing');
97    $.post("/api/?module=user&formname=register", $('#reg_form').serializeArray(), function(text) {
98
99        if (text == 'OK') {
100            setTimeout(function() {
101                location.href = "";
102            }, 3000);
103        } else {
104            $('#register_submit').removeAttr('disabled').text('Register');
105            $("#reg_form .mgg_error_txt").text(text);
106            grecaptcha.reset();
107        }
108    });
109    return false;
110},
111logout = () => {
112    $('#logout_submit').attr('disabled', 'disabled').text('Processing');
113    $.get("/api/?module=user&action=logout", function(text) {
114        if (text == 'OK') {
115            setTimeout(function() {
116                location.href = "";
117            }, 3000);
118        }
119    });
120    return false;
121},
122mgg_send_restore = () => {
123    $.post("/api/?module=my_garage", $('#mgg_lostPasword').serializeArray(), function(text) {
124        if (!text.match("^Error")) {
125            $("#mgg_lostPasword").html(text);
126        } else {
127            $("#mgg_lostPasword .mgg_error_txt").text(text);
128        }
129    });
130    return false;
131},
132extractDomain = (url) => {
133    var domain;
134    if (url.indexOf("://") > -1) {
135        domain = url.split('/')[2];
136    } else {
137        domain = url.split('/')[0];
138    }
139    domain = domain.split(':')[0];
140    return domain;
141},
142toggleNotifications = (checked) => {
143    var user_id = $.cookie('user_id');
144    if (user_id < 1) {
145        alert('Error!');
146        return false;
147    }
148    $.get("/api/?module=my_garage&action=toggleNotification&active="+ checked +"&user_id="+ user_id, function(text) {
149        if (text == "OK")
150            alert('Notification turned '+ (checked == true ? 'On' : 'Off') +'.');
151        else
152            alert('Error! No records changed.');
153    });
154},
155showSaved = (veh, div, callback) => {
156    veh.map((v) => {
157        $('#'+ div).append(getTile(v));
158    })
159    if (typeof callback == 'function')
160        callback();
161},
162locations = [extractDomain(location.href)],
163init_garage = () => {
164    $(".view_more").click(function(e) {
165        $(this).parents('.garage_col').find('.hide_this').removeClass("hide_this");
166        $(this).hide()
167    });
168    $("select[name='priceMn']").on('change', function() {
169        var minP = parseInt($(this).val());
170        $('select[name="priceMx"] option').show();
171        $('select[name="priceMx"] option').filter(function() {
172            return parseInt($(this).val()) < minP;
173        }).hide();
174    });
175    $("select[name='priceMx']").on('change', function() {
176        var minP = parseInt($(this).val());
177        $('select[name="priceMn"] option').show();
178        $('select[name="priceMn"] option').filter(function() {
179            return parseInt($(this).val()) > minP;
180        }).hide();
181    });
182    $("select[name='yearMn']").on('change', function() {
183        var minP = parseInt($(this).val());
184        $('select[name="yearMx"] option').show();
185        $('select[name="yearMx"] option').filter(function() {
186            return parseInt($(this).val()) < minP;
187        }).hide();
188    });
189    $("select[name='yearMx']").on('change', function() {
190        var minP = parseInt($(this).val());
191        $('select[name="yearMn"] option').show();
192        $('select[name="yearMn"] option').filter(function() {
193            return parseInt($(this).val()) > minP;
194        }).hide();
195    });
196    $("select[name='mileageMn']").on('change', function() {
197        var minP = parseInt($(this).val());
198        $('select[name="mileageMx"] option').show();
199        $('select[name="mileageMx"] option').filter(function() {
200            return parseInt($(this).val()) < minP;
201        }).hide();
202    });
203    $("select[name='mileageMx']").on('change', function() {
204        var minP = parseInt($(this).val());
205        $('select[name="mileageMn"] option').show();
206        $('select[name="mileageMn"] option').filter(function() {
207            return parseInt($(this).val()) > minP;
208        }).hide();
209    });
210    $("#add_price_carx").click(function(e) {
211        e.stopImmediatePropagation();
212
213        if (typeof $.cookie('user_id') == 'undefined' || $.cookie('user_id') == '0') {
214            loginPopup();
215            return;
216        }
217
218        let make = $("#mgg_make").val(),
219            model = $("#mgg_model").val(),
220            mxYear = $('#yearMx').val(),
221            mnYear = $('#yearMn').val(),
222            mnPrice = 0,
223            mxPrice = $('#priceMx').val();
224
225        if (make) {
226            $.post("/api/?module=my_garage", {
227                action: "notification_add",
228                make: make,
229                model: model,
230                yearMn: mnYear,
231                yearMx: mxYear,
232                priceMn: mnPrice,
233                priceMx: mxPrice,
234            }, function(data, status) {
235                if (status === "success") {
236                    if (data.type === 'success') {
237                        var nitif_el = `<div class="save_car">
238                                            <div class="deteil">
239                                                <div class="car_list_hide">
240                                                    <div>
241                                                        ${ data.message.make } ${ data.message.model }
242                                                    </div>
243                                                    <div><span>Year Range:</span>
244                                                        ${ data.message.beginyear } - ${ data.message.endyear }
245                                                    </div>
246                                                    <div><span>Price Range:</span>
247                                                        ${ (data.message.highprice ? "$" + numberFormat(data.message.highprice) 
247: "Any") }
248                                                    </div>
249                                                </div>
250                                                <div class="sClinks">
251                                                    <span class="notification_delete" data-id="${ data.message.id }">
252                                                        <svg xmlns="http://www.w3.org/2000/svg" width="10.917" height="14.036" viewBox="0 0 10.917 14.036">
253                                                                        <path id="ic_delete_forever_24px" d="M5.78,15.476a1.564,1.564,0,0,0,1.56,1.56h6.238a1.564,1.564,0,0,0,1.56-1.56V6.119H5.78ZM7.7,9.924l1.1-1.1,1.661,1.653,1.653-1.653,1.1,1.1-1.653,1.653,1.653,1.653-1.1,1.1-1.653-1.653L8.805,14.33l-1.1-1.1,1.653-1.653ZM13.187,3.78,12.408,3h-3.9l-.78.78H5v1.56H15.917V3.78Z" transform="translate(-5 -3)" fill="#bc0000"/>
254                                                                    </svg>
255                                                        <span>Remove vehicle</span>
256                                                    </span>
257                                                </div>
258                                            </div>
259                                        </div>`;
260
261                        $("#notif_car").parent('.garage_col').find('.errors').text('');
262                        $("#notif_car").append(nitif_el);
263                        $("#notif_count").text(data.count);
264                    } else if (data.type === 'error') {
265                        alert(data.message);
266                    }
267                }
268            });
269        } else {
270            alert("Please select at least make.");
271        }
272    });
273    $('.saved_cars_bl').on('click', '.save_car .title', function() {
274        $(this).parent().toggleClass("open");
275    });
276    $('.notif_car').on('click', '.save_car .vv_W', function() {
277        $(this).parents('.save_car').toggleClass("open");
278    });
279    $(".pin:not(.hasFunc)").addClass("hasFunc");
280    $(".save_this").click(function(e) {
281        e.preventDefault();
282        e.stopPropagation();
283        $(this).parents(".car-col").find(".pin").trigger("click");
284    });
285    $('body').on('click', ".save_this_deteil", function(e) {
286        e.preventDefault();
287        $(this).parents(".deteil").find(".pin").trigger("click");
288    });
289    $('.del_alert').on('click', function(e) {
290        e.preventDefault();
291        $.post("/api/?module=my_garage", {
292            action: "delete_alert",
293            alert_id: $(this).attr("data-id")
294        }, function(data, status) {
295            if (status === "success") {
296                if (data.type === 'success') {
297                    $(".notif_car").find("[data-id='" + data.id + "']").parents(".save_car").remove();
298                     $("#alerts_count").text(data.count);
299                } else if (data.type === 'error') {
300                    alert(data.message);
301                }
302            }
303        });
304    });
305    $('span.notification_delete').unbind().on('click', function(e) {
306        e.preventDefault();
307        e.stopPropagation();
308        $.post("/api/?module=my_garage", {
309            action: "notification_delete",
310            notif_id: $(this).attr("data-id")
311        }, function(data, status) {
312            if (status === "success") {
313                if (data.type === 'success') {
314                    $(".notif_car").find("[data-id='" + data.id + "']").parents(".save_car").remove();
315                    $("#notif_count").text(data.count);
316                } else if (data.type === 'error') {
317                    alert(data.message);
318                }
319            }
320        });
321    });
322
323    $('.mygarage-auth-section .inner .form').hide();
324    $(".mgg_login").click(function(e) {
325        e.preventDefault();
326        $('.mygarage-auth-section .inner #login_form').parents(".form").show();
327        $('.mygarage-auth-section').fadeIn();
328    });
329    $('body').on('click', '.mgg_reg', function(e) {
330        e.preventDefault();
331        $('.mygarage-auth-section .inner #reg_form').parents(".form").show();
332        $('.mygarage-auth-section').fadeIn();
333    });
334    $(".mgg_forgotten").click(function(e) {
335        e.preventDefault();
336        $('.mygarage-auth-section .inner .form').hide("slow");
337        $('.mygarage-auth-section .inner #mgg_lostPasword').parents(".form").show("slow");
338    });
339    $('.mygarage-auth-section .head .exit').on('click', function(e) {
340        e.preventDefault();
341        $('.mygarage-auth-section').fadeOut("slow", function() {
342            $('.mygarage-auth-section .inner .form').hide();
343        });
344    });
345    $('body').on('click', '#edit_prof', function(e) {
346        $('.mygarage-auth-section .inner .form:last-child').hide();
347        $("#reg_form button").text('Update').addClass('update');
348        $("#reg_form").parents(".form").show();
349        $('.mygarage-auth-section').fadeIn();
350    });
351    $('body').on('click', '.see_notif_list', function(e) {
352        e.preventDefault();
353        $(this).parents('.hide_deteil').find(".car_list_hide").slideToggle("slow", "linear");
354    });
355    checkPinned();
356}

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.