PageSourceSearch

https://www.aerobicyfitness.com/themes/aerobicyfitness_profesional…/views/js/front/smart_wishlist.js

js aerobicyfitness.com collected 2026-09-29 13:22:14 UTC 21,440 bytes, 549 lines download raw bytes

1/**
2 * 2008-2021 Prestaworld
3 *
4 * All right is reserved,
5 *
6 * @author    Prestaworld <[email protected]>
7 * @copyright 2008-2021 Prestaworld
8 * @license   One Paid Licence By WebSite Using This Module. No Rent. No Sell. No Share.
9 */
10
11$(document).ready(function(){
12    var id_product = $('input#idProduct').val();
13    var id_product_attr = $('input#idProductAttr').val();
14    if (typeof id_product !== 'undefined') {
15        checkProductWishList(id_product, id_product_attr);
16    }
17
18    $(document).on('click', '#select_multiple_items_of_wishlist', function() {
19        if ($('#select_multiple_items_of_wishlist').is(":checked")) {
20            $(".Productcheckbox").prop('checked', true);
21            console.log(get_selected_check_array());
22        } else {
23            $(".Productcheckbox").prop('checked', false);
24        }
25    });
26
27    function get_selected_check_array()
28    {
29        var optionArr = []
30        $(".Productcheckbox:checked").each(function(i, val) {
31            dataid = $(this).attr('data-id');
32            idProduct = $(this).attr('data-productid');
33            quantity = $('#quantityProduct_'+$(this).attr('data-id')).val();
34            idProductAttribute = $(this).attr('data-productattrid');
35            idProductCustomization = $(this).attr('data-customizationid');
36            var productData = {
37                "id":dataid,
38                "id_product": idProduct,
39                "quantity": quantity,
40                'id_product_attribute': idProductAttribute,
41                'id_product_customisation': idProductCustomization
42            }
43            optionArr.push(productData);
44        });
45        return optionArr;
46    }
47    $(document).on('click', '.wishlist_btn a.btn.btn-info', function(){
48        if (typeof presta_id_customer === 'undefined') {
49            alert(presta_customer_error);
50            return false;
51        }
52    });
53    $(document).on('click', '#delete_multiple_products', function(){
54        var multiple_products = get_selected_check_array();
55        if (multiple_products.length === 0) {
56            alert(presta_select_error);
57        } else {
58            $.ajax({
59                type: 'post',
60                cache: 'false',
61                dataType: 'json',
62                url : presta_mylist_url,
63                data : {
64                    'ajax': true,
65                    'action' : 'deletemultipleproduct',
66                    'multiple_products' : multiple_products
67                },
68                success: function(result) {
69                    if (result.status == 'ko'){
70                        $('#messageDiv').append('Product can not be removed from the wishlist');
71                    } else if (result.status == 'ok'){
72                        $('#messageDiv').append( 'Product successfully removed from wishlist');
73                        setTimeout(function(){
74                            window.location.reload();
75                        },1000);
76                    }
77                }
78            });
79        }
80        // console.log(multiple_products);
81    });
82
83    $(document).on('click', '#addtocart_multiple_products', function(){
84        var multiple_products = get_selected_check_array();
85        if (multiple_products.length === 0) {
86            alert(presta_select_error);
87        } else {
88            $.ajax({
89                type: 'post',
90                cache: 'false',
91                dataType: 'json',
92                url : presta_mylist_url,
93                data : {
94                    'ajax': true,
95                    'action' : 'addtocartmultipleproducts',
96                    'multiple_products' : multiple_products
97                },
98                success: function(result) {
99                    if (result.status == 'ko'){
100                        $('#messageDiv').append('Product can not be added to cart from the wishlist');
101                    } else if (result.status == 'ok'){
102                        $('#messageDiv').append( 'Product successfully added to cart from wishlist');
103                        setTimeout(function(){
104                            window.location.reload();
105                        },1000);
106                    }
107                }
108            });
109        }
110        // console.log(multiple_products);
111    });
112
113    $(document).on('click', '.productListBtn', function() {
114        if (typeof presta_id_customer === 'undefined') {
115            alert(presta_customer_error);
116            return false;
117        }
118        var id_product = $(this).attr("data-id-Product");
119        var id_product_attr = $(this).attr("data-id-Attribute");
120        var id_list = $(this).attr("data-default-Id");
121        var thisobject = $(this);
122        $.ajax({
123            type: 'post',
124            cache: 'false',
125            dataType: 'json',
126            url : presta_process_url,
127            data : {
128                'ajax': true,
129                'action' : 'whislistprocess',
130                'id_product' : id_product,
131                'id_product_attribute' : id_product_attr,
132                'id_list' : id_list
133            },
134            success: function(data) {
135                if (data.status == 'ko'){
136                    alert(data.msg);
137                } else if (data.status == 'ok'){
138                    // change image as per return response
139                    if (data.responsecode == 1) {
140                        // image will be red
141                        $('.wishlistCount').empty().append(data.count);
142                        // $("#Modal1").modal({backdrop: false});
143                        // $("#Modal1").modal();
144                        // setTimeout(function(){
145                        //     $("#Modal1").modal('hide');
146                        // },1000);
147                        $(thisobject).closest('.productListBtnDiv').find('.productListBtn').addClass('active');
148                    } else if (data.responsecode == 2) {
149                        // image will be white
150                        $('.wishlistCount').empty().append(data.count);
151                        // $("#Modal2").modal({backdrop: false});
152                        // $("#Modal2").modal();
153                        // setTimeout(function(){
154                        //     $("#Modal2").modal('hide');
155                        // },1000);
156                        $(thisobject).closest('.productListBtnDiv').find('.productListBtn').removeClass('active');
157                    }
158                }
159            }
160        });
161    });
162
163    $(document).on('click', '.presta_whistlist_process', function(e){
164        e.preventDefault();
165        var id_product = $('input#idProduct').val();
166        var id_product_attr = $('input#idProductAttr').val();
167        var idCustomization = $('input#idCustomization').val();
168        var product_quantity_wanted = $('input#product_quantity_wanted').val();
169        if (!product_quantity_wanted) {
170            product_quantity_wanted = 1;
171        }
172        var id_wishlist = $(this).attr("data-id");
173        if (id_wishlist){
174            var id_list = id_wishlist;//for another wishlist
175        }else {
176            var id_list = $('input#id_default_list').val();//for default wishlist
177        }
178        $.ajax({
179            type: 'post',
180            cache: 'false',
181            dataType: 'json',
182            url : presta_process_url,
183            data : {
184                'ajax': true,
185                'action' : 'whislistprocess',
186                'id_product' : id_product,
187                'id_product_attribute' : id_product_attr,
188                'idCustomization' : idCustomization,
189                'product_quantity_wanted' : product_quantity_wanted,
190                'id_list' : id_list
191            },
192            success: function(data) {
193                console.log(data.status);
194                console.log("FAVORITE");
195                if (data.status == 'ko'){
196                    alert(data.msg);
197                } else if (data.status == 'ok'){
198                    // change image as per return response
199                    if (data.responsecode == 1) {
200                        // image will be red
201                        // $('.presta_whistlist_process img').attr('src', added_img);
202                        $('.imgbtn').find('a').addClass('active');
203                        $('.wishlistCount').empty().append(data.count);
204                        // $("#Modal1").modal({backdrop: false});
205                        // $("#Modal1").modal();
206                        // setTimeout(function(){
207                        //     $("#Modal1").modal('hide');
208                        // },1000);
209                    } else if (data.responsecode == 2) {
210                        // image will be white
211                        // $('.presta_whistlist_process img').attr('src', normal_img);
212                        $('.imgbtn').find('a').removeClass('active');
213                        $('.wishlistCount').empty().append(data.count);
214                        // $("#Modal2").modal({backdrop: false});
215                        // $("#Modal2").modal();
216                        // setTimeout(function(){
217                        //     $("#Modal2").modal('hide');
218                        // },1000);
219                    }
220                }
221            }
222        });
223    });
224
225    // $(document).on('click', '.addToCartbtn', function(){
226    //     var idSwlProduct = $(this).attr("data-id");
227    //     $.ajax({
228    //         type: 'post',
229    //         cache: 'false',
230    //         dataType: 'json',
231    //         url : presta_mylist_url,
232    //         data : {
233    //             'ajax': true,
234    //             'action' : 'deletewishlistproduct',
235    //             'id_product_wishlist' : idSwlProduct
236    //         },
237    //         success: function(result) {
238    //             // window.location.reload();
239    //         }
240    //     });
241    // });
242
243
244    $(document).on('click', '#delete_swl_products', function(){
245        var idSwlProduct = $(this).attr("data-id");
246        $.ajax({
247            type: 'post',
248            cache: 'false',
249            dataType: 'json',
250            url : presta_mylist_url,
251            data : {
252                'ajax': true,
253                'action' : 'deletewishlistproduct',
254                'id_product_wishlist' : idSwlProduct
255            },
256            success: function(result) {
257                console.log(result.status);
258                if (result.status == 'ko'){
259                    $('#messageDiv').append('Product can not be removed from the wishlist');
260                } else if (result.status == 'ok'){
261                    $('#messageDiv').append( 'Product successfully removed from wishlist');
262                    setTimeout(function(){
263                        window.location.reload();
264                    },1000);
265                }
266            }
267        });
268    });
269
270    $(document).on('click', '#createlistbtn', function(){
271        var listName = $.trim($('input#newListName').val());
272        if (!listName) {
273            $('#newListName').css('border-color', 'red');
274            $('#presta-list-error').text(presta_list_error).addClass('alert alert-danger');
275            return false;
276        }
277        $.ajax({
278            type: 'post',
279            cache: 'false',
280            dataType: 'json',
281            url : presta_mylist_url,
282            data : {
283                'ajax': true,
284                'action' : 'createWishlist',
285                'listName' : listName
286            },
287            success: function(result) {
288                if (result.status == 'ko') {
289                    $('#messageDiv').append( 'Wishlist could not be created');
290                } else if (result.status == 'ok') {
291                    // $('#messageDiv').append(presta_list_success);
292                    $('#presta-list-error').append(presta_list_success).addClass('alert alert-success');
293                    setTimeout(function(){
294                        window.location.reload();
295                    },1000);
296                } else if (result.status == 'ko1') {
297                    $('#presta-list-error').text(presta_list_max_error).addClass('alert alert-danger');
298                }
299            },
300            beforeSend: function() {
301                $('#presta-list-error').text('').removeClass('alert alert-danger');
302                $('#newListName').css('border-color', 'inherit');
303            }
304        });
305    });
306
307    $(document).on('click', '#createlistathook', function(){
308        var listName = $.trim($('input#ListName').val());
309        if (!listName) {
310            $('#ListName').css('border-color', 'red');
311            $('#presta-list-error').text(presta_list_error).addClass('alert alert-danger');
312            return false;
313        }
314        if ($('#setIdDefault').is(":checked")) {
315            var setIdDefault = 1;
316        }
317        $.ajax({
318            type: 'post',
319            cache: 'false',
320            dataType: 'json',
321            url : presta_process_url,
322            data : {
323                'ajax': true,
324                'action' : 'createWishlist',
325                'listName' : listName,
326                'setIdDefault' : setIdDefault
327            },
328            success: function(result) {
329                console.log(result.status);
330                if (result.status == 'ko1') {
331                    $('#presta-list-error').text(presta_list_max_error).addClass('alert alert-danger');
332                } else if (result.status == 'ko'){
333                    $('#Modal3').empty();
334                    $('#Modal3').append('Wishlist could not be created');
335                    $("#Modal3").modal();
336                    setTimeout(function(){
337                        $("#Modal3").modal('hide');
338                    },2000);
339                } else if (result.status == 'ok'){
340                    $("#newList").modal('hide');
341                    $("#Modal3").modal();
342                    setTimeout(function() {
343                        window.location.reload();
344                    }, 2000);
345                }
346            }
347        });
348    });
349
350    $(document).on('click', '.moveToList', function(){
351        var idSwlist = $(this).attr("data-id");
352        var idProduct = $(this).attr("data-idproduct");
353        $.ajax({
354            type: 'post',
355            cache: 'false',
356            dataType: 'json',
357            url : presta_mylist_url,
358            data : {
359                'ajax': true,
360                'action' : 'moveToWishlist',
361                'idSwlist' : idSwlist,
362                'idSwlProduct':idProduct
363            },
364            success: function(result) {
365                console.log(result.status);
366                if (result.status == 'ko'){
367                    $('#messageDiv').append( 'Product can not be moved');
368                } else if (result.status == 'ok'){
369                    $('#messageDiv').append( 'Product successfully moved');
370                    setTimeout(function(){
371                        window.location.reload();
372                    },1000);
373                }
374            }
375        });
376    });
377
378    $(document).on('click', '#deleteListbtn', function(){
379        var idlist = $(this).attr("data-id");
380        var idlistDefault = $('input#id_list_default').val();
381        if (idlist == idlistDefault){
382            alert("Default list cannot be deleted");
383        }else{
384            $.ajax({
385                type: 'post',
386                cache: 'false',
387                dataType: 'json',
388                url : presta_mylist_url,
389                data : {
390                    'ajax': true,
391                    'action' : 'deletelist',
392                    'idlist' : idlist
393                },
394                success: function(result) {
395                    console.log(result.status);
396                    if (result.status == 'ko'){
397                        $('#messageDiv').append( 'Wishlist could not be deleted');
398                    } else if (result.status == 'ok'){
399                        $('#messageDiv').append( 'Wishlist succesfully deleted');
400                        setTimeout(function(){
401                            window.open(presta_mylist_url, "_self");
402                        },1000);
403                    }
404                }
405            });
406        }
407    });
408
409    $(document).on('click', '#addIdeaToList', function(){
410        $("#addIdeaToList").hide();
411        $(".addIdeaInput").css("display", "block");
412    });
413
414    $(document).on('click', '#updatelist', function(){
415        var listName = $('input#ListName').val();
416        var idlist = $(this).attr("data-id");
417        var RecipientName = $('input#RecipientName').val();
418        var listDescription = $('textarea#listDescription').val();
419        if ($('#setIdDefault').is(":checked"))
420        {
421            var setIdDefault = $('input#setIdDefault').val();
422        }
423        $.ajax({
424            type: 'post',
425            cache: 'false',
426            dataType: 'json',
427            url : presta_mylist_url,
428            data : {
429                'ajax': true,
430                'action' : 'updatelistsettings',
431                'listName' : listName,
432                'RecipientName' : RecipientName,
433                'listDescription' : listDescription,
434                'setIdDefault' : setIdDefault,
435                'idlist' : idlist
436            },
437            success: function(result) {
438                console.log(result.status);
439                if (result.status == 'ko'){
440                    $('#messageDiv').append( 'Wishlist settings could not be updated');
441                } else if (result.status == 'ok'){
442                    $('#messageDiv').append( 'Wishlist settings succesfully updated');
443                    setTimeout(function(){
444                        window.location.reload();
445                    },1000);
446                }
447            }
448        });
449    });
450
451    $(document).on('click', '#searchbutton', function(){
452        var query = $('input#searchBar').val();
453        var id_wishlist = $('input#idwishList').val();
454        if (id_wishlist == ""){
455            var id_wishlist = $('input#id_list').val();
456        }
457        $.ajax({
458            type: 'post',
459            cache: 'false',
460            // dataType: 'json',
461            url : presta_mylist_url,
462            data : {
463                'ajax': true,
464                'action' : 'searchquery',
465                'query' : query,
466                'id_wishlist' :id_wishlist
467            },
468            success: function(result) {
469                if (result) {
470                    $('.contentItems').empty().append(result);
471                } else {
472                    $('.contentItems').empty();
473                }
474            }
475        });
476    });
477
478    $('#searchBar').keypress(function (e) {
479        var key = e.which;
480        if (key == 13) {
481            $('#searchbutton').trigger('click');
482            return false;
483        }
484    });
485
486    $(document).on('click', '#copylink', function(){
487        var share_url = $(this).attr("data-url");
488        $("#presta_texturl").select();
489        document.execCommand("copy");
490        alert("Url copied");
491        window.location.reload();
492    });
493
494    $("#printList").on("click", function () {
495        var listName = $('input#ListName').val();
496        $(".hide_print").empty();
497        var divContents = $(".contentItems").html();
498        var printWindow = window.open('', '', 'height=800,width=800');
499        printWindow.document.write('<html><head><title>DIV Contents</title><h2>');
500        printWindow.document.write(listName);
501        printWindow.document.write('</h2></head><body ><div style="text-align:center;">');
502        printWindow.document.write(divContents);
503        printWindow.document.write('</div></body></html>');
504        printWindow.document.close();
505        printWindow.print();
506        window.location.reload();
507    });
508
509    $("#myBtn2").click(function(){
510        $("#myModal2").modal({backdrop: false});
511    });
512});
513
514$(document).ready(function () {
515    prestashop.on(
516        'updatedProduct',
517        function (event) {
518            if (typeof presta_wishlist_id_product !== 'undefined') {
519                checkProductWishList(presta_wishlist_id_product, event.id_product_attribute);
520            }
521        }
522    );
523});
524
525function checkProductWishList(id_product, id_product_attribute)
526{
527    $.ajax({
528        type: 'post',
529        cache: 'false',
530        dataType: 'json',
531        url : presta_process_url,
532        data : {
533            'ajax': true,
534            'action' : 'checkproductexist',
535            'id_product' : id_product,
536            'id_product_attribute' : id_product_attribute,
537            'id_default_list' : parseInt($('input#id_default_list').val())
538        },
539        success: function(checked) {
540            if (checked.responsecode == 3){
541                $('.imgbtn').find('a').addClass('active');
542                $('.wishlistCount').empty().append(checked.count);
543            } else{
544                $('.imgbtn').find('a').removeClass('active');
545                $('.wishlistCount').empty().append(checked.count);
546            }
547        }
548    });
549}

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.