PageSourceSearch

https://www.ofmclinic.com/assets/front/js/custom.js?v=1790902425

js ofmclinic.com collected 2026-10-02 00:54:16 UTC 16,550 bytes, 580 lines download raw bytes

1// checkCart();
2// sticky header js
3$(window).scroll(function(){
4  if ($(window).scrollTop() >= 50) {
5    $('.menu').addClass('sticky-header');
6   }
7   else {
8    $('.menu').removeClass('sticky-header');
9   }
10});
11
12// on page change add active class to link
13$(function(){
14  var current_page_URL = location.href;
15  $( ".navbar-nav a" ).each(function() {
16     if ($(this).attr("href") !== "#") {
17       var target_URL = $(this).prop("href");
18       if (target_URL == current_page_URL) {
19          $('.navbar-nav a').parents('li').removeClass('active');
20          $(this).parent('li').addClass('active');
21          return false;
22       }
23     }
24  });
25});
26
27//product list slider js
28$('.product-list-slider').slick({
29  dots: false,
30  arrows: true,
31  infinite: false,
32  speed: 300,
33  slidesToShow: 3,
34  slidesToScroll: 1,
35  responsive: [
36    {
37      breakpoint: 1024,
38      settings: {
39        slidesToShow: 2
40      }
41    },
42    {
43      breakpoint: 600,
44      settings: {
45        slidesToShow: 1
46      }
47    }
48  ]
49});
50
51// on click change product image
52function changeimg(url,e) {
53  document.getElementById("img").src = url;
54  let nodes = document.getElementById("thumb_img");
55  let img_child = nodes.children;
56  for (i = 0; i < img_child.length; i++) {
57    img_child[i].classList.remove('active')
58  }
59  e.classList.add('active');
60
61}
62
63// select address
64$(".billing-address li").on('click', function(){
65    $(".billing-address li").removeClass('active');
66    $(this).addClass('active');
67});
68
69// select card
70$(".card-list-wrap li").on('click', function(){
71    $(".card-list-wrap li").removeClass('active');
72    $(this).addClass('active');
73});
74
75// search box
76document.addEventListener("DOMContentLoaded", function () {
77  let clickElement = document.getElementById("click");
78  let searchField = document.getElementById("search-field");
79
80  if (clickElement && searchField) { 
81    clickElement.addEventListener("click", function () {
82      searchField.classList.toggle("form-active");
83      setTimeout(function(){
84        document.querySelector(".search_bar_input")?.focus();
85      }, 100);
86    });
87  }
88});
89// document.getElementById("click").addEventListener("click", function () {
90//   document.getElementById("search-field").classList.toggle("form-active");
91//   setTimeout(function(){
92//     $(".search_bar_input").focus();
93//   },100);
94  
95// });
96
97// onscroll  search box close js
98$(window).on('scroll', function(e){ 
99    $(".search-field1").removeClass('form-active'); 
100});
101
102// product counter
103var num;
104
105$('.button-count:first-child').click(function(){
106  num = parseInt($('input:text').val());
107  if (num > 1) {
108    $('input:text').val(num - 1);
109  }
110  if (num == 2) {
111    $('.button-count:first-child').prop('disabled', true);
112  }
113  if (num == 10) {
114    $('.button-count:last-child').prop('disabled', false);
115  }
116});
117
118$('.button-count:last-child').click(function(){
119  num = parseInt($('input:text').val());
120  if (num < 10) {
121    $('input:text').val(num + 1);
122  }
123  if (num > 0) {
124    $('.button-count:first-child').prop('disabled', false);
125  }
126  if (num == 9) {
127    $('.button-count:last-child').prop('disabled', true);
128  }
129});
130
131//========================Alert==========================================
132setTimeout(function(){
133    $('.alert_message').hide();
134},3000);
135//========================Alert==========================================
136
137
138//========================Email check ===================================
139
140$(document).ready(function() {
141
142   
143    $('.exists_email').parsley();
144
145    var old_value = $("#old_name").val();
146    var table_name = 'users';
147    var field_name = 'email';
148
149    window.ParsleyValidator.addValidator('checkemail', {
150        validateString: function(value) {
151            return $.ajax({
152                url: BASE_URL + "check-duplicate-data",
153                method: "POST",
154                data: {
155                    new_value: value,
156                    old_value: old_value,
157                    table_name: table_name,
158                    field_name: field_name
159                },
160                dataType: "json",
161                success: function(data) {
162                    return true;
163                }
164            });
165        }
166    });
167    //========================Email check ===================================
168
169    // Check duplicate card number validation
170    $('.existscardnumber').parsley();
171    window.ParsleyValidator.addValidator('checkcardnumber', {
172        validateString: function(value) {
173            return $.ajax({
174                url: BASE_URL + "check-card-number",
175                method: "POST",
176                data: {
177                    new_value: value,
178                },
179                dataType: "json",
180                success: function(data) {
181                    return true;
182                }
183            });
184        }
185    });
186
187});
188
189
190
191
192
193//========================NUMBER==========================================
194
195$(document).ready(function() {
196
197    //called when key is pressed in textbox
198
199    $(".number").keypress(function(e) {
200
201        //if the letter is not digit then display error and don't type anything
202
203        if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57))
204
205
206
207            return false;
208
209        return true;
210
211
212
213    });
214
215});
216
217//========================NUMBER==========================================
218
219
220
221//========================NUMBER ( . )==========================================
222
223$(document).ready(function() {
224
225    //called when key is pressed in textbox
226
227    $(".number_pnt").keypress(function(evt) {
228
229        console.log('number_pnt');
230
231        //if the letter is not digit then display error and don't type anything
232
233        var iKeyCode = (evt.which) ? evt.which : evt.keyCode
234
235        if (iKeyCode != 46 && iKeyCode > 31 && (iKeyCode < 48 || iKeyCode > 57))
236
237            return false;
238
239        return true;
240
241    });
242
243});
244
245//========================NUMBER ( . )==========================================
246
247//======================== Notification Alert ==========================================
248function notify(message,status){
249
250  $.notify({
251    // options
252    message: message,
253    style: 'bootstrap',
254    className:"notify_class",
255    autoHide: true,
256    autoHideDelay: 1000,
257  },{
258      // settings
259      type: status,
260      z_index:99999,
261      style: 'bootstrap',
262      className:"notify_class",
263      autoHide: true,
264      autoHideDelay: 1000,
265  });
266}
267//======================== Notification Alert ==========================================
268
269//======================== Add to Cart ==========================================
270$(document).on("click",".btn-add-cart", function(e) {
271
272  var product_id = $(this).data("id");
273  var redirect = $(this).data("redirect");
274  var referesh = 0;
275  if($(this).data("refresh")){
276    referesh = 1;
277  }
278  var self = $(this);
279  if (product_id != '') {
280      $.ajax({
281          type: "POST",
282          url: BASE_URL + 'add-to-cart',
283          data: {
284              'product_id': product_id
285          },
286          dataType: "json",
287          success: function(response) {
288              if(response.status == "success"){
289                if(redirect == "1"){
290                    window.location.href = BASE_URL+'cart'
291                }else{
292                  if(referesh == 1){
293                    window.location.href = BASE_URL+'cart'
294                  }else{
295                    // checkCart();
296                    notify("Add to cart successfully","success");
297                  }
298                }
299              }else{
300                  self.prop("disabled",true);
301                  notify(response.message,"danger");
302              }
303          },
304          error: function(error) {}
305      });
306  } else {
307      
308  }
309});
310
311$(document).on("input",".product_detail_qty",function(){
312  if($(this).val() == "" || $(this).val() == 0 || $(this).val() == "0"){
313    $(this).val(1);
314    $(".count-increase").prop("disabled",false);
315    $(".count-decrease").prop("disabled",true);
316    
317  }else{
318    var closest = $(this).closest(".product-count");
319    var qty = parseInt($(this).val());
320    var remaining_qty = parseInt(closest.find(".remaining_qty").val());
321    if(remaining_qty > 0){
322        if(remaining_qty >= qty){
323          $(".count-increase").prop("disabled",false);
324          if(qty > 1){
325            $(".count-decrease").prop("disabled",false);
326          }else{
327            $(".count-decrease").prop("disabled",true);
328          }
329          if(qty >= remaining_qty){
330            $(".count-increase").prop("disabled",true);
331          }else{
332            $(".count-increase").prop("disabled",false);
333          }
334        }else{
335          notify("Maximum "+remaining_qty+ " quantity available","danger");
336          $(this).val(1);
337          $(".count-increase").prop("disabled",false);
338          $(".count-decrease").prop("disabled",true);
339        }
340    }else{
341      $(this).val(1);
342      $(".count-increase").prop("disabled",false);
343      $(".count-decrease").prop("disabled",true);
344    }
345  }
346});
347
348// For Product detail page
349$(document).on("click",".btn-pro-add-cart", function(e) {
350  var product_id = $(this).data("id");
351  var redirect = $(this).data("redirect");
352  var pro_cart_qty = $(".pro_cart_qty").val();
353  var self = $(this);
354  if (product_id != '') {
355      $.ajax({
356          type: "POST",
357          url: BASE_URL + 'update-cart',
358          data: {
359              'product_id': product_id,
360              'pro_cart_qty': pro_cart_qty,
361          },
362          dataType: "json",
363          success: function(response) {
364              if(response.status == "success"){
365                if(redirect == "1"){
366                    window.location.href = BASE_URL+'cart'
367                }else{
368                    // checkCart();
369                    self.prop("disabled",true);
370                    notify("Add to cart successfully","success");
371                }
372              }else{
373                self.prop("disabled",true);
374                notify(response.message,"danger");
375              }
376          },
377          error: function(error) {}
378      });
379  } else {
380      
381  }
382});
383//======================== Add to Cart ==========================================
384
385//======================== Increase cart qty ==========================================
386$(document).on("click",".count-increase",function(){
387    $(".btn-pro-add-cart").prop("disabled",false);
388    var closest = $(this).closest(".product-count");
389    var qty = parseInt(closest.find(".pro_cart_qty").val()) + 1;
390    var remaining_qty = parseInt(closest.find(".remaining_qty").val());
391    if(remaining_qty > 0){
392      if(remaining_qty >= qty){
393        closest.find(".pro_cart_qty").val(qty);
394        updateCart(closest);
395        closest.find(".count-increase").prop("disabled",false);
396        if(qty > 1){
397          closest.find(".count-decrease").prop("disabled",false);
398        }
399        if(qty >= remaining_qty){
400          closest.find(".count-increase").prop("disabled",true);
401        }else{
402          closest.find(".count-increase").prop("disabled",false);
403        }
404      }else{
405        closest.find(".count-increase").prop("disabled",true);
406        notify("Maximum "+remaining_qty+ " quantity available","danger");
407      }
408    }else{
409      closest.find(".count-increase").prop("disabled",true);
410      notify("Item out of stock","danger");
411    }
412});
413
414
415$(document).on("change",".change_cart_qty",function(){
416    var qty = parseInt($(this).val());
417    $(".btn-pro-add-cart").prop("disabled",false);
418    var closest = $(this).closest(".product-count");
419    var remaining_qty = parseInt(closest.find(".remaining_qty").val());
420    var oldQty = parseInt(closest.find(".old_cart_qty").val());
421    if(qty > 0){
422      if(remaining_qty > 0){
423        if(remaining_qty >= qty){
424          closest.find(".pro_cart_qty").val(qty);
425          closest.find(".old_cart_qty").val(qty);
426          updateCart(closest);
427          if(qty > 1){
428            closest.find(".count-decrease").prop("disabled",false);
429          }else{
430            closest.find(".count-decrease").prop("disabled",true);
431          }
432          if(qty >= remaining_qty){
433            closest.find(".count-increase").prop("disabled",true);
434          }else{
435            closest.find(".count-increase").prop("disabled",false);
436          }
437        }else{
438          if(oldQty > 1){
439            closest.find(".count-increase").prop("disabled",true);
440          }
441          $(this).val(oldQty);
442          notify("Maximum "+remaining_qty+ " quantity available","danger");
443        }
444      }else{
445        $(this).val(oldQty);
446        if(oldQty > 1){
447          closest.find(".count-increase").prop("disabled",true);
448        }
449        notify("Item out of stock","danger");
450      }
451    }else{
452      $(this).val(oldQty);
453    }
454});
455
456//======================== Increase cart qty ==========================================
457
458//======================== Decrease cart qty ==========================================
459$(document).on("click",".count-decrease",function(){
460  $(".btn-pro-add-cart").prop("disabled",false);
461  var closest = $(this).closest(".product-count");
462  closest.find(".count-increase").prop("disabled",false);
463  var qty = parseInt(closest.find(".pro_cart_qty").val()) - 1;
464  if(qty<=1){
465    closest.find(".pro_cart_qty").val(1);
466    closest.find(".count-decrease").prop("disabled",true);
467  }else{
468    closest.find(".pro_cart_qty").val(qty);
469  }
470  updateCart(closest);
471});
472//======================== Decrease cart qty ==========================================
473
474//======================== Cancel Plan ==========================================
475$(document).on("click",".cancel_plan_btn",function(){
476    var membership_id = $("#membership_id").val();
477    Swal.fire({
478
479      title: "Are you sure that you want to cancel this plan?",
480
481      text: "You will not be able to recover plan!",
482
483      icon: "warning",
484
485      showCancelButton: true,
486
487      confirmButtonColor: "#28D094",
488
489      confirmButtonText: "Yes, cancel it!",
490
491      cancelButtonText: "No, cancel please!",
492
493  }).then((result) => {
494
495    if (result.value) {
496        $.ajax({
497          type: "POST",
498          url: BASE_URL + 'cancel-plan',
499          data: {
500              'membership_id': membership_id,
501          },
502          dataType: "json",
503          success: function(response) {
504            $(".cancel_plan_btn").html("Cancelled");
505            $(".cancel_plan_btn").removeClass("cancel_plan_btn");
506            $(".membership_detail").remove();
507            Swal.fire("Success", "Your plan has been cancelled :)", "success");
508
509          },
510          error: function(error) {}
511      });
512    } else {
513        Swal.fire("Cancelled", "Your plan is safe :)", "error");
514    }
515
516  });
517});
518//======================== Cancel Plan ==========================================
519
520//======================== Update Cart Page========================================== //
521
522function updateCart(obj){
523  var is_update_cart = obj.find(".is_update").val();
524  var tr = obj.closest("tr");
525  if(is_update_cart == 1){
526    var cart_id = obj.find(".cart_id").val();
527    var qty = obj.find(".pro_cart_qty").val();
528    $.ajax({
529      type: "POST",
530      async:false,
531      url: BASE_URL + 'update-ajax-cart',
532      data: {
533          'cart_id': cart_id,
534          'qty': qty,
535      },
536      dataType: "json",
537      success: function(response) {
538          tr.find(".pro_sub_total_amount").html(response.cart_item_sub_total);
539          $(".sub_total_amount").html(response.sub_total);
540          $(".discount").html('('+response.discount+')');
541          $(".discount_amount").html(response.discount_amount);
542          $(".total_amount").html(response.total_amount);
543          $(".tax_amount").html(response.tax_amount);
544      },
545      error: function(error) {}
546  });
547  }
548}
549
550//======================== Update Cart Page========================================== //
551
552//======================== Check Cart Is Empty Or Not ========================================== //
553
554// function checkCart(){
555//   $.ajax({
556//       type: "POST",
557//       async:false,
558//       url: BASE_URL + 'check-cart',
559//       dataType: "json",
560//       success: function(response) {
561//           if(response.status == true){
562//             $(".cart_counter").show();
563//           }else{
564//             $(".cart_counter").hide();
565//           }
566//       },
567//       error: function(error) {}
568//   });
569// }
570
571//======================== Check Cart Is Empty Or Not ========================================== //
572
573function isNumber(evt) {
574  evt = evt ? evt : window.event;
575  var charCode = evt.which ? evt.which : evt.keyCode;
576  if (charCode > 31 && (charCode < 48 || charCode > 57)) {
577    return false;
578  }
579  return true;
580}

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.