PageSourceSearch

https://www.sundancemarineusa.com/assets/js/expressCart.js

js sundancemarineusa.com collected 2026-10-04 15:58:02 UTC 40,787 bytes, 1,248 lines download raw bytes

1/* eslint-disable prefer-arrow-callback,  no-var, no-tabs */
2$(document).ready(function (){
3
4
5    // setup if material theme
6    // if($('#cartTheme').val() === 'Material'){
7    //     $('.materialboxed').materialbox();
8
9    // }
10
11
12
13    // twilio script form
14     $('#phone-boat').submit(function(){
15        //event.preventDefault();
16        var msg=$('#phone_message').val();
17        var send_to=$('#text_to').val();
18        var boatImage=$('#timage').attr('src');
19        //var vmsg=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
20        if(true){
21          $.ajax({
22            global:false,
23            type:'post',
24            url:'/sendtext',
25            dataType:'json',
26            data:{
27                phone_message:msg,send_to:send_to,boatImage:boatImage
28            },
29            success:function(result){
30                showNotification("Message Successfully Sent", 'success');
31            },
32            error: function (request, status, error) {
33                showNotification("Some error occur while sending message", 'success');
34            }
35          });
36         }
37        else {
38            console.log("not")
39        }
40            return false;
41    });
42    //end
43
44    if($(window).width() < 768){
45        $('.menu-side').on('click', function(e){
46            e.preventDefault();
47            $('.menu-side li:not(".active")').slideToggle();
48        });
49
50        $('.menu-side li:not(".active")').hide();
51        $('.menu-side>.active').html('<i class="fa fa-bars" aria-hidden="true"></i>');
52        $('.menu-side>.active').addClass('menu-side-mobile');
53
54        // hide menu if there are no items in it
55        if($('#navbar ul li').length === 0){
56            $('#navbar').hide();
57        }
58
59        $('#offcanvasClose').hide();
60    }
61
62    $('.shipping-form input').each(function(e){
63        $(this).wrap('<fieldset></fieldset>');
64        var tag = $(this).attr('placeholder');
65        $(this).after('<label for="name" class="hidden">' + tag + '</label>');
66    });
67
68    $('.shipping-form input').on('focus', function(){
69        $(this).next().addClass('floatLabel');
70        $(this).next().removeClass('hidden');
71    });
72
73    $('.shipping-form input').on('blur', function(){
74        if($(this).val() === ''){
75            $(this).next().addClass('hidden');
76            $(this).next().removeClass('floatLabel');
77        }
78    });
79
80    $('.word_cart').on('click', function(e){
81        e.preventDefault();
82    });
83
84    $('.updateSettingsAdmin').on('click', function(e){
85        e.preventDefault();
86        $.ajax({
87            method: 'POST',
88            url: '/admin/settings/update',
89            data:{'cartTitle':$("#cart-title").val(),
90                'cartDescription':$('#cart-description').val(),
91                'cartLogo':$('#cartLogo').val(),
92                'baseUrl':$('#baseUrl').val(),
93                'emailAddress':$('#emailAddress').val(),
94                'flatShipping':$('#flatShipping').val(),
95                'freeShippingAmount':$("#freeShippingAmount").val(),
96                'currencySymbol':$("#currencySymbol").val(),
97                'theme':$("#theme").val(),
98                'productsPerRow':$('#productsPerRow').val(),
99                'productsPerPage':$('#productsPerPage').val(),
100                //'menuEnabled':$("#menuEnabled").val(),
101                'menuEnabled':$("#menuEnabled").is(':checked') ? true : false,
102                'menuTitle':$('#menuTitle').val(),
103                'menuLocation':$('#menuLocation').val(),
104                'footerHtml_input':$('#footerHtml_input').val(),
105                'googleAnalytics_input':$('#googleAnalytics_input').val(),
106                'googleTagManagerHeader_input':$('#googleTagManagerHeader_input').val(),
107                'googleTagManagerBody_input':$('#googleTagManagerBody_input').val(),
108                'customCss_input':$('#customCss_input').val(),
109                'emailHost':$('#emailHost').val(),
110                'emailPort':$('#emailPort').val(),
111                //'emailSecure':$('#emailSecure').val(),
112                'emailSecure':$("#emailSecure").is(':checked') ? true : false,
113                // 'emailUser':$('#emailUser').val(),
114                // 'emailPassword':$('#emailPassword').val(),
115                'recaptchaPrivateKey':$('#recaptchaPrivateKey').val(),
116                'apiKeySendGrid':$("#apiKeySendGrid").val(),
117                //'newsletterActive':$('#newsletterActive').val(),
118                'newsletterActive':$("#newsletterActive").is(':checked') ? true : false,
119                'mailChimpApiKey':$('#mailChimpApiKey').val(),
120                'mailChimpListId':$('#mailChimpListId').val()}
121        })
122        .done(function(msg){
123            showNotification(msg, 'success');
124        })
125        .fail(function(msg) {
126            const errorMessage = msg.responseJSON && msg.responseJSON.message 
127                ? msg.responseJSON.message 
128                : 'An error occurred. Please try again.';
129            showNotification(errorMessage, 'danger');
130        });
131        
132    });
133
134    if($('#footerHtml').length){
135        var footerHTML = window.CodeMirror.fromTextArea(document.getElementById('footerHtml'), {
136            mode: 'xml',
137            tabMode: 'indent',
138            theme: 'flatly',
139            lineNumbers: true,
140            htmlMode: true,
141            fixedGutter: false
142        });
143
144        footerHTML.setValue(footerHTML.getValue());
145    }
146
147    $('#googleAnalytics').on('change',function(){
148        $('#googleAnalytics_input').val($('#googleAnalytics').val())
149    })
150
151
152    $('#googleTagManagerHeader').on('change',function(){
153        $('#googleTagManagerHeader_input').val($('#googleTagManagerHeader').val())
154    })
155
156
157    $('#googleTagManagerBody').on('change',function(){
158        $('#googleTagManagerBody_input').val($('#googleTagManagerBody').val())
159    })
160
161    // if($('#googleAnalytics').length){
162    //     window.CodeMirror.fromTextArea(document.getElementById('googleAnalytics'), {
163    //         mode: 'xml',
164    //         tabMode: 'indent',
165    //         theme: 'flatly',
166    //         lineNumbers: true,
167    //         htmlMode: true,
168    //         fixedGutter: false
169    //     });
170    // }
171
172    if($('#customCss').length){
173        var customCss = window.CodeMirror.fromTextArea(document.getElementById('customCss'), {
174            mode: 'text/css',
175            tabMode: 'indent',
176            theme: 'flatly',
177            lineNumbers: true
178        });
179
180        var customCssBeautified = window.cssbeautify(customCss.getValue(), {
181            indent: '   ',
182            autosemicolon: true
183        });
184        customCss.setValue(customCssBeautified);
185    }
186
187    // add the table class to all tables
188    $('table').each(function(){
189        $(this).addClass('table table-hover');
190    });
191
192    // if(window.location.pathname.split('/')[1] == 'admin'){
193    //     $('#frmProductTags').tokenfield();
194    // }
195
196    // if(window.location.pathname.split('/')[1] == 'admin'){
197    //     $('.product-title').dotdotdot({
198    //         ellipsis: '...'
199    //     });
200    // }
201
202
203    $(document).on('click', '.dashboard_list', function(e){
204        window.document.location = $(this).attr('href');
205    }).hover(function(){
206        $(this).toggleClass('hover');
207    });
208
209
210    // Call to API for a change to the published state of a product
211    $('input[class="published_state"]').change(function(){
212        $.ajax({
213            method: 'POST',
214            url: '/admin/product/published_state',
215            data: {id: this.id, state: this.checked}
216        })
217        .done(function(msg){
218            showNotification(msg.message, 'success');
219        })
220        .fail(function(msg){
221            showNotification(msg.responseJSON.message, 'danger');
222        });
223    });
224
225    $(document).on('click', '.btn-qty-minus', function(e){
226        var qtyElement = $(e.target).parent().parent().find('.cart-product-quantity');
227        $(qtyElement).val(parseInt(qtyElement.val()) - 1);
228        cartUpdate(qtyElement);
229    });
230
231    $(document).on('click', '.btn-qty-add', function(e){
232        var qtyElement = $(e.target).parent().parent().find('.cart-product-quantity');
233        $(qtyElement).val(parseInt(qtyElement.val()) + 1);
234        cartUpdate(qtyElement);
235    });
236
237    $(document).on('click', '.btn-delete-from-cart', function(e){
238
239        deleteFromCart($(e.target));
240    });
241
242    $(document).on('click', '.orderFilterByStatus', function(e){
243        e.preventDefault();
244        window.location = '/admin/orders/bystatus/' + $('#orderStatusFilter').val();
245    });
246
247    if($('#pager').length){
248        var pageNum = $('#pageNum').val();
249        var pageLen = $('#productsPerPage').val();
250        var productCount = $('#totalProductCount').val();
251        var paginateUrl = $('#paginateUrl').val();
252        var searchTerm = $('#searchTerm').val();
253
254        if(searchTerm !== ''){
255            searchTerm = searchTerm + '/';
256        }
257
258        var pagerHref = '/' + paginateUrl + '/' + searchTerm + '{{number}}';
259        var totalProducts = Math.ceil(productCount / pageLen);
260
261        if(parseInt(productCount) > parseInt(pageLen)){
262            $('#pager').bootpag({
263                total: totalProducts,
264                page: pageNum,
265                maxVisible: 12,
266                href: pagerHref,
267                wrapClass: 'pagination',
268                prevClass: 'waves-effect',
269                nextClass: 'waves-effect',
270                activeClass: 'pag-active waves-effect'
271            });
272        }
273    }
274
275    $(document).on('click', '#btnPageUpdate', function(e) {
276        e.preventDefault();
277    
278        // Validate fields
279        let isValid = true;
280        $('#pageName, #pageSlug, #pageContent').each(function() {
281            if ($(this).prop('required') && !$(this).val().trim()) {
282                $(this).addClass('is-invalid');
283                isValid = false;
284            } else {
285                $(this).removeClass('is-invalid');
286            }
287        });
288    
289        // Show error if any field is invalid
290        if (!isValid) {
291            showNotification('Please fill in all required fields.', 'danger');
292            return;
293        }
294    
295        // AJAX request
296        $.post('/admin/settings/pages/update', {
297            page_id: $('#page_id').val(),
298            pageName: $('#pageName').val(),
299            pageSlug: $('#pageSlug').val(),
300            pageEnabled: $('#pageEnabled').is(':checked'),
301            pageContent: $('#pageContent').val()
302        })
303        .done(function(msg) {
304            showNotification(msg.message, 'success');
305            window.location.href = '/admin/settings/pages';
306        })
307        .fail(function(msg) {
308            showNotification(msg.responseJSON.message, 'danger');
309        });
310    });
311    
312
313    $(document).on('click', '.product_opt_remove', function(e){
314        e.preventDefault();
315        var name = $(this).closest('li').find('.opt-name').html();
316
317        $.ajax({
318            method: 'POST',
319            url: '/admin/settings/option/remove/',
320            data: {productId: $('#frmProductId').val(), optName: name}
321        })
322        .done(function(msg){
323            showNotification(msg.message, 'success', true);
324        })
325        .fail(function(msg){
326            showNotification(msg.responseJSON.message, 'danger');
327        });
328    });
329
330    $(document).on('click', '#product_opt_add', function(e){
331        e.preventDefault();
332
333        var optName = $('#product_optName').val();
334        var optLabel = $('#product_optLabel').val();
335        var optType = $('#product_optType').val();
336        var optOptions = $('#product_optOptions').val();
337
338        var optJson = {};
339        if($('#productOptJson').val() !== ''){
340            optJson = JSON.parse($('#productOptJson').val());
341        }
342
343        var html = '<li class="list-group-item">';
344        html += '<div class="row">';
345        html += '<div class="col-lg-2 opt-name">' + optName + '</div>';
346        html += '<div class="col-lg-2">' + optLabel + '</div>';
347        html += '<div class="col-lg-2">' + optType + '</div>';
348        html += '<div class="col-lg-4">' + optOptions + '</div>';
349        html += '<div class="col-lg-2 text-right">';
350        html += '<button class="product_opt_remove btn btn-danger btn-sm">Remove</button>';
351        html += '</div></div></li>';
352
353        // append data
354        $('#product_opt_wrapper').append(html);
355
356        // add to the stored json string
357        optJson[optName] = {
358            optName: optName,
359            optLabel: optLabel,
360            optType: optType,
361            optOptions: $.grep(optOptions.split(','), function(n){ return n === 0 || n; })
362        };
363
364        // write new json back to field
365        $('#productOptJson').val(JSON.stringify(optJson));
366
367        // clear inputs
368        $('#product_optName').val('');
369        $('#product_optLabel').val('');
370        $('#product_optOptions').val('');
371    });
372
373
374    $('#customerLogout').on('click', function(e){
375        $.ajax({
376            method: 'POST',
377            url: '/customer/logout',
378            data: {}
379        })
380        .done(function(msg){
381            location.reload();
382        });
383    });
384
385    if(window.location.pathname.split('/')[1] == 'pay' || window.location.pathname.split('/')[1] == 'checkout'){
386
387        $('#createCustomerAccount').validator().on('click', function(e){
388            e.preventDefault();
389            if($('#shipping-form').validator('validate').has('.has-error').length === 0){
390                $.ajax({
391                    method: 'POST',
392                    url: '/customer/create',
393                    data: {
394                        email: $('#shipEmail').val(),
395                        firstName: $('#shipFirstname').val(),
396                        lastName: $('#shipLastname').val(),
397                        address1: $('#shipAddr1').val(),
398                        address2: $('#shipAddr2').val(),
399                        country: $('#shipCountry').val(),
400                        state: $('#shipState').val(),
401                        postcode: $('#shipPostcode').val(),
402                        phone: $('#shipPhoneNumber').val(),
403                        password: $('#newCustomerPassword').val()
404                    }
405                })
406                .done(function(msg){
407                    // Just reload to fill in the form from session
408                    location.reload();
409                })
410                .fail(function(msg){
411                    showNotification(msg.responseJSON.err, 'danger');
412                });
413            }
414        });
415    }
416
417    $('#loginForm').on('click', function(e){
418
419        if(!e.isDefaultPrevented()){
420            e.preventDefault();
421            $.ajax({
422                method: 'POST',
423                url: '/admin/login_action',
424                data: {
425                    email: $('#useremail').val(),
426                    password: $('#userpassword').val()
427                }
428            })
429            .done(function(msg){
430                window.location = '/admin';
431            })
432            .fail(function(msg){
433                showNotification(msg.responseJSON.message, 'danger');
434            });
435        }
436        e.preventDefault();
437    });
438
439    // call update settings API
440    $('#customerLogin').on('click', function(e){
441        if(!e.isDefaultPrevented()){
442            e.preventDefault();
443            $.ajax({
444                method: 'POST',
445                url: '/customer/login_action',
446                data: {
447                    loginEmail: $('#customerLoginEmail').val(),
448                    loginPassword: $('#customerLoginPassword').val()
449                }
450            })
451            .done(function(msg){
452                var customer = msg.customer;
453                // Fill in customer form
454                $('#shipEmail').val(customer.email);
455                $('#shipFirstname').val(customer.firstName);
456                $('#shipLastname').val(customer.lastName);
457                $('#shipAddr1').val(customer.address1);
458                $('#shipAddr2').val(customer.address2);
459                $('#shipCountry').val(customer.country);
460                $('#shipState').val(customer.state);
461                $('#shipPostcode').val(customer.postcode);
462                $('#shipPhoneNumber').val(customer.phone);
463                location.reload();
464            })
465            .fail(function(msg){
466                showNotification(msg.responseJSON.message, 'danger');
467            });
468        }
469        e.preventDefault();
470    });
471
472    $(document).on('click', '.image-next', function(e){
473        var thumbnails = $('.thumbnail-image');
474        var index = 0;
475        var matchedIndex = 0;
476
477        // get the current src image and go to the next one
478        $('.thumbnail-image').each(function(){
479            if($('#product-title-image').attr('src') === $(this).attr('src')){
480                if(index + 1 === thumbnails.length || index + 1 < 0){
481                    matchedIndex = 0;
482                }else{
483                    matchedIndex = index + 1;
484                }
485            }
486            index++;
487        });
488
489        // set the image src
490        $('#product-title-image').attr('src', $(thumbnails).eq(matchedIndex).attr('src'));
491    });
492
493    $(document).on('click', '.image-prev', function(e){
494        var thumbnails = $('.thumbnail-image');
495        var index = 0;
496        var matchedIndex = 0;
497
498        // get the current src image and go to the next one
499        $('.thumbnail-image').each(function(){
500            if($('#product-title-image').attr('src') === $(this).attr('src')){
501                if(index - 1 === thumbnails.length || index - 1 < 0){
502                    matchedIndex = thumbnails.length - 1;
503                }else{
504                    matchedIndex = index - 1;
505                }
506            }
507            index++;
508        });
509
510        // set the image src
511        $('#product-title-image').attr('src', $(thumbnails).eq(matchedIndex).attr('src'));
512    });
513
514    $(document).on('click', '#orderStatusUpdate', function(e){
515        $.ajax({
516            method: 'POST',
517            url: '/admin/order/statusupdate',
518            data: {order_id: $('#order_id').val(), status: $('#orderStatus').val()}
519        })
520        .done(function(msg){
521            showNotification(msg.message, 'success', true);
522        })
523        .fail(function(msg){
524            showNotification(msg.responseJSON.message, 'danger');
525        });
526    });
527
528    $(document).on('click', '.product-add-to-cart', function(e){
529        var productOptions = getSelectedOptions();
530
531        if(parseInt($('#product_quantity').val()) < 0){
532            $('#product_quantity').val(0);
533        }
534
535        $.ajax({
536            method: 'POST',
537            url: '/product/addtocart',
538            data: {
539                productId: $('#productId').val(),
540                productQuantity: $('#product_quantity').val() ? $('#product_quantity').val():1,
541                productOptions: JSON.stringify(productOptions),
542                productComment: $('#product_comment').val()
543            }
544        })
545        .done(function(msg){
546
547            $('#cart-count').text(msg.totalCartItems);
548            updateCartDiv();
549            showNotification(msg.message, 'success');
550        })
551        .fail(function(msg){
552            showNotification(msg.responseJSON.message, 'danger');
553        });
554    });
555
556    $('.cart-product-quantity').on('input', function(){
557        cartUpdate();
558    });
559
560    $(document).on('click', '.pushy-link', function(e){
561        $('body').removeClass('pushy-open-right');
562    });
563
564    $(document).on('click', '.add-to-cart', function(e){
565        var productLink = '/product/' + $(this).attr('data-id');
566        if($(this).attr('data-link')){
567            productLink = '/product/' + $(this).attr('data-link');
568        }
569
570        if($(this).attr('data-has-options') === 'true'){
571            window.location = productLink;
572        }else{
573            $.ajax({
574                method: 'POST',
575                url: '/product/addtocart',
576                data: {productId: $(this).attr('data-id')}
577            })
578            .done(function(msg){
579                $('#cart-count').text(msg.totalCartItems);
580                updateCartDiv();
581                showNotification(msg.message, 'success');
582            })
583            .fail(function(msg){
584                showNotification(msg.responseJSON.message, 'danger');
585            });
586        }
587    });
588
589    $(document).on('click', '#empty-cart', function(e){
590        $.ajax({
591            method: 'POST',
592            url: '/product/emptycart'
593        })
594        .done(function(msg){
595            $('#cart-count').text(msg.totalCartItems);
596            updateCartDiv();
597            showNotification(msg.message, 'success', true);
598        });
599    });
600
601    $('.qty-btn-minus').on('click', function(){
602        $('#product_quantity').val(parseInt($('#product_quantity').val()) - 1);
603    });
604
605    $('.qty-btn-plus').on('click', function(){
606        $('#product_quantity').val(parseInt($('#product_quantity').val()) + 1);
607    });
608
609    // product thumbnail image click
610    $('.thumbnail-image').on('click', function(){
611        $('#product-title-image').attr('src', $(this).attr('src'));
612    });
613
614    // $('.set-as-main-image').on('click', function(){
615    //     $.ajax({
616    //         method: 'POST',
617    //         url: '/admin/product/setasmainimage',
618    //         data: {product_id: $('#frmProductId').val(), productImage: $(this).attr('data-id')}
619    //     })
620    //  .done(function(msg){
621    //         showNotification(msg.message, 'success', true);
622    //     })
623    //     .fail(function(msg){
624    //         showNotification(msg.responseJSON.message, 'danger');
625    //     });
626    // });
627
628    // $('.btn-delete-image').on('click', function(){
629    //     $.ajax({
630    //         method: 'POST',
631    //         url: '/admin/product/deleteimage',
632    //         data: {product_id: $('#frmProductId').val(), productImage: $(this).attr('data-id')}
633    //     })
634    //  .done(function(msg){
635    //         showNotification(msg.message, 'success', true);
636    //     })
637    //     .fail(function(msg){
638    //         showNotification(msg.responseJSON.message, 'danger');
639    //     });
640    // });
641
642    // Call to API to check if a permalink is available
643    $(document).on('click', '#validate_permalink', function(e){
644        var permalink ,docId ,postType
645
646        if(window.location.pathname.split('/')[2] == 'product'){
647                permalink =$('#frmProductPermalink').val()
648                docId = $('#frmProductId').val()
649                postType = 'product'
650        }else{
651                permalink =  $('#frmboatPermalink').val()
652                docId =$('#frmboatId').val()
653                postType = 'boat'
654        }
655
656        if($('#frmProductPermalink').val() !== ''){
657            $.ajax({
658                method: 'POST',
659                url: '/admin/api/validate_permalink',
660                data: {'permalink': permalink, 'docId':docId,'postType':postType }
661            })
662            .done(function(msg){
663                showNotification(msg.message, 'success');
664            })
665            .fail(function(msg){
666                showNotification(msg.responseJSON.message, 'danger');
667            });
668        }else{
669            showNotification('Please enter a permalink to validate', 'danger');
670        }
671    });
672
673    // applies an product filter
674    $(document).on('click', '#btn_product_filter', function(e){
675        if($('#product_filter').val() !== ''){
676            window.location.href = '/admin/products/filter/' + $('#product_filter').val();
677        }else{
678            showNotification('Please enter a keyword to filter', 'danger');
679        }
680    });
681
682    // applies an order filter
683    $(document).on('click', '#btn_order_filter', function(e){
684        if($('#order_filter').val() !== ''){
685            window.location.href = '/admin/orders/filter/' + $('#order_filter').val();
686        }else{
687            showNotification('Please enter a keyword to filter', 'danger');
688        }
689    });
690
691    // applies an product filter
692    $(document).on('click', '#btn_customer_filter', function(e){
693        if($('#customer_filter').val() !== ''){
694            window.location.href = '/admin/customers/filter/' + $('#customer_filter').val();
695        }else{
696            showNotification('Please enter a keyword to filter', 'danger');
697        }
698    });
699
700    $(document).on('click', '#btn_employment_search_filter', function(e){
701        var department = $('#employment_department').val();
702        var type = $('#employment_type').val();
703        var location = $('#employment_location').val();
704        window.location.href = '/employment/' + department+'/'+type+'/'+location;
705    });
706
707    $(document).on('click', '#btn_employment_filter', function(e){
708        if($('#boat_filter').val() !== ''){
709            window.location.href = '/admin/employments/filter/' + $('#employment_filter').val();
710        }else{
711            showNotification('Please enter a keyword to filter', 'danger');
712        }
713    });
714
715    $(document).on('click', '#btn_event_filter', function(e){
716        if($('#event_filter').val() !== ''){
717            window.location.href = '/admin/events/filter/' + $('#event_filter').val();
718        }else{
719            showNotification('Please enter a keyword to filter', 'danger');
720        }
721    });
722
723    $(document).on('click', '#btn_event_new_filter', function(e){
724        if($('#event_filter').val() !== ''){
725            window.location.href = '/admin/events/filter/' + $('#event_filter').val();
726        }else{
727            showNotification('Please enter a keyword to filter', 'danger');
728        }
729    });
730
731
732    // resets the order filter
733    $(document).on('click', '#btn_search_reset', function(e){
734        window.location.replace('/');
735    });
736
737    // search button click event
738    $(document).on('click', '#btn_search', function(e){
739        e.preventDefault();
740        if($('#frm_search').val().trim() === ''){
741            showNotification('Please enter a search value', 'danger');
742        }else{
743            window.location.href = '/search/' + $('#frm_search').val();
744        }
745    });
746
747    // create a permalink from the product title if no permalink has already been set
748    $(document).on('click', '#frm_edit_product_save', function(e){
749        if($('#frmProductPermalink').val() === '' && $('#frmProductTitle').val() !== ''){
750            $('#frmProductPermalink').val(slugify($('#frmProductTitle').val()));
751        }
752    });
753
754    if($('#input_notify_message').val() !== ''){
755        // save values from inputs
756        var messageVal = $('#input_notify_message').val();
757        var messageTypeVal = $('#input_notify_messageType').val();
758
759        // clear inputs
760        $('#input_notify_message').val('');
761        $('#input_notify_messageType').val('');
762
763        // alert
764        showNotification(messageVal, messageTypeVal, false);
765    }
766
767    $('#menu-type').on('change',function(){
768        $('.menu_location').val($('#menu-type').val())
769    })
770
771   if (screen.width <= 480) {
772
773    var anchor = document.querySelector('.dropdown.big_hover a');
774    if (anchor) {
775        anchor.removeAttribute('href');
776    }
777
778    var dropdownBigHover = document.querySelector('.dropdown.big_hover');
779    if (dropdownBigHover) {
780        dropdownBigHover.classList.remove('dropdown');
781    }
782
783    $(".big_hover").on('click', function () {
784        $(".dropdown-content").toggle("display");
785    });
786}
787
788
789    $('.clickable').on('click',function(){
790        $(this).parent().find('.firstLink').first().toggle('display')
791    })
792
793    $('.update-menu').on('click',function(){
794        var parent = $(this).parent()
795        parent.parent().data('title',parent.find('#title').val())
796        parent.parent().data('link',parent.find('#link').val())
797        parent.parent().data('meta_title',parent.find('#meta_title').val())
798        parent.parent().data('meta_description',parent.find('#meta_description').val())
799        parent.parent().data('meta_keyword',parent.find('#meta_keyword').val())
800        parent.parent().data('open_in',parent.find('#open_in').val())
801        parent.parent().find('.clickable').first().text(parent.find('#title').val())
802        parent.toggle('display')
803        setMenu()
804    })
805
806    $('#pages-available').on('change',function(){
807        $('#navMenu').val($('#pages-available option:selected').text())
808        $('#navLink').val($(this).val())
809        $("#permalink-test").attr('href','/'+$(this).val())
810        $("#permalink-test").text('http://52.15.98.253/'+$(this).val())
811
812    })
813
814    //##############################################################
815    //
816    //      End of the $(document).ready()
817    //##############################################################
818});
819
820function deleteFromCart(element){
821    $.ajax({
822        method: 'POST',
823        url: '/product/removefromcart',
824        data: {cart_index: element.attr('data-id')}
825    })
826    .done(function(msg){
827        $('#cart-count').text(msg.totalCartItems);
828        if(msg.totalCartItems === 0){
829            $(element).closest('.cart-row').hide('slow', function(){
830                $(element).closest('.cart-row').remove();
831            });
832            $('.cart-contents-shipping').hide('slow', function(){
833                $('.cart-contents-shipping').remove();
834            });
835            showNotification(msg.message, 'success');
836            setTimeout(function(){
837                window.location = '/products';
838            }, 3700);
839        }else{
840            $(element).closest('.cart-row').hide('slow', function(){ $(element).closest('.cart-row').remove(); });
841            showNotification(msg.message, 'success');
842        }
843    })
844    .fail(function(msg){
845        showNotification(msg.responseJSON.message, 'danger');
846    });
847}
848
849function slugify(str){
850    var $slug = '';
851    var trimmed = $.trim(str);
852    $slug = trimmed.replace(/[^a-z0-9-æøå]/gi, '-')
853    .replace(/-+/g, '-')
854    .replace(/^-|-$/g, '')
855    .replace(/æ/gi, 'ae')
856    .replace(/ø/gi, 'oe')
857    .replace(/Ã¥/gi, 'a');
858    return $slug.toLowerCase();
859}
860
861function cartUpdate(element){
862    if($(element).val() > 0){
863        if($(element).val() !== ''){
864            updateCart();
865        }
866    }else{
867        $(element).val(1);
868    }
869}
870
871function updateCart(){
872    // gather items of cart
873    var cartItems = [];
874    $('.cart-product-quantity').each(function(){
875        var item = {
876            cartIndex: $(this).attr('id'),
877            itemQuantity: $(this).val(),
878            productId: $(this).attr('data-id')
879        };
880        cartItems.push(item);
881    });
882
883    // update cart on server
884    $.ajax({
885        method: 'POST',
886        url: '/product/updatecart',
887        data: {items: JSON.stringify(cartItems)}
888    })
889    .done(function(msg){
890        // update cart items
891        updateCartDiv();
892        $('#cart-count').text(msg.totalCartItems);
893    })
894    .fail(function(msg){
895        showNotification(msg.responseJSON.message, 'danger');
896    });
897}
898
899function updateCartDiv(){
900    // get new cart render
901    var path = window.location.pathname.split('/').length > 0 ? window.location.pathname.split('/')[1] : '';
902    $.ajax({
903        method: 'GET',
904        url: '/cartPartial',
905        data: {path: path}
906    })
907    .done(function(msg){
908        // update cart div
909        $('#cart').html(msg);
910    })
911    .fail(function(msg){
912        showNotification(msg.responseJSON.message, 'danger');
913    });
914}
915
916function getSelectedOptions(){
917    var options = {};
918    $('.product-opt').each(function(){
919        options[$(this).attr('name')] = $(this).val();
920
921    });
922
923    return options;
924}
925
926// show notification popup
927function showNotification(msg, type, reloadPage){
928    // defaults to false
929    //reloadPage = reloadPage || false;
930
931    $('#notify_message').removeClass();
932    $('#notify_message').addClass('alert alert-' + type);
933    $('#notify_message').html(msg);
934    $('#notify_message').slideDown(600).delay(2500).slideUp(600, function(){
935        if(reloadPage === true){
936            location.reload();
937        }
938    });
939}
940function showPopupNotification(msg, type, reloadPage){
941    $('.notify_popup_message').removeClass('alert-success');
942    $('.notify_popup_message').removeClass('alert-danger');
943    $('.notify_popup_message').addClass('alert-' + type);
944    $('.notify_popup_message').html(msg);
945    $('.notify_popup_message').slideDown(600).delay(2500).slideUp(600, function(){
946        if(reloadPage === true){
947            location.reload();
948        }
949    });
950}
951
952function deleteMenuLink(me){
953    me.parentNode.parentNode.removeChild(me.parentNode)
954    setMenu()
955
956}
957
958function setMenu(){
959    var data = group.sortable("serialize").get();
960
961    $.ajax({
962        type: 'POST',
963        url: '/admin/settings/menu/save_order',
964        dataType: 'JSON',
965        data: {data:JSON.stringify(data),menuLocation:$('.menu_location').val()},
966        success:function(){
967            console.log("Here")
968        },
969        error:function(){
970            console.log("Error")
971        }
972    })
973    .fail(function(msg){
974        showNotification(msg.responseJSON.message, 'danger');
975    });
976}
977
978function restoreMenu(){
979
980    if(confirm("Your all changes will be reverted to default is it ok ?")){
981        $.ajax({
982            type: 'POST',
983            url: '/admin/restore/menu',
984            success:function(msg){
985                showNotification(msg.message,'success',true)
986            },
987            error:function(){
988                showNotification(msg.message,'danger')
989            }
990        })
991    }
992}
993
994
995function fieldChecks(me){
996
997    if(/^[a-zA-Z ]+$/.test(me.value)){
998        console.log("Alphabets and space")
999    }else if(/^[0-9 ]+$/.test(me.value)){
1000        console.log("Numeric and space")
1001    }else if(/^[0-9a-zA-Z ]+$/.test(me.value)){
1002        console.log("Aplphanumeric and space")
1003    }else if(/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(me.value)){
1004        console.log('Email')
1005    }else{
1006        console.log('Nothing')
1007    }
1008
1009}
1010
1011function alphabets(me){
1012
1013    if(me.value == '' || /^[a-zA-Z ]+$/.test(me.value)){
1014        $('#'+me.id).css('border','1px solid #ccc');
1015        me.classList.remove('error')
1016    }else{
1017        $('#'+me.id).css('border','1px solid #f00');
1018        me.classList.add('error')
1019        showNotification('Only alphabets are allowed ','danger')
1020    }
1021}
1022
1023function alphaNumeric(me){
1024
1025    if(me.value == '' || /^[0-9a-zA-Z.,!?@: ]+$/.test(me.value)){
1026        $('#'+me.id).css('border','1px solid #ccc');
1027        me.classList.remove('error')
1028    }else{
1029        $('#'+me.id).css('border','1px solid #f00');
1030        me.classList.add('error')
1031        showNotification('Alphanumeric characters are allowed ','danger')
1032    }
1033}
1034
1035function numeric(me){
1036
1037    if(me.value == '' || /^[0-9 ]+$/.test(me.value)){
1038        $('#'+me.id).css('border','1px solid #ccc');
1039        me.classList.remove('error')
1040    }else{
1041        $('#'+me.id).css('border','1px solid #f00');
1042        me.classList.add('error')
1043        showNotification('Only numeric characters are allowed','danger')
1044    }
1045}
1046
1047function validateEmail(me){
1048
1049    if(/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(me.value)){
1050        $('#'+me.id).css('border','1px solid #ccc');
1051        me.classList.remove('error')
1052    }else{
1053        $('#'+me.id).css('border','1px solid #f00');
1054        me.classList.add('error')
1055        showNotification('Please enter valid email address','danger')
1056    }
1057}
1058
1059function validatePhoneNumber(me){
1060
1061    if(/^[0-9()+-]+$/.test(me.value)){
1062        $('#'+me.id).css('border','1px solid #ccc');
1063        me.classList.remove('error')
1064    }else{
1065        $('#'+me.id).css('border','1px solid #f00');
1066        me.classList.add('error')
1067        showNotification('Please enter valid Phone Number','danger')
1068    }
1069}
1070
1071function validateTime(me){
1072
1073    if(/^[0-9: ]+$/.test(me.value)){
1074        $('#'+me.id).css('border','1px solid #ccc');
1075        me.classList.remove('error')
1076    }else{
1077        $('#'+me.id).css('border','1px solid #f00');
1078        me.classList.add('error')
1079        showNotification('Please enter 24 hours time format (17:30)','danger')
1080    }
1081}
1082
1083
1084function validateDate(me){
1085
1086    if(/^(0[1-9]|1[0-2])\/(0[1-9]|1\d|2\d|3[01])\/(19|20)\d{2}$/.test(me.value)){
1087        $('#'+me.id).css('border','1px solid #ccc');
1088        me.classList.remove('error')
1089    }else{
1090        $('#'+me.id).css('border','1px solid #f00');
1091        me.classList.add('error')
1092        showNotification('Please enter date in correct format MM/dd/yyyy','danger')
1093    }
1094}
1095
1096
1097
1098
1099
1100
1101function validateFloat(me){
1102
1103    if(/^[0-9.]+$/.test(me.value)){
1104        $('#'+me.id).css('border','1px solid #ccc');
1105        me.classList.remove('error')
1106    }else{
1107        $('#'+me.id).css('border','1px solid #f00');
1108        me.classList.add('error')
1109        showNotification('Please enter valid floating point number','danger')
1110    }
1111}
1112
1113
1114$(document).ready(function() {
1115
1116    if(window.location.pathname.split('/')[1] == 'admin'
1117        && (window.location.pathname.split('/')[2] == 'settings' && window.location.pathname.split('/')[3] == 'pages'
1118        || window.location.pathname.split('/')[2] == 'boat'  && window.location.pathname.split('/')[3] == 'new'
1119        || window.location.pathname.split('/')[2] == 'boat'  && window.location.pathname.split('/')[3] == 'edit'
1120        || window.location.pathname.split('/')[2] == 'boat' && window.location.pathname.split('/')[3] == 'meta-page'
1121        )
1122
1123    ){
1124
1125        // $('#pageContent').summernote({
1126        //     airMode: true
1127        // });
1128        // $('#pageContent').summernote( {
1129        //     height: 500,
1130        //     minHeight: 300,
1131        //     maximumImageFileSize: 1048576,
1132        //     codeviewFilter: true,
1133
1134        //     codeview:true
1135        // },'code');
1136        // $('#pageContentAiDes1').summernote( {
1137        //     height: 500,
1138        //     minHeight: 300,
1139        //     maximumImageFileSize: 1048576,
1140        //     codeviewFilter: true,
1141
1142        //     codeview:true
1143        // },'code');
1144        // $('#pageContentAiHigh1').summernote( {
1145        //     height: 500,
1146        //     minHeight: 300,
1147        //     maximumImageFileSize: 1048576,
1148        //     codeviewFilter: true,
1149
1150        //     codeview:true
1151        // },'code');
1152        // $('#pageContentAiStd1').summernote( {
1153        //     height: 500,
1154        //     minHeight: 300,
1155        //     maximumImageFileSize: 1048576,
1156        //     codeviewFilter: true,
1157
1158        //     codeview:true
1159        // },'code');
1160        // $('#pageContentAiOpt1').summernote( {
1161        //     height: 500,
1162        //     minHeight: 300,
1163        //     maximumImageFileSize: 1048576,
1164        //     codeviewFilter: true,
1165
1166        //     codeview:true
1167        // },'code');
1168        // $('#pageContentAiDes2').summernote( {
1169        //     height: 500,
1170        //     minHeight: 300,
1171        //     maximumImageFileSize: 1048576,
1172        //     codeviewFilter: true,
1173
1174        //     codeview:true
1175        // },'code');
1176        // $('#pageContentAiHigh2').summernote( {
1177        //     height: 500,
1178        //     minHeight: 300,
1179        //     maximumImageFileSize: 1048576,
1180        //     codeviewFilter: true,
1181
1182        //     codeview:true
1183        // },'code');
1184        // $('#pageContentAiStd2').summernote( {
1185        //     height: 500,
1186        //     minHeight: 300,
1187        //     maximumImageFileSize: 1048576,
1188        //     codeviewFilter: true,
1189
1190        //     codeview:true
1191        // },'code');
1192        // $('#pageContentAiOpt2').summernote( {
1193        //     height: 500,
1194        //     minHeight: 300,
1195        //     maximumImageFileSize: 1048576,
1196        //     codeviewFilter: true,
1197
1198        //     codeview:true
1199        // },'code');
1200    }
1201
1202    if(window.location.pathname.split('/')[1] == 'admin'
1203        && (
1204             window.location.pathname.split('/')[2] == 'employment'  && window.location.pathname.split('/')[3] == 'new'
1205            || window.location.pathname.split('/')[2] == 'employment'  && window.location.pathname.split('/')[3] == 'edit'
1206
1207        )
1208
1209    ){
1210
1211        // $('#pageContent').summernote({
1212        //     airMode: true
1213        // });
1214        $('#pageContent').summernote( {
1215            height: 500,
1216            minHeight: 300,
1217            maximumImageFileSize: 1048576,
1218            codeviewFilter: true,
1219
1220            codeview:true
1221        },'code');
1222
1223        $('#pageContentResponsibility').summernote( {
1224            height: 500,
1225            minHeight: 300,
1226            maximumImageFileSize: 1048576,
1227            codeviewFilter: true,
1228
1229            codeview:true
1230        },'code');
1231
1232        $('#pageContentQualification').summernote( {
1233            height: 500,
1234            minHeight: 300,
1235            maximumImageFileSize: 1048576,
1236            codeviewFilter: true,
1237
1238            codeview:true
1239        },'code');
1240
1241
1242    }
1243
1244
1245
1246
1247
1248});

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.