PageSourceSearch

https://netofa.com/wp-content/plugins/valuecard-loyalty/assets/js/widget.js?v=11790274238&ver=6.9.9

js netofa.com collected 2026-09-25 10:07:30 UTC 23,564 bytes, 699 lines download raw bytes

1;jQuery(function($){
2    "use strict";
3    
4    var loadingButton = {
5
6        init: function (btn) {
7          var text = $(btn).text();
8          $(btn).addClass("loading-button").html("<span>" + text + "</span><i class='preloader vcm-ic-spin2'></i>");
9      
10          $(btn).on('click', function () {
11            $(this).addClass('loading');
12            $(this).attr('disabled','disabled');
13          });
14      
15        },
16      
17        showPreloader: function (btn) {
18            $(btn).addClass('loading');
19        },
20      
21        hidePreloader: function (btn) {
22      
23          if (btn) {
24            $(btn).removeClass('loading');
25            $(this).attr('disabled','disabled');
26          }
27          else {
28            $('.loading-button').removeAttr("disabled");
29            $('.loading-button').removeClass('loading');
30          }
31
32        }
33      
34      }
35      
36
37    function formattedNumber(number) {
38        return ("0" + number).slice(-2);
39    }
40
41
42    function objectifyDataForm(form) {
43        var formArray = jQuery(form).serializeArray();
44        var returnArray = {};
45        for (var i = 0; i < formArray.length; i++) {
46            returnArray[formArray[i]['name']] = formArray[i]['value']
47        }
48        return returnArray
49    }
50
51
52    function handelCalender() {
53
54        var fillYear = function (elem) {
55            var myselect = elem[0],
56                startYear = new Date().getFullYear() - 100,
57                count = 100;
58            (function (select, val, count) {
59                do {
60                    val++;
61                    count--;
62                    select.add(new Option(val, val), null);
63                } while (count);
64            })(myselect, startYear, count);
65        }
66
67        $("[fill-data='select-year']").each(function () {
68            if ($(this).find('option').length == 1) fillYear($(this));
69        });
70
71
72        $("[fill-data='select-day']").each(function () {
73            if ($(this).find('option').length == 1) {
74                var thisSelect = $(this)[0];
75                var count = 31, val = 0;
76                do {
77                    val++;
78                    count--;
79                    thisSelect.add(new Option(val, formattedNumber(val)), null);
80                } while (count);
81            }
82        });
83
84        $("[fill-data='select-month']").each(function () {
85            if ($(this).find('option').length == 1) {
86                var thisSelect = $(this)[0];
87                var count = 12, val = 0;
88                do {
89                    val++;
90                    count--;
91                    thisSelect.add(new Option(val, formattedNumber(val)), null);
92                } while (count);
93            }
94        });
95
96        $("[fill-data]").each(function () {
97            if ($(this).attr("data-date")) $(this).val($(this).attr("data-date"));
98        });
99
100        $("[data-date]").each(function () {
101            $(this).on('change', function () {
102                $(this).attr("data-date", $(this).val());
103            });
104        });
105
106    }
107
108
109    var Widget;
110    var Api;
111
112    Api = {
113
114        endpoints: {
115              base: my_ajax_object.ajax_url
116        }, 
117
118        req: function (action, data, method, success, error, retry, async) {
119
120            retry = retry || 0;
121            data = data || {};
122
123            data.action = action;
124            data.source = 'widget';
125
126            var options = {
127                url: this.endpoints.base,
128                data: data,
129                dataType: "json",
130                type: method,
131                success: success,
132                async: async || true,
133                error: function (xhr, body) {
134                    if (retry != 0 && retry < urls.length - 1) {
135                        req(path, data, method, success, error, retry += 1);
136                    } else {
137                        if (error) error(xhr, decodeURIComponent(xhr.statusText).replace(/\+/g, " "), retry);
138                    }
139                },
140                complete: function () {
141                    setTimeout(function () {
142                        loadingButton.hidePreloader();
143                    }, 200);
144                }
145            };
146
147
148            $.ajax(options);
149
150        },
151
152        getUser: function (success, error) {
153            this.req('vcm_get_user', {}, "POST", success, error);
154        },
155
156        getCode: function (input, success, error) {
157            this.req('auth_user', { 'vcm_phone_number' : input }, "POST", success, error);
158        },
159
160        checkNumber: function (input, success, error) {
161            this.req('vcm_check_number', { 'vcm_phone_number' : input }, "POST", success, error);
162        },
163
164        signup: function (data, success, error) {
165            this.req('vcm_ajax_add_member', { 'data' : data }, "POST", success, error);
166        },
167
168        authCode: function (data, success, error) {
169            this.req('vcm_auth_code', { 'data' : data }, "POST", success, error);
170        },
171
172        getBenefitsQuery: function (data, success, error) {
173            this.req('vcm_get_benefits_query', { 'data' : data }, "POST", success, error);
174        },
175
176        updateMember: function (data, success, error) {
177            this.req('vcm_update_member', { 'data' : data }, "POST", success, error);
178        },
179
180        getRecentCardActivity: function (data, success, error) {
181            this.req('vcm_get_user_history', { 'data' : data }, "POST", success, error);
182        },
183
184        getWidgetProperties: function (success, error) {
185            this.req('vcm_get_widget_properties', {}, "POST", success, error);
186        }
187
188
189    },
190
191
192    Widget = {
193
194        slide: {
195
196            hide: function () {
197
198                var slideIn = $("#vcPlugin").width() + 20;
199
200                var addMinus = vcm_options.widgetPosition == 'Left' ? '-' : ''; 
201
202                $("#vcPlugin").addClass('vc-w-hide');
203                $("#vcPlugin:not(.vc-widget-sticky)").css({
204                    "transform": "translatex("+addMinus+slideIn+"px)"
205                });
206                localStorage.setItem("vc-widget-display", 1);
207
208            },
209
210            show: function () {
211
212                $("#vcPlugin").removeClass('vc-w-hide');
213                $("#vcPlugin").attr("style","");
214                localStorage.removeItem("vc-widget-display")
215
216            }
217        },
218
219
220        init: function () {
221
222            $(document).on("click", "#vcPlugin:not(.vc-w-hide), .vc-btn-open-widget", function () {
223                
224                if ((typeof(window.vcm_options.VcmWpConnect) != 'undefined' && window.vcm_options.VcmWpConnect) && (typeof(window.vcm_options.wpLogeedIn) != 'undefined' &&  window.vcm_options.wpLogeedIn== "0")) {
225                    location.href = window.vcm_options.VcmWpConnectUrl;
226                } else {
227                    Widget.open();
228                }
229
230            });
231
232            $(document).on("change", '.chk-add-benefit', function () {
233                let data = jQuery('form[name="benefits_list"]').serialize();
234
235                vcApp.popBox.showPreloader();
236
237                Api.getBenefitsQuery(data, function (response) {
238
239                    $("#vc-promos-list").html(response.html);
240                    $(".vc-promos-footer .vc-promos-total-discount").html(response.discount);
241                    jQuery(document.body).trigger('update_checkout');
242                    vcApp.popBox.hidePreloader();
243                    Widget.onOpenMainWindow();
244
245                });
246
247            });
248
249            window.VcWidget = Widget;
250
251            if (typeof(window.vcm_options.displayVcmWindow) != 'undefined' && window.vcm_options.displayVcmWindow) {
252                VcWidget.open();
253            }
254
255        
256
257
258            $(document).on("click", '#vcPlugin:not(.vc-w-hide) .vc-hide-widget', function (e) {
259                e.preventDefault();
260                e.stopPropagation();
261                Widget.slide.hide();
262            });
263
264            
265            $(document).on("click", '#vcPlugin.vc-w-hide', function (e) {
266                e.preventDefault();
267                e.stopPropagation();
268                Widget.slide.show();
269            });
270
271            
272
273            if (vcm_options.isMobile) {
274
275                $(document).on("focus", 'input, textarea', function () {
276
277                    $("#vcPlugin").addClass('hide-down');
278
279                });
280
281                $(document).on("blur", 'input, textarea', function () {
282
283                    $("#vcPlugin").removeClass('hide-down');
284
285                });
286
287                let touchstartX = 0
288                let touchendX = 0
289                $(document).on("touchstart", '#vcPlugin', function (e) {
290                    touchstartX = e.changedTouches[0].screenX;
291                });
292    
293                $(document).on("touchend", '#vcPlugin', function (e) {
294                    touchendX = e.changedTouches[0].screenX;
295
296                    if (touchendX < touchstartX) vcm_options.widgetPosition == "Right" ? Widget.slide.show() : Widget.slide.hide();
297                    if (touchendX > touchstartX) vcm_options.widgetPosition == "Left" ? Widget.slide.show() : Widget.slide.hide();
298                            
299                });
300
301            }
302
303        },
304
305
306
307        open: function () {
308            
309            vcApp.popBox.open({
310            cssClass: 'vc-vc-widget-window',
311                height: "200px",
312                width: "200px",
313                onOpen: function () {
314    
315                    vcApp.popBox.showPreloader();
316
317                    Api.getUser(function (response) {
318
319                        if ( response ) {
320
321                            if (!response.isMemebr && response.redirect_url) {
322                                location.href = response.redirect_url;
323                            } else {
324                                vcApp.popBox.hidePreloader();
325                                vcApp.popBox.wrap().width(450);
326                            }
327    
328                            var re = response;
329    
330                            var popHeight = 200;
331    
332                            if (re.isMemebr) {
333                                popHeight = 750;
334                            } 
335                            
336                            vcApp.popBox.wrap().height(popHeight);
337                            vcApp.popBox.innerHtml(response.html);
338
339                            if (re.isMemebr) {
340    
341                                Widget.onOpenMainWindow();
342                                if (re.btn_text) vcm_options.vcWidgetLabelText = re.btn_text;
343
344                            } else {
345
346                                loadingButton.init(".vc-btn-signin");
347                                vcApp.popBox.wrap().width(450);
348
349                                $(".vc-btn-signin").on('click', function (e) {
350
351                                    Api.getCode($("input.signin-input").val() , function (code) {
352                                        
353                                        vcApp.popBox.innerHtml(code.html);
354
355                                        if (code.is_error) {
356                                            
357                                            loadingButton.hidePreloader();
358                                            Widget.onSignUpWindow();
359
360                                        }  else {
361
362                                            if (code.authentication) {
363                                                Widget.onAuthenticationWindow(code.phone);
364                                            } else {
365                                                vcApp.popBox.wrap().height(750);
366                                                if (code.btn_text) vcm_options.vcWidgetLabelText = code.btn_text;
367                                                Widget.onOpenMainWindow();
368                                            }
369
370                                        }
371
372                                        Widget.setHeight();
373
374                                    });
375                                });
376
377
378                                $(".vc-btn-check-number").on('click', function (e) {
379
380                                    Api.checkNumber($("input.signin-input").val() , function (code) {
381                                        
382                                        vcApp.popBox.innerHtml(code.html);
383
384                                        if (code.is_error) {
385
386                                            loadingButton.hidePreloader();
387                                            Widget.onSignUpWindow();
388
389                                        }  else {
390
391                                            if (code.authentication) {
392                                                Widget.onAuthenticationWindow(code.phone);
393                                            } else {
394                                                vcApp.popBox.wrap().height(750);
395                                                if (code.btn_text) vcm_options.vcWidgetLabelText = code.btn_text;
396                                                Widget.onOpenMainWindow();
397                                            }
398
399                                        }
400
401                                        Widget.setHeight();
402
403                                    });
404                                });
405
406                                var winHeight = jQuery(".vc-signin-wrapper").outerHeight();
407                                Widget.setHeight(winHeight);
408                                if (Math.round(winHeight) > Math.round($(".popbox-inner").outerHeight())) {
409                                    jQuery(".vc-signin-wrapper").css('max-height', '100%');
410                                }                        
411                            }
412
413                            
414                        }
415                    });
416
417                    },
418                    html: ''
419
420               
421            });
422
423
424        },
425
426
427        setHeight: function (h) {
428
429            var height = h || $(".popbox-inner").outerHeight();
430            //vcApp.popBox.wrap().width('370px');
431            vcApp.popBox.wrap().height(height);
432
433        },
434
435        attach: function () {
436
437            var hideWidget = localStorage.getItem("vc-widget-display");
438
439            if (!vcm_options.isCheckoutPage) {
440                $("body").append('<div id="vcPlugin" style="" class="' + (hideWidget ? 'vc-w-hide ' : '') + ' vc-widget-' + vcm_options.widgetPosition.toLocaleLowerCase() + '" data-slide-s="60839624954"><span class="vc-hide-widget"><i class="vcm-ic-double-left"></i></span><span id="vcWidgetText">' + vcm_options.vcWidgetLabelText + '</span></div>');
441            }
442
443            $("body").addClass("vc-");
444
445            Api.getWidgetProperties(function (res) {
446
447                if (!vcm_options.isCheckoutPage) {
448                    $("#vcWidgetText").text(res.vcWidgetLabelText);
449                }
450              
451                if (hideWidget) {
452                    Widget.slide.hide();
453                }
454
455            });
456
457        },
458
459        onSignUpWindow: function () {
460          
461            vcApp.popBox.wrap().addClass("vc-register-window");
462
463            vcApp.popBox.wrap().height(8000);
464
465            handelCalender();
466            
467            loadingButton.init("#vcm_widget_signup");
468            $("#vcm_widget_signup").on('click', function (e) {
469
470                e.target.classList.add('loading');
471
472                var formData = objectifyDataForm('#register_window');
473                
474                if (!/^[^\s@]+@[^\s@]+\.[^\s@]{2,17}$/.test(formData.vcm_registration_email)) {
475                    vcApp.popBox.addAlert('כתובת מייל לא תקינה');
476                    loadingButton.hidePreloader();
477                    return;
478                }
479                
480                if (formData.BirthDateDay == "0" || formData.BirthDateMonth == "0" || formData.BirthDateYear == "0") {
481                    vcApp.popBox.addAlert('תאריך יום הולדת לא תקי×
481Ÿ');
482                    loadingButton.hidePreloader();                    
483                    return;
484                }
485
486                if ($("#vcm_approve_terms").length) {
487                    
488                    if (!$("#vcm_approve_terms").is(":checked")) {
489                        vcApp.popBox.addAlert('חובה לאשר את התקנון');
490                        loadingButton.hidePreloader();                    
491                        return;
492                    }
493                  
494                }
495
496                var data = jQuery('#register_window').serialize();
497
498                Api.signup(data, function (res) {
499
500                    if (!res.result) {
501                        vcApp.popBox.addAlert(res.message);
502                        loadingButton.hidePreloader();
503                    } else {
504
505                        vcApp.popBox.innerHtml(res.html);
506                        
507                        if (res.sent_sms) {
508                            Widget.onAuthenticationWindow(res.phone);
509                        } else {
510                            Widget.onOpenMainWindow();
511                        }
512
513                    }
514
515                });
516
517            });
518
519            vcApp.popBox.wrap().width('370px');
520
521            setTimeout(function () {
522                
523                var winHeight = jQuery("#register_window").outerHeight();
524                Widget.setHeight(winHeight);
525                if (Math.round(winHeight) > Math.round($(".popbox-inner").outerHeight())) {
526                    jQuery("#register_window").css('max-height', '100%');
527                }
528
529            }, 1);
530
531        },
532
533        onAuthenticationWindow: function (phone) {
534
535            VcWidget.setHeight(140);
536
537            loadingButton.init(".btn-send-login-code");
538
539            $(".btn-send-login-code").on('click', function (e) {
540
541                var data = {
542                    'vc_phone': phone,
543                    'vc_code': $("input.login-code").val()
544                }
545
546                Api.authCode(data, function (aut) {
547
548                    if (!aut.result) {
549                        loadingButton.hidePreloader();
550                        vcApp.popBox.addAlert(aut.message);
551
552                    } else {
553                        if (aut.btn_text) vcm_options.vcWidgetLabelText = aut.btn_text;
554                        vcApp.popBox.innerHtml(aut.html);
555                        Widget.onOpenMainWindow();
556                    }
557
558                });
559
560            });
561
562        },
563
564        onOpenMainWindow: function () {
565
566            vcApp.popBox.wrap().height(750);
567            jQuery(document.body).trigger('update_checkout');
568
569            var headerHeight = jQuery(".user-card.window-header").outerHeight();
570
571            $(".vc-widget-window.active-window").css({
572                'padding-top': headerHeight+'px'
573            });
574
575            $("#vcPlugin span:not(.vc-hide-widget)").text(vcm_options.vcWidgetLabelText);
576
577            $(".vc-widget-window.active-window .tabs a").on('click', function() {
578                $(".tabs a").removeClass("active");
579                $(this).addClass("active");
580                var openTab = $(this).attr("data-href");
581                $(".tabs-info").hide();
582                $("#" + openTab).show();
583                var height = jQuery(".popbox-inner").outerHeight();
584                vcApp.popBox.wrap().height(height);
585            });
586
587
588            $(".btn-show-profile").on('click', function () {
589                handelCalender();
590                var height = jQuery(".popbox-inner").outerHeight();
591                vcApp.popBox.wrap().height(height);
592            });
593
594            $(".vc-btn-close-window").on('click', function () {
595
596                vcApp.popBox.close();
597
598            });
599
600
601            $(".trans-tabs").on('click', function () {
602
603                jQuery(".orders-history-list").html('<div class="preloader"><i class=" fc-spin vcm-ic-load-spin"></i></div>');
604
605                Api.getRecentCardActivity({}, function (data) {
606
607                    $(".orders-history-list").html(data.html);
608
609                });
610
611            });
612
613
614            $(".btn-update-member").on('click', function (e) {
615                
616                e.target.classList.add('loading');
617
618                vcApp.popBox.showPreloader();
619
620                var formData = objectifyDataForm('.vc-update-member-form');
621
622                if (formData.BirthDateDay == "0" || formData.BirthDateMonth == "0" || formData.BirthDateYear == "0") {
623                    vcApp.popBox.addAlert('תאריך יום הולדת לא תקי×
623Ÿ');
624                    vcApp.popBox.hidePreloader();
625                    loadingButton.hidePreloader();
626                    return;
627                }
628
629                var data = jQuery('.vc-update-member-form').serialize();
630
631                Api.updateMember(data, function (updateResponse) {
632                    vcApp.popBox.hidePreloader();
633
634                    if (updateResponse.is_error) {
635                        vcApp.popBox.addAlert(updateResponse.message);
636                        loadingButton.hidePreloader();
637                        e.target.classList.remove('loading');
638
639                    } else {
640                        vcApp.popBox.addSuccess(updateResponse.message)
641                        loadingButton.hidePreloader();
642                        e.target.classList.remove('loading');
643
644                    }
645
646                });
647
648
649            });
650
651            Widget.setHeight();
652            vcApp.popBox.wrap().width('370px');
653
654            if (jQuery(".vcm-progress-wrapper").length) {
655
656                jQuery(".vcm-progress-wrapper").css({ "margin-right": jQuery(".vc-step:first-child").outerWidth()/2, "margin-left": jQuery(".vc-step:last-child").outerWidth()/2 });
657
658                setTimeout(function () {
659                    
660                var progressWrapper = jQuery(".vcm-progress-wrapper").outerWidth();
661                var progressSize = jQuery(".vcm-progress-bar").outerWidth();
662                var labelSize = jQuery(".vcm-progress-amount").outerWidth();
663
664                    var progressSize = 0;
665                    $(".vcm-progress-bar").each(function () { 
666                        progressSize = progressSize + $(this).outerWidth(); 
667                    });
668
669                    console.log(progressSize);
670
671                    var labelMargin;
672                    labelMargin = progressSize-(labelSize /2);
673                    $(".vcm-progress-amount").attr("style", "right:" + (labelMargin - 3) + "px");
674
675
676                }, 200);
677
678            }
679
680        }
681
682    }
683
684    Widget.init();
685
686    window.vcm_options = window.vcm_options || [];
687    
688    if (!vcm_options.isMobile) {
689        if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
690            vcm_options.isMobile = true;
691        }
692    }
693
694    if (window.vcm_options.attachVcmWidget) {
695        Widget.attach();
696    }
697
698
699});

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.