PageSourceSearch

https://www.bonback.com/include/customer/customer.js?v=202510071324

js bonback.com collected 2026-10-01 10:36:48 UTC 58,253 bytes, 1,329 lines download raw bytes

1/*
2 *
3 * script on public customer
4 *
5 */
6
7function addToCart(productID, productSkuID, productAttributeCrossID, imageUrl, amount) {
8    jQuery.ajax({
9        type: 'POST',
10        url: '/include/customer/ajaxAddToCart.php',
11        data: {
12            'type': 'addToCart',
13            'productID': productID,
14            'productSkuID': productSkuID,
15            'productAttributeCrossID': productAttributeCrossID,
16            'imageUrl': imageUrl,
17            'amount': amount
18        },
19        beforeSend: function (xhr) {  },
20        success: function (data, textStatus, jqXHR) { 
21            document.location.href = '/' + lang + '/cart';
22        }
23    });
24} 
25
26async function addToCartShowDialog(productID, productSkuID, productAttributeCrossID, imageUrl, amount, productCode) {
27    var isNotOverStock_be = await getStockQuantityBalance(productID, productSkuID, productAttributeCrossID, amount);
28    var isNotOverStock = isNotOverStock_be.split('@@');
29    //console.log(isNotOverStock_be);
30    amount = (amount) ? amount : 1;
31    amount = (amount < 1) ? 1 : amount; // check negative amount
32    if(isNotOverStock[0] == 1){
33        productCode = encodeURIComponent(productCode);
34        jQuery.ajax({
35            type: 'POST',
36            url: '/include/customer/ajaxAddToCart.php',
37            data: {
38                'type': 'addToCart',
39                'productID': productID,
40                'productSkuID': productSkuID,
41                'productAttributeCrossID': productAttributeCrossID,
42                'imageUrl': imageUrl,
43                'amount': amount
44            },
45            beforeSend: function (xhr) {  },
46            success: function (data, textStatus, jqXHR) {                 
47                window.parent.showModalBS(1, '/include/customer/dialogProductAddToCartController.php?productID='+productID+'&productSkuID='+productSkuID+'&productCode='+productCode+'&amount='+amount, 'addToCart');
48            }
49        });
50    }else if(isNotOverStock[0] == 2){
51        showModalBS(1, '/page/page_cart/cartDialogErrorController.php?pagetype=noproduct2', 'medium');
52    }else if(isNotOverStock[0] == 3){
53        imageUrl2 = encodeURIComponent(imageUrl);
54        showModalBS(1, '/page/page_cart/cartDialogErrorController.php?pagetype=noproduct3&productID='+productID+'&productSkuID='+productSkuID+'&productCode='+productCode+'&amount='+amount+'&productAttributeCrossID='+productAttributeCrossID+'&promowarn='+isNotOverStock[1]+'&imageUrl='+imageUrl2, 'large');
55    }else if(isNotOverStock[0] == 5){
56        imageUrl2 = encodeURIComponent(imageUrl);
57        showModalBS(1, '/page/page_cart/cartDialogErrorController.php?pagetype=permisflash&productID='+productID+'&productSkuID='+productSkuID+'&productCode='+productCode+'&amount='+amount+'&productAttributeCrossID='+productAttributeCrossID+'&promowarn='+isNotOverStock[1]+'&imageUrl='+imageUrl2, 'large');
58    }else{
59        showModalBS(1, '/page/page_cart/cartDialogErrorController.php?pagetype=noproduct', 'medium');
60    }
61}
62
63function productGroupShowDialog(productID, productSkuID, productCode) {
64    productCode = encodeURIComponent(productCode);
65    window.parent.showModalBS(1, '/include/customer/dialogProductGroupController.php?productID='+productID+'&productSkuID='+productSkuID+'&productCode='+productCode, 'addToCartGroupProduct');
66}
67
68function drawWidgetCartFix() {
69    jQuery.ajax({
70        type: 'POST',
71        url: '/include/ajaxDrawWidgetCartFix.php',
72        success: function (data, textStatus, jqXHR) {
73            jQuery('.widget_cart_fix_display').html(data);
74        }
75    });
76}
77
78function addToCartAll() {
79    var productIDAllArr = new Array();
80    $(".wishlist-list .product_id").each(function (key, val) {
81        var stock_number = $(".wishlist-list .stockNumber:eq(" + key + ")").val();
82        if (stock_number != 0) {
83            productIDAllArr.push($(this).val());
84        }
85    });
86    var productIDAllJSON = JSON.stringify(productIDAllArr); 
87
88    var productAttIDAllArr = new Array();
89    $(".wishlist-list .product_attribute_cross_id").each(function (key, val) {
90        var stock_number = $(".wishlist-list .stockNumber:eq(" + key + ")").val();
91        if (stock_number != 0) {
92            productAttIDAllArr.push($(this).val());
93        }
94    });
95    var productAttIDAllJSON = JSON.stringify(productAttIDAllArr); 
96
97    var productImgAllArr = new Array();
98    $(".wishlist-list .image_url").each(function (key, val) {
99        var stock_number = $(".wishlist-list .stockNumber:eq(" + key + ")").val();
100        if (stock_number != 0) {
101            productImgAllArr.push($(this).val());
102        }
103    });
104    var productImgAllJSON = JSON.stringify(productImgAllArr); 
105
106    jQuery.ajax({
107        type: 'POST',
108        url: '/include/customer/ajaxAddToCartAll.php',
109        data: {
110            'type': 'addAllToCart',
111            'product_id': productIDAllJSON,
112            'product_attribute_cross_id': productAttIDAllJSON,
113            'image_url': productImgAllJSON,
114            'amount': 1
115        },
116        beforeSend: function (xhr) {
117        },
118        success: function (data, textStatus, jqXHR) {
119            document.location.href = '/' + lang + '/cart';
120        }
121    });
122
123} /* end function addToCartAll */
124
125$(window).on('load', function () {
126    if ($(window).width() > 1024) {
127        ScrollPosStyler.init({
128            scrollOffsetY: parseFloat($('.headerDesktop #top-bar').height()) + 1
129        });
130    } else {
131        ScrollPosStyler.init({
132            scrollOffsetY: parseFloat($('.headerMobile #top-bar').height()) + 1
133        });
134        jQuery(".topwidget-menu").find('#chooseLanguage').on('click', function(e){
135            var objclick = jQuery(this).parent();
136            jQuery('#section-header.sps--blw .headerMobile #navbarNavDropdown').animate({
137                scrollTop: objclick.position().top
138            }, 500);
139        });
140    }
141
142    jQuery(".topwidget-menu > .navbar-nav.navbar-topmenu.public-topmenu a").find('.arrowCollapse').on('click', function(e){
143        if ($(window).width() < 1025) {
144            e.preventDefault();
145            e.stopPropagation();
146            jQuery(this).parent().siblings().toggleClass('show');
147            jQuery(this).parent().parent().toggleClass('show');
148            var objclick = jQuery(this).parent();
149            var objarrow = jQuery(this).parent().siblings('ul');
150            if(jQuery(this).parent().hasClass('abl1') && jQuery(this).parent().siblings().hasClass('show') && objclick.parent().position().top!==0){
151                jQuery('#section-header.sps--blw .headerMobile #navbarNavDropdown').animate({
152                    scrollTop: objclick.parent().position().top
153                }, 800); 
154            }  
155            if(jQuery(this).parent().hasClass('abl2') && jQuery(this).parent().siblings().hasClass('show') && objclick.parent().position().top!==0){
156                jQuery('#section-header.sps--blw .headerMobile #navbarNavDropdown').animate({
157                    scrollTop: objclick.parent().position().top
158                }, 800); 
159            }
160        }
161    });
162
163    if ($(window).width() > 1024) {
164        calcWidthAfter();
165        jQuery(".topwidget-menu > .navbar-nav.navbar-topmenu > li.nav-item").hover(function(){
166            var vjim = jQuery(this);
167            if (jQuery('ul', this).length) {
168                var elm = jQuery('ul:first', this);
169                var off = elm.offset();
170                var l = off.left;
171                var w = elm.width();
172                var docW = jQuery("#top-area > #top-sticky").width();
173                var maxWidthLv2 = 0;
174                if(vjim.find('ul.dropdown-menu > li > ul.dropdown-menu').length > 0){
175                    var maxWidthLv2 = Math.max.apply( null, vjim.find('ul.dropdown-menu > li > ul.dropdown-menu').map( function () {
176                        return jQuery( this ).outerWidth( true );
177                    }).get());
178                }
179                var maxWidthLv3 = 0;
180                if(vjim.find('ul.dropdown-menu > li > ul.dropdown-menu > li > ul.dropdown-menu').length > 0){
181                    maxWidthLv3 = Math.max.apply( null, vjim.find('ul.dropdown-menu > li > ul.dropdown-menu > li > ul.dropdown-menu').map( function () {
182                        return jQuery( this ).outerWidth( true );
183                    }).get());
184                    if(maxWidthLv3==0){
185                        //maxWidthLv3 = 400; //simple
186                    }
187                }
188
189                var isEntirelyVisible = ((l + w + maxWidthLv2 + maxWidthLv3) <= docW);
190                if (!isEntirelyVisible){
191                    vjim.children('ul.dropdown-menu').addClass('dropdown-menu-right');
192                    vjim.children('ul.dropdown-menu.dropdown-menu-right').find('ul.dropdown-menu').addClass('dropdownfix-menu-right');
193                }
194            }
195        }, function(){
196            jQuery(this).children('ul.dropdown-menu').removeClass('dropdown-menu-right');
197            jQuery(this).children('ul.dropdown-menu').find('ul.dropdown-menu').removeClass('dropdownfix-menu-right');
198        });
199    }
200});
201$(window).on('resize', function () {
202    if ($(window).width() > 1024) {
203        calcWidthAfter();
204        ScrollPosStyler.init({
205            scrollOffsetY: parseFloat($('.headerDesktop #top-bar').height()) + 1
206        });
207    } else {
208        ScrollPosStyler.init({
209            scrollOffsetY: parseFloat($('.headerMobile #top-bar').height()) + 1
210        });
211    }
212});
213
214$(document).ready(function () {
215    jQuery(".modal").removeClass("fade");
216    $('.dropdown-menu a.dropdown-toggle').on('click', function (e) {
217        var $el = $(this);
218        var $parent = $(this).offsetParent(".dropdown-menu");
219        if (!$(this).next().hasClass('show')) {
220            $(this).parents('.dropdown-menu').first().find('.show').removeClass("show");
221        }
222        var $subMenu = $(this).next(".dropdown-menu");
223        $subMenu.toggleClass('show');
224        $(this).parent("li").toggleClass('show');
225        $(this).parents('li.nav-item.dropdown.show').on('hidden.bs.dropdown', function (e) {
226            $('.dropdown-menu .show').removeClass("show");
227        });
228        if (!$parent.parent().hasClass('navbar-nav')) {
229            $el.next().css({"top": $el[0].offsetTop, "left": $parent.outerWidth() - 2});
230        }
231        return false;
232    });
233
234});
235
236/* logout */
237$(document).ready(function () {
238    jQuery('#txtMemberLogout, #txtMemberLogouttopmenu, #txtMemberLogoutonmenu').on('click', function () {
239        jQuery.ajax({
240            type: 'POST',
241            url: '/customer/member/ajaxAuthen.php',
242            data: {
243                'type': 'logout'
244            },
245            beforeSend: function (xhr) {
246                jQuery('#divViewportLoading').addClass('active');
247            },
248            success: function (data, textStatus, jqXHR) {
249                jQuery('#divViewportLoading').removeClass('active');
250                var arrayData = jQuery.parseJSON(data);
251                if (arrayData.code == '00') {
252                    document.location.href = '/member';
253                }
254            }
255        });
256    });
257});
258/* search */
259
260jQuery('.selectFilterSearch').on('change', function () {
261    var textStringSearch = jQuery('#textStringSearchinpage').val();
262    if (textStringSearch != '') {
263        document.location.href = `/search&text=${encodeURI(jQuery('#textStringSearchinpage').val())}&type=${jQuery(this).val()}`;
264    }
265});
266
267/* end search */
268
269/* wishlist*/
270jQuery('.btnAddToCartwish').on('click', function () {
271    var product_id = $(this).closest('.wishlist-item').find('.product_id').val();
272    var product_sku_id = $(this).closest('.wishlist-item').find('.product_sku_id').val();
273    var product_attribute_cross_id = $(this).closest('.wishlist-item').find('.product_attribute_cross_id').val();
274    var image_url = $(this).closest('.wishlist-item').find('.image_url').val();
275    var product_code = $(this).closest('.wishlist-item').find('.product_code').val();
276    // addToCart(product_id, product_sku_id, product_attribute_cross_id, image_url, 1);
277    addToCartShowDialog(product_id, product_sku_id, product_attribute_cross_id, image_url, 1, product_code);
278});
279
280function validateAllProduct() {
281    jQuery.ajax({
282        type: "POST",
283        url: "/page/page_product_item/ajaxPageProductItemController.php",
284        data: {
285            'productID': jQuery("#hiddenProductID").val(),
286            'type': 'checkAllProductHasByID'
287        },
288        success: function (returnData) {
289            if(returnData == 1){
290                jQuery('.addWishlist').addClass('disabled-tag-a').removeClass('disabled-tag-a');
291                jQuery('.compareProduct').addClass('disabled-tag-a').removeClass('disabled-tag-a');
292                jQuery(".btnAddToCartpdetail").prop('disabled',false);
293                getProductData();    
294            }else{
295                jQuery('.addWishlist').removeClass('disabled-tag-a').addClass('disabled-tag-a');
296                jQuery('.compareProduct').removeClass('disabled-tag-a').addClass('disabled-tag-a');
297                jQuery(".btnAddToCartpdetail").prop('disabled',true);
298            }
299        }
300    });
301}
302
303function validateCheckProduct() {
304    var attributeSelectAll = '';
305    $('[name="hiddenAttributeSelected[]"]').each(function() {
306        if($(this).val() != '0'){
307            attributeSelectAll += '[' + $(this).val() + '],' ;
308        }
309    })
310    attributeSelectAll = attributeSelectAll.substring(0, attributeSelectAll.length - 1);
311    jQuery.ajax({
312        type: "POST",
313        url: "/page/page_product_item/ajaxPageProductItemController.php",
314        data: {
315            'productID': jQuery("#hiddenProductID").val(),
316            'attributeCross': attributeSelectAll,
317            'type': 'checkHasProduct'
318        },
319        success: function (returnData) {
320            if(returnData == 1){
321                jQuery('.addWishlist').addClass('disabled-tag-a').removeClass('disabled-tag-a');
322                jQuery('.compareProduct').addClass('disabled-tag-a').removeClass('disabled-tag-a');
323                getProductData();    
324            }else{
325                jQuery("#errorNumAttribute").show();
326                var errorNumText = getTextErrorInProductDetail();
327                jQuery("#errorNumText").html(errorNumText);
328                jQuery(".productStock").html('');
329                jQuery('.addWishlist').removeClass('disabled-tag-a').addClass('disabled-tag-a');
330                jQuery('.compareProduct').removeClass('disabled-tag-a').addClass('disabled-tag-a');
331                jQuery(".btnAddToCartpdetail").prop('disabled',true);
332            }
333        }
334    });
335}
336
337function disableOptionOutStock() {
338    $.ajax({
339        type: "POST",
340        url: "/page/page_product_item/ajaxPageProductItemController.php",
341        data: {
342            type: "disableOption",
343            productID: jQuery('#hiddenProductID').val(),
344            attributeCross: jQuery('[name="hiddenAttributeSelected[]"]').serialize()
345        },
346        success: (response) => {
347            var res = $.parseJSON(response);
348            jQuery('.hiddenAttributeID option').prop('disabled', false);
349            jQuery('input.hiddenAttributeID').parent().removeClass('disabled');
350            $.each(res, (index, value) => {
351                if(value.has_stock == 0) {
352                    jQuery(`.hiddenAttributeID option[value="${value.product_attribute_member_id}"]`).prop('disabled', true);
353                    jQuery(`.hiddenAttributeID[value="${value.product_attribute_member_id}"]`).parent().addClass('disabled');
354                }
355            });
356        }
357    });
358}
359
360/* product details*/
361jQuery(document).ready(function () {
362    if (jQuery('#hiddenProductTypeID').val() == '2') {
363        disableOptionOutStock();
364    }
365    validateAllProduct();
366    getProductData();
367    jQuery(".dropdownDetail").on('change', function () {
368        jQuery(this).parent().find(".dropdownDetail").removeClass('borderError');
369        jQuery(this).parent().find(".hiddenAttributeSelected").val(jQuery(this).val());
370        jQuery("#errorNumAttribute").hide();
371        if(jQuery(this).parent().find(".hiddenAttributeSelected").val() == 0 ){ 
372            jQuery(".productItemDetail .hiddenCheckAddToCart").val(0); 
373            jQuery(".productItemDetail #hiddenProductSkuID").val(0);
374        }
375        disableOptionOutStock();
376        validateCheckProduct();
377    });
378    jQuery(".buttonItems").on('click', function () {
379        if(jQuery(this).hasClass('disabled')) return;
380        if(jQuery(this).parent().parent().find(".hiddenAttributeSelected").val() == jQuery(this).find(".hiddenAttributeID").val()){
381            jQuery(this).removeClass("selected");
382            jQuery(this).parent().parent().find(".hiddenAttributeSelected").val(0);
383        }else {
384
385            jQuery(this).parent().find(".buttonItems").removeClass("selected");
386            jQuery(this).addClass("selected"); 
387            jQuery(this).parent().parent().find(".hiddenAttributeSelected").val(jQuery(this).find(".hiddenAttributeID").val());
388            jQuery(this).parent().find(".buttonItems").removeClass('borderError');
389            jQuery("#errorNumAttribute").hide();
390        }
391        
392        if(jQuery(this).parent().parent().find(".hiddenAttributeSelected").val() == 0 ){ 
393            jQuery(".productItemDetail .hiddenCheckAddToCart").val(0); 
394            jQuery(".productItemDetail #hiddenProductSkuID").val(0);
395        }
396        disableOptionOutStock();
397        validateCheckProduct()
398    });
399    jQuery(".colorDetail div").on('click', function () {
400        if(jQuery(this).hasClass('disabled')) return;
401        if(jQuery(this).parent().parent().find(".hiddenAttributeSelected").val() ==jQuery(this).find(".hiddenAttributeID").val()){
402            jQuery(this).parent().find("div").removeClass("selected");
403            jQuery(this).parent().parent().find(".hiddenAttributeSelected").val(0);
404        }else {
405            jQuery(this).parent().find("div").removeClass("selected");
406            jQuery(this).addClass("selected");
407            jQuery(this).parent().find(".colorItems").removeClass('borderError');
408            jQuery("#errorNumAttribute").hide();
409            jQuery(this).parent().parent().find(".hiddenAttributeSelected").val(jQuery(this).find(".hiddenAttributeID").val());
410
411            if(jQuery(this).parent().parent().find(".hiddenAttributeSelected").val() == 0 ){ 
412                jQuery(".productItemDetail .hiddenCheckAddToCart").val(0);
413                jQuery(".productItemDetail #hiddenProductSkuID").val(0);
414            }
415        }
416        disableOptionOutStock();
417        validateCheckProduct();
418    });
419    jQuery(".product-thumbList a").click(function () {
420        var largeImage = jQuery(this).find("div").attr('data-large');
421        jQuery(".mainImg").attr('src', largeImage);
422    });
423    if(plugins['magnificpopup'].isEnable) {
424        jQuery('.gall-item-container').magnificPopup({
425            delegate: 'a',
426            type: 'image',
427            gallery: {
428                enabled: true
429            }
430        });
431    }
432    jQuery('.addWishlist').on('click', function () {
433        var valid = validateAttribute();
434        if(valid <= 0){
435            if (parseInt(laogekgimember) > 0) {
436                var product_id = jQuery("#hiddenProductID").val();
437                var product_sku_id = jQuery("#hiddenProductSkuID").val();
438                var product_attribute_cross_id = jQuery(".productItemDetail .hiddenAttributeGroupID").val();
439                if(arrayData.isHaveWishlist == 1){
440                    jQuery.ajax({
441                        type: "POST",
442                        url: "/page/page_product_item/ajaxPageProductItemController.php",
443                        data: {
444                            type: 'delProductWishList',
445                            product_id: product_id,
446                            product_sku_id: product_sku_id,
447                            product_attribute_cross_id: product_attribute_cross_id
448                        },
449                        success: function (result) {
450                            eval(result);
451                            document.location.reload();
452                            // document.location.href = laogekgilanguse == 'th' ? `/member/wishlist` : `/${laogekgilanguse}/member/wishlist`;
453                        }
454                    });
455                } else {
456                    jQuery.ajax({
457                        type: "POST",
458                        url: "/page/page_product_item/ajaxPageProductItemController.php",
459                        data: {
460                            type: 'addProductWishList',
461                            product_id: product_id,
462                            product_sku_id: product_sku_id,
463                            product_attribute_cross_id: product_attribute_cross_id
464                        },
465                        success: function (result) {
466                            eval(result);
467                            document.location.reload();
468                            // document.location.href = laogekgilanguse == 'th' ? `/member/wishlist` : `/${laogekgilanguse}/member/wishlist`;
469                        }
470                    });
471                }
472            } else {
473                var product_id = jQuery("#hiddenProductID").val();
474                var product_sku_id = jQuery("#hiddenProductSkuID").val();
475                var product_attribute_cross_id = jQuery(".productItemDetail .hiddenAttributeGroupID").val();
476                showModalBS(1, '/page/page_product_item/wishlistDialogMemberController.php?type=login&product_id=' + product_id + '&product_sku_id=' + product_sku_id + '&product_attribute_cross_id=' + product_attribute_cross_id + '', 'cartlogin');
477            }
478        }   
479    });
480});
481
482jQuery(".btnAddToCartpdetail").on('click', function () {
483    validateAttribute();
484    var canAddTocart = jQuery(".productItemDetail .hiddenCheckAddToCart").val();
485   
486    if(canAddTocart == '1'){
487        addToCartShowDialog(jQuery("#hiddenProductID").val(), jQuery("#hiddenProductSkuID").val(), jQuery(".productItemDetail .hiddenAttributeGroupID").val(), jQuery('#hiddenCartImageDefault').val(), jQuery('#productNumber').val(), jQuery('#hiddenProductCode').val());
488    } else {
489        if($(window).width() < 768) {
490            $([document.documentElement, document.body]).animate({
491                scrollTop: $(".productName").offset().top - 100
492            }, 500);
493        }
494    }
495});
496
497function getStockQuantityBalance(productID,productSkuID,attributeCrossID,quantity){
498    return  $.ajax({
499        type: "POST",
500        url: "/page/page_product_item/ajaxPageProductItemController.php",
501        data: {
502            'type': "checkStockQuantity",
503            'productID': productID,
504            'productSkuID': productSkuID,
505            'attributeCrossID': attributeCrossID,
506            'quantity': quantity
507        }
508    });
509}
510
511jQuery(window).on('load', function () {
512    showImageProductDetail();
513});
514
515function checkValidateProductAttribute(){
516    var numAttribute = jQuery(".hiddenAttributeSelected").length;
517    var numAttributeSelect = 0;
518    if(jQuery('#hiddenProductTypeID').val() === '2'){
519        jQuery(".hiddenAttributeSelected").each(function() {
520            if(jQuery(this).val() === '0'){
521                jQuery(".productItemDetail .productSku").hide();
522                jQuery(".productItemDetail .productStock").hide();
523                jQuery(".btnAddToCartpdetail").prop('disabled',true);
524                jQuery('.productAttr').hide();
525                jQuery(".stringAttr").html("");
526                numAttributeSelect++;
527            }
528        });
529        if(numAttribute == numAttributeSelect || numAttributeSelect == 0){
530            if (numAttributeSelect == 0) {
531                jQuery(".btnAddToCartpdetail").prop('disabled',false);
532            }
533            return 1;
534        }else {
535            return 0;
536        }
537    } else {
538        return 1;
539    }
540}
541
542function getProductData() { 
543    var tmpArr = new Array();
544    var isProduct = 0;
545    jQuery("input[name='hiddenAttributeSelected[]']").each(function () {
546        tmpArr.push(jQuery(this).val());
547        isProduct++;
548    });
549    
550    if(tmpArr != '' && isProduct >0) {
551        var isChangeData = checkValidateProductAttribute();
552        if(isChangeData == 1){
553            var attribute = JSON.stringify(tmpArr);
554            getProductAttribute(attribute);
555        }
556    }
557}
558function getProductAttribute(attribute) {
559    jQuery(".productItemDetail .productPrice").html('<div class="iconLoadSlider loader" style="width: 50px;"><svg class="circular" viewBox="25 25 50 50"><circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10"/></svg></div>');
560    jQuery.ajax({
561        type: "POST",
562        url: "/page/page_product_item/ajaxPageProductItemController.php",
563        data: {
564            'productID': jQuery("#hiddenProductID").val(),
565            'productSkuID': jQuery("#hiddenProductSkuID").val(),
566            'attributeSet': attribute,
567            'type': 'getAttributeGroupID',
568            'pagetype': 'productdetail'
569        },
570        success: function (returnData) {
571            //console.log(returnData);
572            //jQuery('#testBugs').html(returnData);
573            arrayData = JSON.parse(returnData);
574            if(arrayData.isHaveWishlist == 1){
575                $('.addWishlist .fa-heart').removeClass('far').addClass('fa');
576            }else{
577                $('.addWishlist .fa-heart').removeClass('fa').addClass('far');
578            }
579            jQuery(".productItemDetail #hiddenProductSkuID").val(arrayData.skuID);
580            jQuery(".productItemDetail .productPrice").html(arrayData.price);
581            jQuery(".productItemDetail .hiddenAttributeGroupID").val(arrayData.cross);
582            jQuery(".productItemDetail #hiddenProductWeight").val(arrayData.weight);
583            jQuery(".productItemDetail .hiddenCheckAddToCart").val(arrayData.cart);
584            jQuery(".productItemDetail #hiddenProductCode").val(arrayData.productC
584ode);
585            if(arrayData.flashsale!=''){
586                jQuery(".productItemDetail .flashbar").html(arrayData.flashsale);
587                jQuery(".productItemDetail #hiddenProductPromotion").val(arrayData.flashsaletimeremain);
588                var jimtime = jQuery(".productItemDetail #hiddenProductPromotion").val();
589                flstartCounter(jimtime,'pdetail','s');
590            }else{
591                jQuery(".productItemDetail .flashbar").html('');
592                jQuery(".productItemDetail #hiddenProductPromotion").val('');
593                flstartCounter('','pdetail','st');
594            }
595            if (arrayData.skuID === 0) {
596                if(arrayData.cross === 0 && arrayData.stock !== '') {
597                    /////////// Not have Cross Attribute ////////////
598                    jQuery(".productItemDetail .btnAddToCartpdetail").attr('disabled', 'disabled');
599                    jQuery(".productItemDetail .productStock").show();
600                    jQuery(".productItemDetail .productStock").html(arrayData.stock);
601                } else {
602                    ///////// First Load /////////
603                    jQuery(".productItemDetail .productSku").hide();
604                    jQuery(".productItemDetail .productStock").hide();
605                }
606            } else if(arrayData.cart == 0 && arrayData.skuID !== 0) {
607                ///////// Out Of Stock //////////
608                jQuery(".productItemDetail .btnAddToCartpdetail").addClass('disabled');
609                jQuery(".productItemDetail .productStock").show();
610                jQuery(".productItemDetail .productStock").html(arrayData.stock);
611                jQuery(".productItemDetail .productSku").show();
612                jQuery(".productItemDetail .productSku").html(arrayData.sku);
613            } else {
614                ///////// Has Stock //////////
615                jQuery(".productItemDetail .btnAddToCartpdetail").removeAttr('disabled');
616                jQuery(".productItemDetail .btnAddToCartpdetail").removeClass('disabled');
617                jQuery(".productItemDetail .productSku").show();
618                jQuery(".productItemDetail .productSku").html(arrayData.sku);
619                jQuery(".productItemDetail .productStock").show();
620                jQuery(".productItemDetail .productStock").html(arrayData.stock);
621            } 
622            if(arrayData.stringAttribute != 0) {
623                jQuery('.productAttr').show();
624                jQuery(".stringAttr").html(arrayData.stringAttribute);
625            } else {
626                jQuery('.productAttr').hide();
627                jQuery(".stringAttr").html("");
628            }
629            if(arrayData.configProductSell != 0) {
630                jQuery(".productItemDetail #config-product-sold").show();
631                jQuery(".productItemDetail #config-product-sold").html(arrayData.productsell);
632            } else {
633                jQuery(".productItemDetail #config-product-sold").hide();
634                jQuery(".productItemDetail #config-product-sold").html('');
635            }
636            changeProductImage();
637            changeUrlSku(arrayData.newUrl);
638            
639        }
640    });
641}
642
643function flstartCounter(timer,locat,turn) {
644    if(timer!=''){
645        tdata = JSON.parse(timer);
646        arrayData3 = ''+tdata.exp+'';
647        //2022-11-27 00:00:00
648        var timeParsed = arrayData3.replace(' ', 'T');
649        var countDownDate = new Date(timeParsed).getTime();
650        // Update the count down every 1 second
651        var x = setInterval(function() {
652            var now = new Date().getTime();
653            var distance = countDownDate - now;
654            var days = Math.floor(distance / (1000 * 60 * 60 * 24));
655            var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
656            var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
657            var seconds = Math.floor((distance % (1000 * 60)) / 1000);
658
659            // Display the result in the element with id="demo"
660            if(locat=='pdetail'){
661                jQuery(".productItemDetail .fsui-day").html(('0' +days).slice(-2));
662                jQuery(".productItemDetail .fsui-hour").html(('0' +hours).slice(-2));
663                jQuery(".productItemDetail .fsui-min").html(('0' +minutes).slice(-2));
664                jQuery(".productItemDetail .fsui-sec").html(('0' +seconds).slice(-2));
665            }else if(locat=='plistall'){
666                //section
667                //page
668                jQuery(".col-flash-clock .fsui-day").html(('0' +days).slice(-2));
669                jQuery(".col-flash-clock .fsui-hour").html(('0' +hours).slice(-2));
670                jQuery(".col-flash-clock .fsui-min").html(('0' +minutes).slice(-2));
671                jQuery(".col-flash-clock .fsui-sec").html(('0' +seconds).slice(-2));
672            }
673            // If the count down is finished, write some text
674            if (distance < 0) {
675                if(locat=='pdetail'){
676                    //diable add
677                }
678                clearInterval(x);
679            }
680        }, 1000);
681    }else{
682        clearInterval(x);
683    }
684}
685
686
687function changeUrlSku(url) {
688    if (typeof (history.replaceState) != "undefined") {
689        var obj = { Title: '', Url: url };  
690        history.replaceState(obj, obj.Title, obj.Url); 
691    } else {
692        alert("Browser does not support HTML5.");
693    }
694}
695
696function changeProductImage(){
697    jQuery.ajax({
698        type: "POST",
699        url: "/page/page_product_item/ajaxPageProductItemController.php",
700        data: {
701            'productID': jQuery("#hiddenProductID").val(),
702            'productSkuID': jQuery("#hiddenProductSkuID").val(),
703            'type': 'changeImage'
704        },
705        success: function (returnData) {
706            //jQuery('#testBugs').html(returnData);
707            jQuery('#flslideProductUl').html('');
708            var arrayData = JSON.parse(returnData);
709            jQuery(".gall-item-container").remove();
710            var j=0;
711            jQuery.each(arrayData, function(i, item) {
712                //jQuery('#testBugs').html(j);
713                if(j == 0){
714                    jQuery("#zoomProduct").html('<a id="" class="gall-item" title="'+item.product_name+'" href="'+item.image_url_full+'"><img class="zoomImage img-responsive" data-mag="info0" data-src="'+item.image_url_full+'" src="'+item.image_url_full+'" alt="'+item.product_name+'" title="'+item.image_title+'"/></a>');
715                    jQuery('#hiddenCartImageDefault').val(item.image_url);
716                    jQuery('#hiddenCartImageDefaultFull').val(item.image_url_full);
717                    jQuery("#zoomProduct").after('<div id="fullImgZoom'+j+'" class="gall-item-container"><a href="'+item.image_url_full+'"></a></div>');
718                }else{
719                    jQuery("#fullImgZoom"+(j-1)).after('<div id="fullImgZoom'+j+'" class="gall-item-container"><a href="'+item.image_url_full+'"></a></div>');
720                }
721                
722                jQuery("#flslideProductUl").append('<li href="'+item.image_url_full+'" style="width: 63px; float: left; display: block;"><a class="zoomThumbLink2"><div id="info'+i+'" class="infoThumbProduct1" data-large="'+item.image_url_full+'"><img src="'+item.image_url_thmb+'" alt="'+item.image_alt+'" title="'+item.image_title+'" draggable="false" style="opcity:1; max-height: 50px;"/></div></a></li>');
723                jQuery("img.zoomImage").css('opacity','1');
724                jQuery("#info"+i).find("img").css('opacity','1');
725                j++;
726            }); 
727           jQuery('#info0').click();
728           if(plugins['magnificpopup'].isEnable) {
729                jQuery('.gall-item-container').magnificPopup({
730                    delegate: 'a',
731                    type: 'image',
732                    gallery: {
733                        enabled: true
734                    }
735                });
736            }
737           showImageProductDetail();
738        }
739    });
740}
741
742function showImageProductDetail(){
743    jQuery(".iconLoadSlider").fadeOut();
744    jQuery("#flslideProductUl").fadeIn();
745    jQuery('#zoomProduct').zoom({
746        touch: false
747    });
748    jQuery("#zoomProduct").on('click', function () {
749        var index = $(this).find(".zoomImage").attr("data-mag").substring(4);
750        if(plugins['magnificpopup'].isEnable) {
751            jQuery('.gall-item-container').magnificPopup('open', index);
752        }
753    });
754    jQuery(".infoThumbProduct1").on('click', function () {
755        var largeImage = jQuery(this).attr('data-large');
756        jQuery(".zoomImage").attr('src', largeImage);
757        jQuery(".zoomImage").attr('data-mag', $(this).attr("id"));
758        jQuery(".zoomImg").attr('src', largeImage);
759    });
760    jQuery('#flslideProduct').flexslider({
761        animation: "slide",
762        controlNav: false,
763        animationLoop: false,
764        slideshow: false,
765        itemWidth: 63,
766        itemMargin: 15,
767        customDirectionNav: $(".customProduct-navigation a")
768    });
769}
770
771function validateAttribute(){ 
772    var errorNum = 0;
773    if(jQuery('#hiddenProductTypeID').val() === '2'){
774        jQuery(".hiddenAttributeSelected").each(function() {
775            if(jQuery(this).val() === '0'){
776                jQuery(this).parent().find(".dropdownDetail").addClass('borderError');
777                jQuery(this).parent().find(".colorItems").addClass('borderError');
778                jQuery(this).parent().find(".buttonDetail span").addClass('borderError');
779                errorNum++;
780            } else {
781                jQuery(this).parent().find(".dropdownDetail").removeClass('borderError');
782                jQuery(this).parent().find(".colorItems").removeClass('borderError');
783                jQuery(this).parent().find(".buttonDetail span").removeClass('borderError');
784            }
785        });
786
787        if(errorNum > 0 ){
788            jQuery.ajax({
789                type: "POST",
790                url: "/page/page_product_item/ajaxPageProductItemController.php",
791                data: {
792                    'type': 'returnTextChooseOption'
793                },
794                success: function (returnData) {
795                    // Focus on Mobile
796                    if($(window).width() < 768) {
797                        $([document.documentElement, document.body]).animate({
798                            scrollTop: $(".productName").offset().top - 100
799                        }, 500);
800                    }
801                    jQuery("#errorNumAttribute").show();
802                    jQuery("#errorNumText").html(returnData);
803                    jQuery(".productItemDetail .hiddenCheckAddToCart").val(0);
804                }
805            });
806        } else {
807            jQuery("#errorNumAttribute").hide();
808            if($(window).width() < 768) {
809                $([document.documentElement, document.body]).animate({
810                    scrollTop: $(".productName").offset().top - 100
811                }, 500);
812            }
813        }
814    }
815    return errorNum;
816}
817
818function compareProductClickCheckbox(jQueryObj, productID, productSkuID, pathImage, warntxt) {
819    jQuery.ajax({
820        type: 'POST',
821        url: '/include/cookieCompareProduct.php',
822        data: {
823            type: 'compareProductAdd',
824            productID: productID,
825            productSkuID: productSkuID,
826            pathImage: pathImage
827        },
828        success: function (data, textStatus, jqXHR) {
829            if (data == 'isfull') {
830                bootbox.alert(warntxt, function () {
831                    jQueryObj.prop('checked', false);
832                });
833            } else {
834                document.location.href = '/compare';
835            }
836        }
837    }); 
838}
839
840function compareProductClickDetail() {
841    var productID = jQuery('#hiddenProductID').val();
842    var productSkuID = jQuery('#hiddenProductSkuID').val();
843    var productImage = jQuery('#hiddenCartImageDefaultFull').val();
844    jQuery.ajax({
845        type: 'POST',
846        url: '/include/cookieCompareProduct.php',
847        data: {
848            type: 'compareProductAdd',
849            subType: 'detail',
850            productID: productID,
851            productSkuID: productSkuID,
852            pathImage: productImage
853        },
854        success: function (data) {
855            if (data == 'isfull') {
856                bootbox.alert(warntxt, function () {
857                    jQueryObj.prop('checked', false);
858                });
859            } else {
860                document.location.href = '/compare';
861            }
862        }
863    }); 
864}
865/* END product details*/
866
867/* content details*/
868jQuery(document).ready(function () {
869    jQuery('.divTextContentDetail img').each(function () {
870        if (jQuery(this).closest("a").length !== 1) {
871            jQuery(this).wrap('<a class="magnificPopImg" href="' + jQuery(this).attr('src') + '"></a>');
872        }
873    });
874    if(plugins['magnificpopup'].isEnable) {
875        jQuery('.gallcndetail-item').magnificPopup({
876            type: 'image',
877            gallery: {
878                enabled: true
879            }
880        });
881    }
882    if(plugins['magnificpopup'].isEnable) {
883        jQuery('.divTextContentDetail').magnificPopup({
884            delegate: 'a.magnificPopImg',
885            type: 'image',
886            gallery: {
887                enabled: true
888            },
889            zoom: {
890                enabled: true,
891                duration: 300,
892                opener: function (element) {
893                    return element.find('img');
894                }
895            }
896        });
897    }
898});
899jQuery(window).on('load', function () {
900    jQuery("#flslideProductUl2").fadeIn();
901    jQuery(".zoomThumbLinkcon").on('click', function () {
902        var zoomThumb = jQuery(".zoomThumbLinkcon");
903        jQuery.each(zoomThumb.find("div"), function () {
904            largeImage = jQuery(this).attr('data-large');
905            jQuery(this).parent().parent().attr('href', largeImage);
906        });
907    });
908    jQuery('#flslideContent').flexslider({
909        animation: "slide",
910        controlNav: false,
911        animationLoop: false,
912        slideshow: false,
913        itemWidth: 120,
914        itemMargin: 15,
915        customDirectionNav: $(".customcontent-navigation a")
916    });
917});
918/* END content details*/
919
920/* eventcalendar details*/
921function nexevent(url) {
922    document.location.href = url;
923}
924function addClassP() {
925    jQuery(".fc-more-popover .fc-content").addClass('p');
926}
927/* END eventcalendar details*/
928
929/* forum */
930jQuery("#buttonAddTopic").on("click", function () {
931    document.location.href = urlNewTopic;
932});
933/* END forum */
934
935/*FAQ*/
936jQuery('.faqList1 .collapse').on('show.bs.collapse', function () {
937    jQuery(this).parent().find('.faqHeading').find('[data-fa-i2svg]').removeClass('fa-plus').addClass('fa-minus');
938});
939jQuery('.faqList1 .collapse').on('hide.bs.collapse', function () {
940    jQuery(this).parent().find('.faqHeading').find('[data-fa-i2svg]').removeClass('fa-minus').addClass('fa-plus');
941});
942/*FAQ*/
943
944/* Trackcode */
945jQuery("#searchTrack").on('keypress', function (event) {
946    if (event.which === 13) {
947        event.preventDefault();
948        jQuery("#buttonTrackSearch").click();
949    }
950}).on("blur", function () {
951    if (jQuery.trim(jQuery(this).val()) !== "") {
952        jQuery("#searchTrack").removeClass('borderError');
953    }
954});
955jQuery("#buttonTrackSearch").on("click", function () {
956    var searchTrack = jQuery.trim(jQuery("#searchTrack").val());
957    jQuery("#searchTrack").removeClass('borderError');
958    jQuery("#divError_searchTrack").hide();
959
960    document.location.href = nextUrlTrack + '/' + searchTrack + '/';
961});
962/*end Trackcode*/
963
964/*informpayment*/
965jQuery(document).ready(function () {
966    jQuery('#datePickerPayment').datetimepicker({
967        /*format: "YYYY-MM-DD HH:mm",*/
968        format: "DD/MM/YYYY",
969        icons: {
970            date: 'far fa-calendar-alt'
971        }
972    }).on('dp.change dp.show', function (e) {
973        jQuery('#formInformPayment').formValidation('revalidateField', 'ip_paymentDate');
974    });
975    jQuery('#timePickerPayment').datetimepicker({
976        format: "LT",
977        icons: {
978            time: 'far fa-clock'
979        }
980    }).on('dp.change dp.show', function (e) {
981        jQuery('#formInformPayment').formValidation('revalidateField', 'ip_paymentTime');
982    });
983    jQuery("#ipPaymentTime").on("blur", function () {
984        jQuery('#formInformPayment').formValidation('revalidateField', 'ip_paymentTime');
985    });
986    jQuery("#captchaInputinform").on("blur", function () {
987        jQuery('#formInformPayment').formValidation('revalidateField', 'captcha');
988    });
989    jQuery("#refreshCaptchainform").on("click", function () {
990        generateCaptchaifpm();
991    });
992    jQuery("#selectPaymentGateway").on('change', function () {
993        transferPayment();
994    });
995});
996function transferPayment() {
997    if (jQuery("#selectPaymentGateway").val() === "transfer") {
998        jQuery("#divTransferPaymentGateway").show();
999    } else {
1000        jQuery("#divTransferPaymentGateway").hide();
1001    }
1002}
1003function randomNumberifpm(min, max) {
1004    return Math.floor(Math.random() * (max - min + 1) + min);
1005}
1006function generateCaptchaifpm(task = null) {
1007    let elemBoundary = (task && jQuery(`#captcha_${task}`).length) ? jQuery(`#captcha_${task}`) : jQuery(`.mwe-captcha`);
1008    if (!elemBoundary) return;
1009
1010    elemBoundary.find('.captchaOperation').html([randomNumberifpm(10, 99), '+', randomNumberifpm(10, 99), '='].join(' '));
1011    checkCaptcha(task);
1012}
1013function checkCaptcha(task = null) {
1014    let elemBoundary = (task && jQuery(`#captcha_${task}`).length) ? jQuery(`#captcha_
1014${task}`) : jQuery(`.mwe-captcha`);
1015    if (!elemBoundary) return;
1016
1017    var items = elemBoundary.find('.captchaOperation').html().split(' ');
1018    var sum = parseInt(items[0]) + parseInt(items[2]);
1019    elemBoundary.find(".checkCapt").val(sum);
1020
1021    let isMockup = Boolean(elemBoundary.attr('data-mockup'));
1022    if (isMockup) return;
1023
1024    if (task) {
1025        jQuery.ajax({
1026            type: "POST",
1027            url: '/page/ajax_captcha.php',
1028            data: {
1029                type: "setCaptcha",
1030                task: task,
1031                sum: sum,
1032            },
1033            success: function (returnData) {
1034            }
1035        });
1036    }
1037}
1038/*end informpayment*/
1039
1040/*CONTACT US*/
1041function initialize01() { // ฟังก์ชันแสดงแผนที่
1042    GGM = new Object(google.maps); // เก็บตัวแปร google.maps Object ไว้ในตัวแปร GGM
1043    GGM.visualRefresh = true;
1044    geocoder = new GGM.Geocoder(); // เก็บตัวแปร google.maps.Geocoder Object
1045    infowindow = new google.maps.InfoWindow({maxWidth: 300});
1046    // กำหนดจุดเริ่มต้นของแผนที่
1047    var my_Latlng = new GGM.LatLng(default_map_latitude, default_map_longtitude);
1048    var my_mapTypeId = GGM.MapTypeId.ROADMAP; // กำหนดรูปแบบแผนที่ที่แสดง
1049    // กำหนด DOM object ที่จะเอาแผนที่ไปแสดง ที่นี้คือ div id=map_canvas
1050    var my_DivObj = jQuery("#map_canvas01")[0];
1051    // กำหนด Option ของแผนที่
1052    var myOptions = {
1053        zoom: 16, // กำหนดขนาดการ zoom
1054        center: my_Latlng, // กำหนดจุดกึ่งกลาง
1055        mapTypeId: my_mapTypeId, // กำหนดรูปแบบแผนที่
1056        streetViewControl: false, //ปิดการใช้ streetview
1057        scrollwheel: false,
1058        draggable: googlemapdrag,
1059        styles: [googleStyle]
1060    };
1061    map = new GGM.Map(my_DivObj, myOptions); // สร้างแผนที่และเก็บตัวแปรไว้ในชื่อ map
1062
1063    // สร้าง bounds เพื่อคำนวณจุดกึ่งกลาง
1064    var bounds = new GGM.LatLngBounds();
1065    if (arr_map_latitude !== null && arr_map_longitude !== null) {
1066        for (var i = 0; i < arr_map_latitude.length; i++) {
1067            my_Latlng = new GGM.LatLng(arr_map_latitude[i], arr_map_longitude[i]);
1068            my_Marker = new GGM.Marker({// สร้างตัว marker ไว้ในตัวแปร my_Marker
1069                position: my_Latlng, // กำหนดไว้ที่เดียวกับจุดกึ่งกลาง
1070                map: map, // กำหนดว่า marker นี้ใช้กับแผนที่ชื่อ instance ว่า map
1071                animation: GGM.Animation.DROP,
1072                draggable: false // กำหนดให้สามารถลากตัว marker นี้ได้
1073            });
1074
1075            bounds.extend(my_Latlng); //เก็บพิกัดของแต่ละจุด
1076
1077            interestings[i] = my_Marker;
1078            contentInfo[i] = '<table style="width: 100%; border: none;">' +
1079                    '<tr style="vertical-align: top;">' +
1080                    '<td style="width: 65px;">' +
1081                    '<img src="' + arr_map_logo[i] + '" style="max-height: 60px; max-width: 60px;">' +
1082                    '</td>' +
1083                    '<td style="width: 150px; color: #333333;">' +
1084                    '<span style="font-weight: bold;">' + arr_map_name[i] + '</span></br>' +
1085                    arr_map_detail[i] + '</br>' +
1086                    '<a target="_blank" style="color:#2200cc; font-size: 12px; font-family: Roboto,Arial,sans-serif;" href="https://www.google.com/maps/place/' + arr_map_latitude[i] + ',' + arr_map_longitude[i] + '">Direction</a>' +
1087                    '</td>' +
1088                    '</tr>' +
1089                    '</table>';
1090
1091            // กำหนด event ให้กับตัวแผนที่ เมื่อมีการเปลี่ยนแปลง center
1092            GGM.event.addListener(my_Marker, 'click', (function (my_Marker, i) {
1093                return function () {
1094                    interestings[i].setAnimation(google.maps.Animation.BOUNCE);
1095                    setTimeout(function () {
1096                        interestings[i].setAnimation(null);
1097                    }, 1500); //animation bounce 2 times
1098                    infowindow.setContent(contentInfo[i]);
1099                    infowindow.open(map, interestings[i]);
1100                }
1101            })(my_Marker, i));
1102        }
1103
1104        // กำหนดจุดกึ่งกลางของแผนที่
1105        if (arr_map_latitude.length > 1)
1106            map.fitBounds(bounds);
1107        else
1108            map.setCenter(my_Latlng);
1109    } else {
1110        map.setCenter(my_Latlng);
1111        my_Marker = new GGM.Marker({// สร้างตัว marker ไว้ในตัวแปร my_Marker
1112            position: my_Latlng, // กำหนดไว้ที่เดียวกับจุดกึ่งกลาง
1113            map: map, // กำหนดว่า marker นี้ใช้กับแผนที่ชื่อ instance ว่า map
1114            animation: GGM.Animation.DROP,
1115            draggable: false, // กำหนดให้สามารถลากตัว marker นี้ได้
1116            title: "MakeWebEasy" // แสดง title เมื่อเอาเมาส์มาอยู่เหนือ
1117        });
1118    }
1119}
1120
1121function initialize02() { // ฟังก์ชันแสดงแผนที่
1122    GGM = new Object(google.maps); // เก็บตัวแปร google.maps Object ไว้ในตัวแปร GGM
1123    GGM.visualRefresh = true;
1124    geocoder = new GGM.Geocoder(); // เก็บตัวแปร google.maps.Geocoder Object
1125    infowindow = new google.maps.InfoWindow({maxWidth: 300});
1126    // กำหนดจุดเริ่มต้นของแผนที่
1127    var my_Latlng = new GGM.LatLng(default_map_latitude, default_map_longtitude);
1128    var my_mapTypeId = GGM.MapTypeId.ROADMAP; // กำหนดรูปแบบแผนที่ที่แสดง
1129
1130    // กำหนด DOM object ที่จะเอาแผนที่ไปแสดง ที่นี้คือ div id=map_canvas
1131    var my_DivObj = jQuery("#map_canvas02")[0];
1132    // กำหนด Option ของแผนที่
1133    var myOptions = {
1134        zoom: 16, // กำหนดขนาดการ zoom
1135        center: my_Latlng, // กำหนดจุดกึ่งกลาง
1136        mapTypeId: my_mapTypeId, // กำหนดรูปแบบแผนที่
1137        streetViewControl: false, //ปิดการใช้ streetview
1138        scrollwheel: false,
1139        draggable: googlemapdrag,
1140        styles: [googleStyle]
1141    };
1142    map = new GGM.Map(my_DivObj, myOptions); // สร้างแผนที่และเก็บตัวแปรไว้ในชื่อ map
1143
1144    // สร้าง bounds เพื่อคำนวณจุดกึ่งกลาง
1145    var bounds = new GGM.LatLngBounds();
1146    if (arr_map_latitude !== null && arr_map_longitude !== null) {
1147        for (var i = 0; i < arr_map_latitude.length; i++) {
1148            my_Latlng = new GGM.LatLng(arr_map_latitude[i], arr_map_longitude[i]);
1149            my_Marker = new GGM.Marker({// สร้างตัว marker ไว้ในตัวแปร my_Marker
1150                position: my_Latlng, // กำหนดไว้ที่เดียวกับจุดกึ่งกลาง
1151                map: map, // กำหนดว่า marker นี้ใช้กับแผนที่ชื่อ instance ว่า map
1152                animation: GGM.Animation.DROP,
1153                draggable: false // กำหนดให้สามารถลากตัว marker นี้ได้
1154            });
1155
1156            bounds.extend(my_Latlng); //เก็บพิกัดของแต่ละจุด
1157
1158            interestings[i] = my_Marker;
1159            contentInfo[i] = '<table style="width: 100%; border: none;">' +
1160                    '<tr style="vertical-align: top;">' +
1161                    '<td style="width: 65px;">' +
1162                    '<img src="' + arr_map_logo[i] + '" style="max-height: 60px; max-width: 60px;">' +
1163                    '</td>' +
1164                    '<td style="width: 150px; color: #333333;">' +
1165                    '<span style="font-weight: bold;">' + arr_map_name[i] + '</span></br>' +
1166                    arr_map_detail[i] + '</br>' +
1167                    '<a target="_blank" style="color:#2200cc; font-size: 12px; font-family: Roboto,Arial,sans-serif;" href="https://www.google.com/maps/place/' + arr_map_latitude[i] + ',' + arr_map_longitude[i] + '">Direction</a>' +
1168                    '</td>' +
1169                    '</tr>' +
1170                    '</table>';
1171
1172            // กำหนด event ให้กับตัวแผนที่ เมื่อมีการเปลี่ยนแปลง center
1173            GGM.event.addListener(my_Marker, 'click', (function (my_Marker, i) {
1174                return function () {
1175                    interestings[i].setAnimation(google.maps.Animation.BOUNCE);
1176                    setTimeout(function () {
1177                        interestings[i].setAnimation(null);
1178                    }, 1500); //animation bounce 2 times
1179                    infowindow.setContent(contentInfo[i]);
1180                    infowindow.open(map, interestings[i]);
1181                }
1182            })(my_Marker, i));
1183        }
1184
1185        // กำหนดจุดกึ่งกลางของแผนที่
1186        if (arr_map_latitude.length > 1)
1187            map.fitBounds(bounds);
1188        else
1189            map.setCenter(my_Latlng);
1190    } else {
1191        map.setCenter(my_Latlng);
1192        my_Marker = new GGM.Marker({// สร้างตัว marker ไว้ในตัวแปร my_Marker
1193            position: my_Latlng, // กำหนดไว้ที่เดียวกับจุดกึ่งกลาง
1194            map: map, // กำหนดว่า marker นี้ใช้กับแผนที่ชื่อ instance ว่า map
1195            animation: GGM.Animation.DROP,
1196            draggable: false, // กำหนดให้สามารถลากตัว marker นี้ได้
1197            title: "MakeWebEasy" // แสดง title เมื่อเอาเมาส์มาอยู่เหนือ
1198        });
1199    }
1200}
1201jQuery(".focusMap").click(function () {
1202    var id = jQuery(this).parent().parent().find(".hiddenBranchID").val();
1203    var lat = jQuery(this).parent().parent().find(".hiddenLatitude").val();
1204    var lng = jQuery(this).parent().parent().find(".hiddenLongitude").val();
1205    var yourLocation = new GGM.LatLng(lat, lng);
1206    map.setCenter(yourLocation);
1207    map.setZoom(12);
1208    GGM.event.trigger(interestings[id], 'click');
1209});
1210
1211
1212function loadEventCalendarListBox(month, year) {
1213    jQuery.ajax({
1214        type: 'POST',
1215        url: '/page/page_eventcalendar/ajaxEventCalendarHomeboxController.php',
1216        data: {
1217            'typ': 'gethtml',
1218            'month': month,
1219            'year': year
1220        },
1221        success: function (returnData) {
1222            if (returnData) {
1223                jQuery("#eventcalendarListBox").html(returnData);
1224            }
1225        },
1226        error: function (xhr, textStatus, errorThrown) {
1227            console.log(xhr);
1228        }
1229    });
1230}
1231
1232$(document).ready(function () {
1233    $window = $(window);
1234    if ($(window).width() > 1024) {
1235        jQuery('.targethash').css('top', '-' + jQuery('#menutop').outerHeight() + 'px');
1236    }else{
1237        jQuery('.targethash').css('top', '-' + jQuery('.headerMobile .container-mobile').outerHeight() + 'px');
1238    }
1239});
1240
1241jQuery('#btnAcceptPd').on('click', function () {
1242    var coname2 = getPdValue('_acepata');
1243    
1244    if(coname2==0 && coname2!=''){
1245        //set 1
1246        setAceptpd('_acepata', 1, 365);
1247        setPdService(1);
1248    }else if(coname2==1 && coname2!=''){
1249        //do notting
1250    }else if(coname2==''){
1251        setAceptpd('_acepata', 1, 365);
1252        setPdService(1);
1253    }
1254    jQuery('div.policy-position').hide();
1255});
1256
1257jQuery('#btn_setting_cookie').on('click', function () {
1258    showModalBS(0, '/include/pdpa/dialogPdpaController.php', 'large');
1259});
1260
1261jQuery('.cls-poli-dialog').on('click', function () { 
1262    var celpdpa = getPdValue('_showcancelpdpa');
1263    setAceptpd('_showcancelpdpa', 1, 0);
1264    jQuery('div.policy-position').hide();
1265});
1266
1267function couponClipboard(coupon) {
1268    var copyText = jQuery('[name="toUseCoupon_' + coupon+'"]').val();
1269    var $temp = $("<input class='tmp_coupon'>");
1270    $("body").append($temp);
1271    $temp.val(copyText).select();
1272    document.execCommand("copy");
1273    $temp.remove();
1274    jQuery('[name="toUseCoupon_' + coupon+'"]').parent().find('.btnCopyCodeCoupon').hide();
1275    jQuery('[name="toUseCoupon_' + coupon+'"]').parent().find('.btnCopyedCodeCoupon').show();
1276    setTimeout(function() {
1277        jQuery('[name="toUseCoupon_' + coupon+'"]').parent().find('.btnCopyCodeCoupon').show();
1278        jQuery('[name="toUseCoupon_' + coupon+'"]').parent().find('.btnCopyedCodeCoupon').hide();
1279    }, 1500);
1280}
1281
1282function getPdValue(a) {
1283    var b = document.cookie.match('(^|;)\\s*' + a + '\\s*=\\s*([^;]+)');
1284    return b ? b.pop() : '';
1285}
1286
1287function setAceptpd(name, value, days) {
1288    var expires = "";
1289    if (days) {
1290        var date = new Date();
1291        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
1292        expires = "; expires=" + date.toUTCString();
1293    }
1294    document.cookie = name + "=" + (value || "") + expires + "; path=/";
1295}
1296
1297function setPdService(time) {
1298    if(time!=''){
1299        jQuery.ajax({
1300            type: 'post',
1301            url: '/page/page_policy/ajaxPolicyController.php',
1302            data: {
1303                'type': 'acep'
1304            },
1305            beforeSend: function (xhr) {
1306            
1307            },
1308            success: function (data, textStatus, jqXHR) {
1309                if (data !== '1') {
1310                console.log(data);
1311                }
1312            }
1313        });
1314    }
1315// base64 encode the data
1316function bs64encode(data) {
1317    if (typeof data === "object") {
1318      data = JSON.stringify(data);
1319    }
1320  
1321    return bs64escape(data.toString("base64"));
1322}
1323  
1324// modify the base64 string to be URL safe
1325function bs64escape(string) {
1326    return string.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
1327}
1328
1329}

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.