PageSourceSearch

https://www.mediaconstruct.ro/wp-content/themes/dwt-listing/assets/js/profile.js?ver=7.1.3

js mediaconstruct.ro collected 2026-10-06 21:35:29 UTC 66,069 bytes, 2,026 lines download raw bytes

1// document.addEventListener('DOMContentLoaded', function () {
2//   var meetingLinkBox = document.querySelector('.form-meeting');
3//   var statusDropdown = document.getElementById('booking_status');
4
5
6//   if (statusDropdown.value !== 'Approved') {
7//       meetingLinkBox.style.display = 'none';
8//   }
9
10
11//   statusDropdown.addEventListener('change', function () {
12//       if (this.value === 'Approved') {
13//           meetingLinkBox.style.display = 'block';
14//       } else {
15
16//           meetingLinkBox.style.display = 'none';
17//       }
18//   });
19// });
20(function ($) {
21  "use strict";
22  var ajax_url = $("input#dwt_listing_ajax_url").val();
23  var yes_rtl;
24  if ($("#is_rtl").val() !== "" && $("#is_rtl").val() === "1") {
25    yes_rtl = true;
26  } else {
27    yes_rtl = false;
28  }
29
30  if ($(".admin-panel-scroll").length > 0) {
31    $(".admin-panel-scroll .panel-body").slimScroll({
32      height: "800px",
33      wheelStep: 12,
34    });
35  }
36
37  if ($("#sidebar-nav .sidebar-scroll").length > 0) {
38    $("#sidebar-nav .sidebar-scroll").slimScroll({
39      height: "auto",
40      wheelStep: 10,
41      color: "#ccc",
42    });
43  }
44
45  $(".collaspe-btn-admin").on("click", function () {
46    $(this).find(".lnr").toggleClass("lnr-menu lnr-cross");
47
48    if ($(window).innerWidth() < 1025) {
49      if (!$("body").hasClass("admin-sidebar-active")) {
50        $("body").addClass("admin-sidebar-active");
51      } else {
52        $("body").removeClass("admin-sidebar-active");
53      }
54    }
55  });
56
57  var readURL = function (input) {
58    if (input.files && input.files[0]) {
59      var fd = new FormData();
60      var files_data = $(".profile-file-upload");
61      $.each($(files_data), function (i, obj) {
62        $.each(obj.files, function (j, file) {
63          fd.append("my_file_upload[" + j + "]", file);
64        });
65      });
66
67      fd.append("action", "upload_user_pic");
68      $.ajax({
69        type: "POST",
70        url: ajax_url,
71        data: fd,
72        contentType: false,
73        processData: false,
74        success: function (res) {
75          var res_arr = res.split("|");
76          if ($.trim(res_arr[0]) == "1") {
77            $(".profile-pic").attr("src", res_arr[1]);
78            $(".resize").attr("src", res_arr[1]);
79            $("#img-upload-success").show();
80          } else if ($.trim(res_arr[0]) == "0") {
81            $("#max-img-size").show();
82          } else {
83            $("#error-messages").show();
84          }
85        },
86      });
87    }
88  };
89  $(".profile-file-upload").on("change", function () {
90    readURL(this);
91  });
92
93  $(".profile-upload-button").on("click", function () {
94    $(".profile-file-upload").click();
95  });
96
97  /*--- Reset Password ---*/
98  $("#resetPassword")
99    .validator()
100    .on("submit", function (e) {
101      if (e.isDefaultPrevented()) {
102        return false;
103      } else {
104        $(".sonu-button-reset").button("loading");
105        $.post(ajax_url, {
106          action: "dwt_listing_resetmy",
107          collect_data: $("form#resetPassword").serialize(),
108        }).done(function (response) {
109          $(".sonu-button-reset").button("reset");
110          if ($.trim(response) == "1") {
111            $("#password-success").show();
112          }
113        });
114      }
115      return false;
116    });
117
118  /*--- Registration Form Action ---*/
119  $("#profile-update")
120    .validator()
121    .on("submit", function (e) {
122      if (e.isDefaultPrevented()) {
123        return false;
124      } else {
125        $(".update_profile").button("loading");
126        $.post(ajax_url, {
127          action: "dwt_listing_profile_update",
128          collect_data: $("form#profile-update").serialize(),
129        }).done(function (response) {
130          $(".update_profile").button("reset");
131          if ($.trim(response) == "1") {
132            $("#p_up").hide();
133            $("#success-messages").show();
134            window.setTimeout(function () {
135              window.location.reload(true);
136            }, 1000);
137          } else {
138            $.alert({
139              title: get_strings.whoops,
140              backgroundDismiss: true,
141              rtl: yes_rtl,
142              icon: "fa fa-frown-o",
143              theme: "modern",
144              animation: "scale",
145              type: "red",
146              content: response,
147              buttons: { okay: { btnClass: "btn-blue" } },
148            });
149          }
150        });
151        /*--- stop submitting ---*/
152        return false;
153      }
154    });
155
156  /*--- Events  ---*/
157  function dwt_listing_eventz_zone() {
158    Dropzone.autoDiscover = false;
159    var acceptedFileTypes = "image/*";
160    var fileList = new Array();
161    var i = 0;
162    $("#event_dropzone").dropzone({
163      addRemoveLinks: true,
164      paramName: "my_file_upload",
165      maxFiles: $("#event_upload_limit").val(),
166      gallery_limit: $("#event_img_size").val(),
167      acceptedFiles: ".jpeg,.jpg,.png",
168      dictMaxFilesExceeded: $("#max_upload_reach").val(),
169      url:
170        ajax_url +
171        "?action=upload_dwt_listing_events_images&is_update=" +
172        $("#is_update").val(),
173      parallelUploads: 1,
174      dictDefaultMessage: $("#dictDefaultMessage").val(),
175      dictFallbackMessage: $("#dictFallbackMessage").val(),
176      dictFallbackText: $("#dictFallbackText").val(),
177      dictFileTooBig: $("#dictFileTooBig").val(),
178      dictInvalidFileType: $("#dictInvalidFileType").val(),
179      dictResponseError: $("#dictResponseError").val(),
180      dictCancelUpload: $("#dictCancelUpload").val(),
181      dictCancelUploadConfirmation: $("#dictCancelUploadConfirmation").val(),
182      dictRemoveFile: $("#dictRemoveFile").val(),
183      dictRemoveFileConfirmation: null,
184      init: function () {
185        var thisDropzone = this;
186        let url =
187          ajax_url +
188          "?action=upload_dwt_listing_events_images&is_update=" +
189          $("#is_update").val();
190
191        console.log("URLS: ", url);
192        $.post(ajax_url, {
193          action: "get_event_images",
194          is_update: $("#is_update").val(),
195        }).done(function (data) {
196          if (data != 0) {
197            $.each(data, function (key, value) {
198              var mockFile = { name: value.dispaly_name, size: value.size };
199
200              thisDropzone.options.addedfile.call(thisDropzone, mockFile);
201
202              thisDropzone.options.thumbnail.call(
203                thisDropzone,
204                mockFile,
205                value.name
206              );
207              $("a.dz-remove:eq(" + i + ")").attr("data-dz-remove", value.id);
208              i++;
209              $(".dz-progress").remove();
210            });
211          }
212          if (i > 0) $(".dz-message").hide();
213          else $(".dz-message").show();
214        });
215
216        this.on("addedfile", function (file) {
217          $(".dz-message").hide();
218        });
219        this.on("success", function (file, responseText) {
220          var res_arr = responseText.split("|");
221          if ($.trim(res_arr[0]) != "0") {
222            $("a.dz-remove:eq(" + i + ")").attr("data-dz-remove", responseText);
223            i++;
224            $(".dz-message").hide();
225          } else {
226            if (i == 0) $(".dz-message").show();
227            this.removeFile(file);
228            $("#listing_msgz").show();
229            $("#listing_msgz .custom-alert__content").text(res_arr[1]);
230          }
231        });
232        this.on("removedfile", function (file) {
233          var img_id = file._removeLink.attributes[2].value;
234          if (img_id != "") {
235            i--;
236            if (i == 0) $(".dz-message").show();
237            $.post(ajax_url, {
238              action: "delete_event_image",
239              img: img_id,
240              is_update: $("#is_update").val(),
241            }).done(function (response) {
242              if ($.trim(response) == "1") {
243                $("#listing_msgz").hide();
244                /*this.removeFile(file);*/
245              }
246            });
247          }
248        });
249      },
250    });
251  }
252  dwt_listing_eventz_zone();
253  /*--- speakers  ---*/
254  function dwt_listing_speakers_zone() {
255    Dropzone.autoDiscover = false;
256    var acceptedFileTypes = "image/*";
257    var fileList = new Array();
258    var i = 0;
259    $("#speaker_dropzone").dropzone({
260      addRemoveLinks: true,
261      paramName: "my_file_upload",
262      maxFiles: $("#speaker_upload_limit").val(),
263      gallery_limit: $("#speaker_img_size").val(),
264      acceptedFiles: ".jpeg,.jpg,.png",
265      dictMaxFilesExceeded: $("#max_upload_reach").val(),
266      url:
267        ajax_url +
268        "?action=upload_dwt_listing_speaker_images&is_update=" +
269        $("#is_update").val(),
270      parallelUploads: 1,
271      dictDefaultMessage: $("#dictDefaultMessage").val(),
272      dictFallbackMessage: $("#dictFallbackMessage").val(),
273      dictFallbackText: $("#dictFallbackText").val(),
274      dictFileTooBig: $("#dictFileTooBig").val(),
275      dictInvalidFileType: $("#dictInvalidFileType").val(),
276      dictResponseError: $("#dictResponseError").val(),
277      dictCancelUpload: $("#dictCancelUpload").val(),
278      dictCancelUploadConfirmation: $("#dictCancelUploadConfirmation").val(),
279      dictRemoveFile: $("#dictRemoveFile").val(),
280      dictRemoveFileConfirmation: null,
281      init: function () {
282        var thisDropzone = this;
283        let url =
284          ajax_url +
285          "?action=upload_dwt_listing_events_images&is_update=" +
286          $("#is_update").val();
287
288        $.post(ajax_url, {
289          action: "get_speaker_images",
290          is_update: $("#is_update").val(),
291        }).done(function (data) {
292          if (data != 0) {
293            $.each(data, function (key, value) {
294              var mockFile = { name: value.dispaly_name, size: value.size };
295
296              thisDropzone.options.addedfile.call(thisDropzone, mockFile);
297
298              thisDropzone.options.thumbnail.call(
299                thisDropzone,
300                mockFile,
301                value.name
302              );
303              $("a.dz-remove:eq(" + i + ")").attr("data-dz-remove", value.id);
304              i++;
305              $(".dz-progress").remove();
306            });
307          }
308          if (i > 0) $(".dz-message").hide();
309          else $(".dz-message").show();
310        });
311
312        this.on("addedfile", function (file) {
313          $(".dz-message").hide();
314        });
315        this.on("success", function (file, responseText) {
316          var res_arr = responseText.split("|");
317          if ($.trim(res_arr[0]) != "0") {
318            $("a.dz-remove:eq(" + i + ")").attr("data-dz-remove", responseText);
319            i++;
320            $(".dz-message").hide();
321          } else {
322            if (i == 0) $(".dz-message").show();
323            this.removeFile(file);
324            $("#listing_msgz").show();
325            $("#listing_msgz .custom-alert__content").text(res_arr[1]);
326          }
327        });
328        this.on("removedfile", function (file) {
329          var img_id = file._removeLink.attributes[2].value;
330          if (img_id != "") {
331            i--;
332            if (i == 0) $(".dz-message").show();
333            $.post(ajax_url, {
334              action: "delete_speaker_image",
335              img: img_id,
336              is_update: $("#is_update").val(),
337            }).done(function (response) {
338              if ($.trim(response) == "1") {
339                $("#listing_msgz").hide();
340                /*this.removeFile(file);*/
341              }
342            });
343          }
344        });
345      },
346    });
347  }
348  dwt_listing_speakers_zone();
349
350  /*Create Event*/
351  $("#event_title").on("blur", function () {
352    $(".loader-field").css("display", "block");
353    $.post(ajax_url, {
354      action: "create_new_event",
355      event_title: $("#event_title").val(),
356      is_update: $("#is_update").val(),
357    }).done(function (response) {
358      $(".loader-field").css("display", "none");
359    });
360  });
361
362  /*Create speaker by title*/
363  $("#speaker_name").on("blur", function () {
364    $(".loader-field").css("display", "block");
365    $.post(ajax_url, {
366      action: "create_new_speaker_by_title",
367      speaker_title: $("#speaker_name").val(),
368      is_update: $("#is_update").val(),
369    }).done(function (response) {
370      $(".loader-field").css("display", "none");
371    });
372  });
373
374  /*--- Registration Form Action ---*/
375  $("#my-events")
376    .validator()
377    .on("submit", function (e) {
378      if (e.isDefaultPrevented()) {
379        return false;
380      } else {
381        var is_update = $("#is_update").val();
382        var curent_lang = $("#lang").val();
383        var link = $('#webinar_link_input').val();
384        var check = $('#share_webinar_link_checkbox').val();
385        console.log('link: ', link);
386        console.log('check: ', check);
387        $(".sonu-button").button("loading");
388        $.post(ajax_url, {
389          action: "my_new_event",
390          lang: curent_lang,
391          collect_data: $("form#my-events").serialize(),
392          is_update: $("#is_update").val(),
393        }).done(function (response) {
394          console.log(response);
395          $(".sonu-button").button("reset");
396          if (is_update) {
397            $.alert({
398              title: get_strings.congratulations,
399              backgroundDismiss: true,
400              rtl: yes_rtl,
401              icon: "fa fa-smile-o",
402              theme: "modern",
403              animation: "scale",
404              type: "green",
405              content: profile_strings.updated,
406              buttons: {
407                ShowEvent: function () {
408                  window.open(response);
409                },
410                Cancel: function () { },
411              },
412            });
413          } else {
414            $.alert({
415              title: get_strings.congratulations,
416              rtl: yes_rtl,
417              icon: "fa fa-smile-o",
418              theme: "modern",
419              animation: "scale",
420              type: "green",
421              content: profile_strings.created,
422              buttons: {
423                ShowEvent: function () {
424                  window.open(response);
425                },
426                Cancel: function () { },
427              },
428            });
429          }
430        });
431        /*--- stop submitting ---*/
432        return false;
433      }
434    });
435
436  // Create Speaker
437  $("#create-speaker").validator().on('submit', function (e) {
438    e.preventDefault();
439    var is_update = $("#is_update").val();
440    var current_lang = $("#lang").val();
441
442    $(".sonu-button").button("loading");
443
444    $.post(ajax_url, {
445      action: "create_new_speaker",
446      lang: current_lang,
447      collect_data: $("form#create-speaker").serialize(),
448      is_update: is_update,
449    }).done(function (response) {
450      console.log(response);
451      $(".sonu-button").button("reset");
452      if (response.success) {
453        if (is_update) {
454          $.alert({
455            title: get_strings.congratulations,
456            closeIcon: true,
457            rtl: yes_rtl,
458            icon: "fa fa-smile-o",
459            theme: "modern",
460            animation: "scale",
461            type: "green",
462            content: profile_strings.speaker_update_success,
463          });
464        } else {
465          $.alert({
466            title: get_strings.congratulations,
467            closeIcon: true,
468            rtl: yes_rtl,
469            icon: "fa fa-smile-o",
470            theme: "modern",
471            animation: "scale",
472            type: "green",
473            content: profile_strings.speaker_creation_success,
474          });
475        }
476      } else if (!response.success) {
477        $.alert({
478          title: get_strings.whoops,
479          closeIcon: true,
480          rtl: yes_rtl,
481          icon: "fa fa-frown-o",
482          theme: "modern",
483          animation: "scale",
484          type: "red",
485          content: response.data,
486        });
487      }
488    }).fail(function (jqXHR, textStatus, errorThrown) {
489      console.error("Error:", textStatus, errorThrown);
490      $(".sonu-button").button("reset");
491    });
492  });
493  // Create Speaker
494
495  // ============Zoom Settings =================
496  $('#zoom-settings').validator().on('submit', function (e) {
497    e.preventDefault();
498    $(".sonu-button").button("loading");
499    var tncCheckbox = $('#zoomTermsAndCondition');
500    var zoom_email = $('#zoom_email').val();
501    var client_id = $('#zoom_client_id').val();
502    var client_secret = $('#zoom_client_secret').val();
503    var zoomEmailError = $('#zoomEmailError').hide();
504    var zoomClientIdError = $('#zoomClientIdError').hide();
505    var zoomClientSecretError = $('#zoomClientSecretError').hide();
506    var tncCheckboxError = $('#zoomTermsAndConditionError').hide();
507    var validationErrors = [];
508
509    if (zoom_email === '') {
510      validationErrors.push(zoomEmailError);
511    }
512    if (client_id === '') {
513      validationErrors.push(zoomClientIdError);
514    }
515    if (client_secret === '') {
516      validationErrors.push(zoomClientSecretError);
517    }
518
519    if (validationErrors.length === 0) {
520      if (tncCheckbox.is(":checked")) {
521        $.post(ajax_url, {
522          action: "dwt_save_zoom_settings",
523          form_data: $("form#zoom-settings").serialize(),
524        }).done(function (res) {
525          $(".sonu-button").button("reset");
526          if (res.success) {
527            $.alert({
528              title: get_strings.congratulations,
529              closeIcon: true,
530              rtl: yes_rtl,
531              icon: "fa fa-smile-o",
532              theme: "modern",
533              animation: "scale",
534              type: "green",
535              content: res.data,
536            });
537          } else {
538            $.alert({
539              title: get_strings.whoops,
540              closeIcon: true,
541              rtl: yes_rtl,
542              icon: "fa fa-smile-o",
543              theme: "modern",
544              animation: "scale",
545              type: "green",
546              content: res.data,
547            });
548          }
549        }).fail(function (jqXHR, textStatus, errorThrown) {
550          console.error("Error:", textStatus, errorThrown);
551          $(".sonu-button").button("reset");
552        });
553      } else {
554        $(".sonu-button").button("reset");
555        tncCheckboxError.show();
556      }
557    } else {
558      $(".sonu-button").button("reset");
559      validationErrors.forEach(function (error) {
560        error.show();
561      });
562    }
563  });
564
565
566  $('#zoomTermsAndCondition').change(function () {
567    if ($(this).is(":checked")) {
568      $('#zoomTermsAndConditionError').hide();
569    }
570  });
571  // ============Zoom Settings =================
572
573  // =========== Zoom Auth =====================
574  $('.meeting_authorization').click(function () {
575    var reservationId = $(this).closest('.meeting-container').find('.reservation_id_listing').val();
576    var $button = $(this);
577    $button.button("loading");
578    $.post(ajax_url, {
579      action: 'dwt_zoom_auth_user',
580    }).done(function (response) {
581      $button.button("reset");
582      var zoom_auth_window = window.open(response,
583        '', 'scrollbars=no,menubar=no,resizable=yes,toolbar=no,status=no,width=800, height=400');
584
585      var auth_window_timer = setInterval(function () {
586        console.log("Checking if window is closed...");
587        if (zoom_auth_window.closed) {
588          clearInterval(auth_window_timer);
589
590          $.post(ajax_url, {
591            reservation_id: reservationId,
592            action: 'dwt_load_zoom_meeting_form_func',
593          }).done(function (response) {
594            $("#zoom_meeting_container").html(response);
595            $('.zoom-meeting-popup').modal('show');
596            $("#meeting_authorization").attr("disabled", false);
597          }).fail(function (xhr, status, error) {
598            console.error("Error:", error);
599          });
600        }
601      }, 500);
602
603      $(".meeting_authorization").attr("disabled", false);
604    });
605  });
606  // =========== Zoom Auth =====================
607
608  // =========== Zoom Refresh Access Token =====================
609  $('#refresh_zoom_token').click(function () {
610    $(".refresh-token-button").button("loading");
611    $.post(ajax_url, {
612      action: 'dwt_refresh_zoom_access_token'
613    }).done(function (response) {
614      $(".refresh-token-button").button("reset");
615      if (response.success) {
616        $.alert({
617          title: get_strings.congratulations,
618          closeIcon: true,
619          rtl: yes_rtl,
620          icon: "fa fa-smile-o",
621          theme: "modern",
622          animation: "scale",
623          type: "green",
624          content: response.data.message,
625        });
626      } else {
627        $.alert({
628          title: get_strings.whoops,
629          closeIcon: true,
630          rtl: yes_rtl,
631          icon: "fa fa-smile-o",
632          theme: "modern",
633          animation: "scale",
634          type: "red",
635          content: response.data.message,
636        });
637      }
638    })
639    return;
640  })
641  // =========== Zoom Refresh Access Token =====================
642
643  // =========== Copy Meeting Link ===========
644  $(".copy_meeting_url").click(function () {
645    var meetingUrl = $(this).attr('data-meeting-url');
646    var tempInput = $("<input>");
647    $("body").append(tempInput);
648    tempInput.val(meetingUrl).select();
649    document.execCommand("copy");
650    tempInput.remove();
651    $.alert({
652      title: get_strings.congratulations,
653      closeIcon: true,
654      rtl: yes_rtl,
655      icon: "fa fa-smile-o",
656      theme: "modern",
657      animation: "scale",
658      type: "green",
659      content: 'Link Copied to Clipboard',
660    });
661  });
662  // =========== Copy Meeting Link ===========
663
664  // =================Create Meeting ==================
665  $(document).on('submit', '.zoom-meeting-form', function (e) {
666    e.preventDefault();
667    var $button = $('#btn_update_meeting');
668    $button.button("loading");
669    var this_value = $(this);
670    var meetID = $(this).find("input[name=current_meeting_id]").val();
671    var freelancer_id = $(this).find("input[name=current_author]").val();
672    var reservation_id = $(this).find("input[name=current_job]").val();
673
674    this_value.find('span.bubbles').addClass('view');
675    $(".zoom-metting-form-btn").attr("disabled", true);
676
677    $.post(ajax_url, {
678      reservation_id: reservation_id,
679      meetID: meetID,
680      form_data: $(this).serialize(),
681      action: 'dwt_setup_zoom_meeting',
682    }).done(function (response) {
683      $button.button("reset");
684      if (response.success) {
685        $.alert({
686          title: get_strings.congratulations,
687          closeIcon: true,
688          rtl: yes_rtl,
689          icon: "fa fa-smile-o",
690          theme: "modern",
691          animation: "scale",
692          type: "green",
693          content: response.data.msg,
694        });
695        window.location.reload(true);
696      } else {
697        $.alert({
698          title: get_strings.whoops,
699          closeIcon: true,
700          rtl: yes_rtl,
701          icon: "fa fa-smile-o",
702          theme: "modern",
703          animation: "scale",
704          type: "red",
705          content: response.data.msg,
706        });
707      }
708    });
709  });
710  // =================Create Meeting ==================
711
712  // =================Delete Meeting ==================
713  $(".delete_zoom_meeting").on("click", function (e) {
714    var $button = $(this);
715    $button.button("loading");
716    e.preventDefault();
717    var reservation_id = $(this).attr('data-res-id');
718    var meeting_id = $(this).attr('data-meetid');
719
720    $.post(ajax_url, {
721      reservation_id: reservation_id,
722      meeting_id: meeting_id,
723      form_data: $(this).serialize(),
724
725      action: 'dwt_zoom_delete_meet',
726    }).done(function (response) {
727      $button.button("reset");
728      if (response.success) {
729        $.alert({
730          title: get_strings.congratulations,
731          closeIcon: true,
732          rtl: yes_rtl,
733          icon: "fa fa-smile-o",
734          theme: "modern",
735          animation: "scale",
736          type: "green",
737          content: response.data.msg,
738        });
739        window.location.reload(true);
740      } else {
741        $.alert({
742          title: get_strings.whoops,
743          closeIcon: true,
744          rtl: yes_rtl,
745          icon: "fa fa-smile-o",
746          theme: "modern",
747          animation: "scale",
748          type: "red",
749          content: response.data.msg,
750        });
751      }
752    });
753  });
754  // =================Delete Meeting ==================
755
756  /* Delete My Events */
757  $(".delete-my-events").on("click", function () {
758    var event_id = $(this).attr("data-myevent-id");
759    $.confirm({
760      title: get_strings.confirmation,
761      icon: "fa fa-question-circle",
762      theme: "supervan",
763      animation: "scale",
764      content: get_strings.content,
765      closeAnimation: "scale",
766      type: "red",
767      buttons: {
768        confirm: {
769          text: get_strings.ok,
770          action: function () {
771            $.post(ajax_url, {
772              action: "remove_my_events",
773              event_id: event_id,
774            }).done(function (response) {
775              var get_r = response.split("|");
776              if ($.trim(get_r[0]) == "1") {
777                $.alert({
778                  title: get_strings.congratulations,
779                  backgroundDismiss: true,
780                  rtl: yes_rtl,
781                  icon: "fa fa-smile-o",
782                  theme: "modern",
783                  animation: "scale",
784                  type: "green",
785                  content: get_r[1],
786                  buttons: { okay: { btnClass: "btn-blue" } },
787                });
788                window.setTimeout(function () {
789                  location.reload();
790                }, 1500);
791              } else {
792                $.alert({
793                  title: get_strings.whoops,
794                  rtl: yes_rtl,
795                  icon: "fa fa-frown-o",
796                  theme: "modern",
797                  animation: "scale",
798                  type: "red",
799                  closeIcon: true,
800                  backgroundDismiss: true,
801                  content: get_r[1],
802                  buttons: { okay: { btnClass: "btn-blue" } },
803                });
804              }
805            });
806          },
807        },
808        cancle: {
809          text: get_strings.cancle,
810        },
811      },
812    });
813    return false;
814  });
815
816  /* Delete Speaker */
817  $(".delete-my-speaker").on("click", function () {
818    var speaker_id = $(this).attr("data-speaker-id");
819    $.confirm({
820      title: get_strings.confirmation,
821      icon: "fa fa-question-circle",
822      theme: "supervan",
823      animation: "scale",
824      content: get_strings.content,
825      closeAnimation: "scale",
826      type: "red",
827      buttons: {
828        confirm: {
829          text: get_strings.ok,
830          action: function () {
831            $.post(ajax_url, {
832              action: "remove_speaker_by_id",
833              speaker_id: speaker_id,
834            }).done(function (response) {
835              var get_r = response.split("|");
836              if ($.trim(get_r[0]) == "1") {
837                $.alert({
838                  title: get_strings.congratulations,
839                  backgroundDismiss: true,
840                  rtl: yes_rtl,
841                  icon: "fa fa-smile-o",
842                  theme: "modern",
843                  animation: "scale",
844                  type: "green",
845                  content: get_r[1],
846                  buttons: { okay: { btnClass: "btn-blue" } },
847                });
848                window.setTimeout(function () {
849                  location.reload();
850                }, 1500);
851              } else {
852                $.alert({
853                  title: get_strings.whoops,
854                  rtl: yes_rtl,
855                  icon: "fa fa-frown-o",
856                  theme: "modern",
857                  animation: "scale",
858                  type: "red",
859                  closeIcon: true,
860                  backgroundDismiss: true,
861                  content: get_r[1],
862                  buttons: { okay: { btnClass: "btn-blue" } },
863                });
864              }
865            });
866          },
867        },
868        cancle: {
869          text: get_strings.cancle,
870        },
871      },
872    });
873    return false;
874  });
875
876  $('#dwt_cat_parent').on('change', function () {
877    var cat_parent = $(this).val();
878    $('#dwt_listing_loading').show();
879    $.post(ajax_url, { action: 'check_acf_active'}).done(function(responce) { 
880      var res = responce.split("|");
881      if(res[0] === '0') {
882        $.post(ajax_url, {
883          action: 'exertio_get_custom_fields', cat_parent: cat_parent
884        }).done(function (response) {
885          console.log(response);
886          if (response.success) {
887            $('#dwt_listing_loading').hide();
888            $('.additional-fields').css("display", "block");
889            // $('.additional-fields').css("display", "flex");
890            $('.additional-fields-container').html(response.data.fields);
891    
892            if ($(".custom-range-slider").length > 0) { $(".custom-range-slider").ionRangeSlider({ skin: "round" }); }
893          }
894          else {
895            $('#dwt_listing_loading').hide();
896            $('.additional-fields').css("display", "none");
897          }
898        });
899      } else {
900        $('#dwt_listing_loading').hide();
901        $('.additional-fields-search').css("display", "none");
902    }
903  });
904    
905  });
906
907  /* verify user number */
908  $(document).on('click', '#sb_verification_ph,#resend_now', function () {
909    var ph_number = $('#sb_ph_number').val();
910    $('#sb_verification_ph_code').hide();
911    $('#sb_verification_ph').hide();
912    $('#sb_verification_ph_back').show();
913    $.post(ajax_url, { action: 'dwt_verification_system', sb_phone_numer: ph_number, }).done(function (response) {
914      var res_arr = response.split("|");
915      console.log(res_arr);
916      if ($.trim(res_arr[0]) != "0") {
917        $('#sb_verification_ph_back').hide();
918        $('.sb_ver_ph_div').hide();
919        $('.sb_ver_ph_code_div').show();
920        $('#sb_verification_ph_code').show();
921        $.alert({
922          title: get_strings.congratulations,
923          backgroundDismiss: true,
924          rtl: yes_rtl,
925          icon: "fa fa-smile-o",
926          theme: "modern",
927          animation: "scale",
928          type: "green",
929          content: res_arr[1],
930          buttons: { okay: { btnClass: "btn-blue" } },
931        });
932        // toastr.success(res_arr[1], '', {timeOut: 4000, "closeButton": true, "positionClass": "toast-top-right"});
933      } else {
934        $('#sb_verification_ph').show();
935        $('#sb_verification_ph_back').hide();
936        $.alert({
937          title: get_strings.whoops,
938          backgroundDismiss: true,
939          rtl: yes_rtl,
940          icon: "fa fa-frown-o",
941          theme: "modern",
942          animation: "scale",
943          type: "red",
944          content: res_arr[1],
945          buttons: { okay: { btnClass: "btn-blue" } },
946        });
947        // toastr.error(res_arr[1], '', {timeOut: 4000, "closeButton": true, "positionClass": "toast-top-right"});
948      }
949    });
950  });
951
952  // verify number code
953  $(document).on('click', '#sb_verification_ph_code', function () {
954    var ph_code = $('#sb_ph_number_code').val();
955    $('#sb_verification_ph_code').hide();
956    $('#sb_verification_ph_back').show();
957    $.post(ajax_url, { action: 'dwt_verification_code', sb_code: ph_code, }).done(function (response) {
958      var res_arr = response.split("|");
959      if ($.trim(res_arr[0]) != "0") {
960        $.alert({
961          title: get_strings.congratulations,
962          backgroundDismiss: true,
963          rtl: yes_rtl,
964          icon: "fa fa-smile-o",
965          theme: "modern",
966          animation: "scale",
967          type: "green",
968          content: res_arr[1],
969          buttons: { okay: { btnClass: "btn-blue" } },
970        });
971        //  toastr.success(res_arr[1], '', {timeOut: 4000, "closeButton": true, "positionClass": "toast-top-right"});
972        location.reload();
973      } else {
974        $('#sb_verification_ph_code').show();
975        $('#sb_verification_ph_back').hide();
976        $.alert({
977          title: get_strings.whoops,
978          backgroundDismiss: true,
979          rtl: yes_rtl,
980          icon: "fa fa-frown-o",
981          theme: "modern",
982          animation: "scale",
983          type: "red",
984          content: res_arr[1],
985          buttons: { okay: { btnClass: "btn-blue" } },
986        });
987        //  toastr.error(res_arr[1], '', {timeOut: 4000, "closeButton": true, "positionClass": "toast-top-right"});
988      }
989    });
990  });
991
992  // $("#make_payment_button").on("click", function () {
993  //   alert("proceeding");
994  //   var listing_id = $(this).attr("data-listing-id");
995  //   const price = document.getElementById("price_of_table").value;
996  //   const apoint_id = document.getElementById("Appointment_id").value;
997  //  console.log(price);
998  //  console.log(apoint_id);
999  //   $.post(ajax_url, {
1000  //     action: "book_listing_paid",
1001  //     listing_id: listing_id,
1002  //     price: price,
1003  //     apoint_id: apoint_id,
1004  //   }).done(function (response) {
1005  //     var res_arr = response.toString().split("|");
1006
1007  //     if ($.trim(res_arr[0]) == "1") {
1008  //       $.alert({
1009  //         title: get_strings.congratulations,
1010  //         closeIcon: true,
1011  //         rtl: yes_rtl,
1012  //         icon: "fa fa-smile-o",
1013  //         theme: "modern",
1014  //         animation: "scale",
1015  //         type: "green",
1016  //         content: get_strings.redirecting_success,
1017  //         backgroundDismiss: true,
1018  //         buttons: { okay: { btnClass: "btn-blue" } },
1019  //       });
1020
1021  //       location.replace(res_arr[2]);
1022  //     } else {
1023  //       $.alert({
1024  //         title: get_strings.whoops,
1025  //         closeIcon: true,
1026  //         rtl: yes_rtl,
1027  //         icon: "fa fa-frown-o",
1028  //         theme: "modern",
1029  //         animation: "scale",
1030  //         type: "red",
1031  //         content: res_arr[1],
1032  //         backgroundDismiss: true,
1033  //       });
1034  //     }
1035  //   });
1036  // });
1037
1038  $("#make_payment_button").on("click", function () {
1039    alert("proceeding");
1040    var listing_id = $(this).attr("data-listing-id");
1041    const price = document.getElementById("price_of_table").value;
1042    const apoint_id = document.getElementById("Appointment_id").value;
1043
1044    // Calculate 10% of the payment amount
1045    // const walletAmount = parseFloat(price) * 0.1;
1046    // const authorAmount = parseFloat(price) - walletAmount;
1047    // console.log(walletAmount);
1048    // console.log(authorAmount);
1049    // Make the AJAX call to process the payment
1050    $.post(ajax_url, {
1051      action: "book_listing_paid",
1052      listing_id: listing_id,
1053      price: price,
1054      apoint_id: apoint_id,
1055      // walletAmount: walletAmount,
1056      // authorAmount: authorAmount
1057    }).done(function (response) {
1058      var res_arr = response.toString().split("|");
1059
1060      if ($.trim(res_arr[0]) == "1") {
1061        $.alert({
1062          title: get_strings.congratulations,
1063          closeIcon: true,
1064          rtl: yes_rtl,
1065          icon: "fa fa-smile-o",
1066          theme: "modern",
1067          animation: "scale",
1068          type: "green",
1069          content: get_strings.redirecting_success,
1070          backgroundDismiss: true,
1071          buttons: { okay: { btnClass: "btn-blue" } },
1072        });
1073
1074        location.replace(res_arr[2]);
1075
1076        // Update wallet amount display
1077        var currentWalletAmount = parseFloat($(".amount_in_wallet h3").text().replace(currency_symbol, ""));
1078        var newWalletAmount = currentWalletAmount + walletAmount;
1079        $(".amount_in_wallet h3").text(currency_symbol + newWalletAmount);
1080      } else {
1081        $.alert({
1082          title: get_strings.whoops,
1083          closeIcon: true,
1084          rtl: yes_rtl,
1085          icon: "fa fa-frown-o",
1086          theme: "modern",
1087          animation: "scale",
1088          type: "red",
1089          content: res_arr[1],
1090          backgroundDismiss: true,
1091        });
1092      }
1093    });
1094  });
1095
1096  /* Expire My Listing */
1097  $(".expire-my-events").on("click", function () {
1098    var event_id = $(this).attr("data-myevent-id");
1099    $.confirm({
1100      title: get_strings.confirmation,
1101      icon: "fa fa-question-circle",
1102      theme: "supervan",
1103      animation: "scale",
1104      content: get_strings.event_expiry,
1105      closeAnimation: "scale",
1106      type: "red",
1107      buttons: {
1108        confirm: {
1109          text: get_strings.ok,
1110          action: function () {
1111            $.post(ajax_url, {
1112              action: "expire_my_events",
1113              event_id: event_id,
1114            }).done(function (response) {
1115              var get_r = response.split("|");
1116              if ($.trim(get_r[0]) == "1") {
1117                $.alert({
1118                  title: get_strings.congratulations,
1119                  rtl: yes_rtl,
1120                  icon: "fa fa-smile-o",
1121                  theme: "modern",
1122                  animation: "scale",
1123                  type: "green",
1124                  content: get_r[1],
1125                  buttons: { okay: { btnClass: "btn-blue" } },
1126                });
1127                window.setTimeout(function () {
1128                  location.reload();
1129                }, 1500);
1130              } else {
1131                $.alert({
1132                  title: get_strings.whoops,
1133                  rtl: yes_rtl,
1134                  icon: "fa fa-frown-o",
1135                  theme: "modern",
1136                  animation: "scale",
1137                  type: "red",
1138                  closeIcon: true,
1139                  backgroundDismiss: true,
1140                  content: get_r[1],
1141                  buttons: { okay: { btnClass: "btn-blue" } },
1142                });
1143              }
1144            });
1145          },
1146        },
1147        cancle: {
1148          text: get_strings.cancle,
1149        },
1150      },
1151    });
1152    return false;
1153  });
1154
1155  /* Expire My Listing */
1156  $(".reactive-my-events").on("click", function () {
1157    var event_id = $(this).attr("data-myevent-id");
1158    $.confirm({
1159      title: get_strings.confirmation,
1160      icon: "fa fa-question-circle",
1161      theme: "supervan",
1162      animation: "scale",
1163      content: get_strings.event_reactive,
1164      closeAnimation: "scale",
1165      type: "red",
1166      buttons: {
1167        confirm: {
1168          text: get_strings.ok,
1169          action: function () {
1170            $.post(ajax_url, {
1171              action: "reactive_my_events",
1172              event_id: event_id,
1173            }).done(function (response) {
1174              var get_r = response.split("|");
1175              if ($.trim(get_r[0]) == "1") {
1176                $.alert({
1177                  title: get_strings.congratulations,
1178                  rtl: yes_rtl,
1179                  icon: "fa fa-smile-o",
1180                  theme: "modern",
1181                  animation: "scale",
1182                  type: "green",
1183                  content: get_r[1],
1184                  buttons: { okay: { btnClass: "btn-blue" } },
1185                });
1186                window.setTimeout(function () {
1187                  location.reload();
1188                }, 1500);
1189              } else {
1190                $.alert({
1191                  title: get_strings.whoops,
1192                  rtl: yes_rtl,
1193                  icon: "fa fa-frown-o",
1194                  theme: "modern",
1195                  animation: "scale",
1196                  type: "red",
1197                  closeIcon: true,
1198                  backgroundDismiss: true,
1199                  content: get_r[1],
1200                  buttons: { okay: { btnClass: "btn-blue" } },
1201                });
1202              }
1203            });
1204          },
1205        },
1206        cancle: {
1207          text: get_strings.cancle,
1208        },
1209      },
1210    });
1211    return false;
1212  });
1213
1214  $("#food_menu")
1215    .validator()
1216    .on("submit", function (e) {
1217      if (e.isDefaultPrevented()) {
1218        return false;
1219      } else {
1220        $(".sonu-button").button("loading");
1221        $.post(ajax_url, {
1222          action: "my_new_menu",
1223          collect_data: $("form#food_menu").serialize(),
1224        }).done(function (response) {
1225          $(".sonu-button").button("reset");
1226        });
1227      }
1228      return false;
1229    });
1230
1231  //======================== On Change Event Type ========================//
1232  $('#event_type').on('change', function () {
1233    var locationInput = $('#address_location');
1234    var latInput = $('#d_latt');
1235    var longInput = $('#d_long');
1236    var webinarLinkRadio = $('#webinar_link_radio_wrapper');
1237    var asteriskSpan = $('#location_asterisk');
1238    var latCont = $('.latitude_input_container')
1239    var longCont = $('.longitude_input_container')
1240    var locCont = $('.location_input_container')
1241    var mapCont = $('.map_view_container')
1242
1243    if ($(this).val() === 'webinar') {
1244      locationInput.prop('disabled', true);
1245      latInput.prop('disabled', true);
1246      longInput.prop('disabled', true);
1247      locationInput.removeAttr('required');
1248      webinarLinkRadio.show();
1249      asteriskSpan.hide();
1250      longCont.hide();
1251      latCont.hide();
1252      locCont.hide();
1253      mapCont.hide();
1254    } else {
1255      locationInput.prop('disabled', false);
1256      latInput.prop('disabled', false);
1257      longInput.prop('disabled', false);
1258      locationInput.attr('required', 'required');
1259      webinarLinkRadio.hide();
1260      $('#webinar_link_input_wrapper').hide();
1261      asteriskSpan.show();
1262      longCont.show();
1263      latCont.show();
1264      locCont.show();
1265      mapCont.show();
1266    }
1267  });
1268
1269  $('input[name="share_webinar_link"]').on('change', function () {
1270    if ($(this).val() === 'yes') {
1271      $('#webinar_link_input_wrapper').show();
1272      $('#webinar_link_input').attr('required', 'required');
1273    } else {
1274      $('#webinar_link_input_wrapper').hide();
1275      $('#webinar_link_input').removeAttr('required');
1276    }
1277  });
1278  //======================== On Change Event Type ========================//
1279
1280  //======================== Copy Webinar Link ========================//
1281  $("#copy_webinar_link").click(function () {
1282    var meetingUrl = $(this).attr('data-webinar-link');
1283    var tempInput = $("<input>");
1284    $("body").append(tempInput);
1285    tempInput.val(meetingUrl).select();
1286    document.execCommand("copy");
1287    tempInput.remove();
1288    $.alert({
1289      title: get_strings.congratulations,
1290      closeIcon: true,
1291      rtl: yes_rtl,
1292      icon: "fa fa-smile-o",
1293      theme: "modern",
1294      animation: "scale",
1295      type: "green",
1296      content: 'Link Copied to Clipboard',
1297    });
1298  });
1299  //======================== Copy Webinar Link ========================//
1300
1301  // On page reload check if the event type is webinar and the radio is checked to show or hide the input fot webinar meeting link//
1302  $(document).ready(function () {
1303    var eventType = $('#event_type').val();
1304    var shareWebinarLink = $('input[name="share_webinar_link"]:checked').val();
1305
1306    function showHideWebinarLinkInput() {
1307      if (shareWebinarLink === 'yes') {
1308        $('#webinar_link_input_wrapper').show();
1309        $('#webinar_link_input').attr('required', 'required');
1310      } else {
1311        $('#webinar_link_input_wrapper').hide();
1312        $('#webinar_link_input').removeAttr('required');
1313      }
1314    }
1315
1316    function handleEventTypeChange() {
1317      var locationInput = $('#address_location');
1318      var latInput = $('#d_latt');
1319      var longInput = $('#d_long');
1320      var webinarLinkRadio = $('#webinar_link_radio_wrapper');
1321      var asteriskSpan = $('#location_asterisk');
1322      var longCont = $('.longitude_input_container');
1323      var latCont = $('.latitude_input_container')
1324      var locCont = $('.location_input_container')
1325      var mapCont = $('.map_view_container')
1326
1327      if (eventType === 'webinar') {
1328        locationInput.prop('disabled', true);
1329        latInput.prop('disabled', true);
1330        longInput.prop('disabled', true);
1331        locationInput.removeAttr('required');
1332        webinarLinkRadio.show();
1333        showHideWebinarLinkInput();
1334        asteriskSpan.hide();
1335        longCont.hide();
1336        latCont.hide();
1337        locCont.hide();
1338        mapCont.hide();
1339      } else {
1340        locationInput.prop('disabled', false);
1341        latInput.prop('disabled', false);
1342        longInput.prop('disabled', false);
1343        locationInput.attr('required', 'required');
1344        webinarLinkRadio.hide();
1345        $('#webinar_link_input_wrapper').hide();
1346        asteriskSpan.show();
1347        longCont.show();
1348        latCont.show();
1349        locCont.show();
1350        mapCont.show();
1351      }
1352    }
1353
1354    if (eventType === 'webinar') {
1355      handleEventTypeChange();
1356    }
1357
1358    $('#event_type').on('change', function () {
1359      eventType = $(this).val();
1360      handleEventTypeChange();
1361    });
1362
1363    $('input[name="share_webinar_link"]').on('change', function () {
1364      shareWebinarLink = $(this).val();
1365      showHideWebinarLinkInput();
1366    });
1367  });
1368  // On page reload check if the event type is webinar and the radio is checked to show or hide the input fot webinar meeting link//
1369
1370  $("#dwt_create_menu")
1371    .validator()
1372    .on("submit", function (e) {
1373      if (e.isDefaultPrevented()) {
1374        return false;
1375      } else {
1376        $(".sonu-button").button("loading");
1377        var listing_id = $("#menu_parent_listingz").val();
1378        $.post(ajax_url, {
1379          action: "dwt_create_menutype",
1380          collect_data: $("form#dwt_create_menu").serialize(),
1381          listing_id: listing_id,
1382        }).done(function (response) {
1383          $("#dwt_create_menu")[0].reset();
1384          $(".sonu-button").button("reset");
1385          $(".menu_modalz").modal("hide");
1386          $("#append_result").html(response);
1387        });
1388        return false;
1389      }
1390    });
1391
1392  /*--- edit menu ---*/
1393  $(document).on("click", ".edit-lmenu", function () {
1394    var listing_id = $(this).attr("data-id");
1395    var key = $(this).attr("data-key");
1396    $(".edit-button-" + key).button("loading");
1397    var trid = $(this).closest("tr").attr("id");
1398    $.post(ajax_url, {
1399      action: "dwt_edit_menutype",
1400      listing_id: listing_id,
1401      key: key,
1402      trid: trid,
1403    }).done(function (response) {
1404      $(".edit-button-" + key).button("reset");
1405      $(".edit_modal_menu").html(response);
1406      $(".menu_modalz1").modal("show");
1407      $("#dwt_update_menu").validator();
1408    });
1409    return false;
1410  });
1411
1412  $(document).on("submit", "#dwt_update_menu", function (e) {
1413    if (e.isDefaultPrevented()) {
1414      return false;
1415    } else {
1416      $(".sonu-button").button("loading");
1417      $.post(ajax_url, {
1418        action: "dwt_update_menutype",
1419        collect_data: $("form#dwt_update_menu").serialize(),
1420      }).done(function (response) {
1421        $(".sonu-button").button("reset");
1422        $(".menu_modalz1").modal("hide");
1423        var res = response.split("|");
1424        $("#" + res[1] + " span.menu_name").html(res[0]);
1425      });
1426      return false;
1427    }
1428  });
1429
1430  /*--- Add new items in menu ---*/
1431  $(document).on("click", ".menu_items_addition", function () {
1432    $(".menu_modalz_itemz").modal("show");
1433    var k_ref = $(this).attr("data-key-ref");
1434    var k_list = $(this).attr("data-key-id");
1435    $("input#reference_key").val(k_ref);
1436    $("input#reference_listing").val(k_list);
1437    return false;
1438  });
1439
1440  /*--- Inserting menu items ---*/
1441  $("#ad_menu_listz")
1442    .validator()
1443    .on("submit", function (e) {
1444      if (e.isDefaultPrevented()) {
1445        return false;
1446      } else {
1447        $(".sonu-button").button("loading");
1448        $.post(ajax_url, {
1449          action: "dwt_ad_new_menu_listz",
1450          collect_data: $("form#ad_menu_listz").serialize(),
1451        }).done(function (response) {
1452          $("#ad_menu_listz")[0].reset();
1453          $(".sonu-button").button("reset");
1454          $(".menu_modalz_itemz").modal("hide");
1455          $(".show_inner_menuz").html(response);
1456          $(".menu_item_historyz").modal("show");
1457        });
1458        return false;
1459      }
1460    });
1461
1462  /*--- edit inner menu type ---*/
1463  $(document).on("click", ".inner-menu-edit", function () {
1464    var listing_id = $(this).attr("data-listing_id");
1465    var key = $(this).attr("data-refer_key");
1466    $(".lmenu-edit-" + key).button("loading");
1467    var trid = $(this).closest("tr").attr("id");
1468    $.post(ajax_url, {
1469      action: "dwt_edit_inner_menugroup",
1470      listing_id: listing_id,
1471      key: key,
1472      trid: trid,
1473    }).done(function (response) {
1474      $(".lmenu-edit-" + key).button("reset");
1475      $(".show_updated_modal").html(response);
1476      $(".fetch_inner_form").modal("show");
1477      $("#update_inner_itemz_menu").validator();
1478    });
1479    return false;
1480  });
1481
1482  /*--- update menu ---*/
1483  $(document).on("submit", "#update_inner_itemz_menu", function (e) {
1484    if (e.isDefaultPrevented()) {
1485      return false;
1486    } else {
1487      $(".sonu-button").button("loading");
1488      $.post(ajax_url, {
1489        action: "dwt_update_current_menu",
1490        collect_data: $("form#update_inner_itemz_menu").serialize(),
1491      }).done(function (response) {
1492        $(".sonu-button").button("reset");
1493        $(".fetch_inner_form").modal("hide");
1494        var res = response.split("|");
1495        $("#" + res[1] + " span.menu_name").html(res[0]);
1496        $("#" + res[1] + " span.menu_price").html(res[2]);
1497      });
1498      return false;
1499    }
1500  });
1501
1502  /*--- View All menu Items ---*/
1503  $(document).on("click", ".l_view_collection", function () {
1504    var listing_id = $(this).attr("data-id");
1505    var key = $(this).attr("data-key");
1506    $(".view-button-" + key).button("loading");
1507    $.post(ajax_url, {
1508      action: "dwt_fetch_inner_menugroupz",
1509      listing_id: listing_id,
1510      key: key,
1511    }).done(function (response) {
1512      $(".view-button-" + key).button("reset");
1513      $(".show_inner_menuz").html(response);
1514      $(".menu_item_historyz").modal("show");
1515    });
1516    return false;
1517  });
1518
1519  $("#menu_parent_listingz").on("change", function () {
1520    $(".menu-btn").show();
1521  });
1522
1523  var m_id = $("#conditional_id").val();
1524  if (typeof m_id != "undefined") {
1525    $(".sk-circle").show();
1526    //$("#menu_parent_listingz").trigger("change");
1527    $(".menu-btn").show();
1528    $.post(ajax_url, {
1529      action: "dwt_fetchmenu_against_listing",
1530      listing_id: m_id,
1531    }).done(function (response) {
1532      $(".sk-circle").hide();
1533      $("#append_result").html(response);
1534    });
1535    return false;
1536  }
1537
1538  /*--- Update profile settings ---*/
1539  $("#profile-settings")
1540    .validator()
1541    .on("submit", function (e) {
1542      if (e.isDefaultPrevented()) {
1543        return false;
1544      } else {
1545        $(".sonu-button").button("loading");
1546        $.post(ajax_url, {
1547          action: "save_profile_settings",
1548          collect_data: $("form#profile-settings").serialize(),
1549        }).done(function (response) {
1550          $(".sonu-button").button("reset");
1551          if ($.trim(response) != "") {
1552            $.alert({
1553              title: get_strings.congratulations,
1554              rtl: yes_rtl,
1555              icon: "fa fa-smile-o",
1556              theme: "modern",
1557              animation: "scale",
1558              type: "green",
1559              content: response,
1560              buttons: { okay: { btnClass: "btn-blue" } },
1561            });
1562            window.setTimeout(function () {
1563              location.reload();
1564            }, 1500);
1565          } else {
1566            $.alert({
1567              title: get_strings.whoops,
1568              closeIcon: true,
1569              rtl: yes_rtl,
1570              backgroundDismiss: true,
1571              icon: "fa fa-frown-o",
1572              theme: "modern",
1573              animation: "scale",
1574              type: "red",
1575              content: response,
1576              buttons: { okay: { btnClass: "btn-blue" } },
1577            });
1578          }
1579        });
1580      }
1581      return false;
1582    });
1583
1584
1585  //ajax for calendar form
1586
1587  $("#reservation_information")
1588    .validator()
1589    .on("submit", function (e) {
1590      if (e.isDefaultPrevented()) {
1591        return false;
1592      } else {
1593        Appointment_id;
1594        var is_update = $("#is_update").val();
1595        var curent_lang = $("#lang").val();
1596        var type_of_ads = $("#type_of_ads").val();
1597        var price = $("#table_price").val();
1598        var Appointment_id = $("#Appointment_id").val();
1599        var meetingType;
1600
1601        // Check if the select element is visible, if yes, get its value
1602        if ($("#appointment_reservationType").is(":visible")) {
1603          meetingType = $("#appointment_reservationType").val();
1604        } else {
1605          // Otherwise, get the value from the hidden input
1606          meetingType = $("#listing_app_meeting_type").val();
1607        }
1608
1609        $(".sonu-button").button("loading");
1610        $.post(ajax_url, {
1611          action: "my_new_reservation",
1612          lang: curent_lang,
1613          type_of_ads: type_of_ads,
1614          price: price,
1615          collect_data: $("form#reservation_information").serialize(),
1616          is_update: $("#is_update").val(),
1617          meeting_type: meetingType
1618        }).done(function (response) {
1619          var res_arr = response.toString().split("|");
1620          if ($.trim(res_arr[0]) == "1") {
1621            $.alert({
1622              title: get_strings.congratulations,
1623              closeIcon: true,
1624              rtl: yes_rtl,
1625              icon: "fa fa-smile-o",
1626              theme: "modern",
1627              animation: "scale",
1628              type: "green",
1629              content: get_strings.redirecting_success,
1630              backgroundDismiss: true,
1631              buttons: { okay: { btnClass: "btn-blue" } },
1632            });
1633
1634            console.log(res_arr[2]);
1635            location.replace(res_arr[2]);
1636            // location.reload();
1637          } else {
1638            $.alert({
1639              title: get_strings.whoops,
1640              closeIcon: true,
1641              rtl: yes_rtl,
1642              icon: "fa fa-frown-o",
1643              theme: "modern",
1644              animation: "scale",
1645              type: "red",
1646              content: response.data.message,
1647              backgroundDismiss: true,
1648            });
1649          }
1650        });
1651
1652
1653        /*--- stop submitting ---*/
1654        return false;
1655      }
1656    });
1657
1658
1659  //enable reservation on listings
1660  $(".create_menu_types").click(function () {
1661    $(".datepicker-here-custom .air-datepicker").remove();
1662  });
1663
1664  $("#reservations").on("submit", function (e) {
1665    if (e.isDefaultPrevented()) {
1666      return false;
1667    } else {
1668      $(".sonu-button").button("loading");
1669      var booked_days = $("#disabled_dates").datepicker().val();
1670      var ads_type = $("#subscription").val();
1671      var price_of_table = $("#table_price").val();
1672      var listing_id = $("#menu_parent_listingz").val();
1673      var table_slot_duration = $("#table_slot_duration").val();
1674      var selectedValue = $("#reservationType").val();
1675
1676      $.post(ajax_url, {
1677        action: "my_reservations",
1678        collect_data: $("form#reservations").serialize(),
1679        restricted_days: booked_days,
1680        table_price: price_of_table,
1681        listing_id: listing_id,
1682        ads_type: ads_type,
1683        table_slot_duration: table_slot_duration,
1684        res_type: selectedValue,
1685      }).done(function (response) {
1686        var res_arr = response.toString().split("|");
1687
1688        if ($.trim(res_arr[0]) == "1") {
1689          $.alert({
1690            rtl: yes_rtl,
1691            icon: "fa fa-smile-o",
1692            theme: "modern",
1693            animation: "scale",
1694            type: "green",
1695            title: get_strings.reservation_created,
1696            content: res_arr[1],
1697            backgroundDismiss: true,
1698            backgroundDismiss: true,
1699          });
1700
1701          location.reload();
1702        } else {
1703          $.alert({
1704            rtl: yes_rtl,
1705            icon: "fa fa-frown-o",
1706            theme: "modern",
1707            animation: "scale",
1708            type: "red",
1709            title: get_strings.no_business_hrs,
1710            backgroundDismiss: true,
1711            content: res_arr[1],
1712            backgroundDismiss: true,
1713          });
1714        }
1715      });
1716    }
1717    return false;
1718  });
1719
1720  //for listing appointment meeting type
1721  $("#appointment_reservationType").on("change", function () {
1722    var selectedType = $(this).val();
1723    var selectedID = $("#listing_id").val();
1724    {
1725
1726      $.ajax({
1727        type: 'POST',
1728        url: ajax_url,
1729        data: {
1730          action: 'store_meeting_type',
1731          meetingType: selectedType,
1732          postID: selectedID
1733        },
1734        success: function (response) {
1735          console.log('Meeting type stored successfully.');
1736          console.log('Response from the server: ', response);
1737        },
1738        error: function (xhr, status, error) {
1739          console.error('Error storing meeting type:', error);
1740        }
1741      });
1742      //   $('#meeting_link_box').hide();
1743    }
1744  });
1745
1746
1747
1748
1749
1750  //   var selectedValue = $(this).val();
1751  // var selectedID = $("#listing_id").val();
1752  // console.log(selectedID);
1753  //   $.ajax({
1754  //       type: 'POST',
1755  //       url: ajax_url,
1756  //       data: {
1757  //           action: 'store_meeting_type',
1758  //           meetingType: selectedValue,
1759  //           postID: selectedID
1760  //       },
1761  //       success: function(response) {
1762  //           // Handle the response here
1763  //           console.log('Meeting type stored successfully.');
1764  //           console.log('Response from server:', response);
1765
1766
1767  //       },
1768  //       error: function(xhr, status, error) {
1769  //           console.error('Error storing meeting type:', error);
1770  //       }
1771  //   });
1772  // });
1773
1774
1775  //js for virtual meeting popup
1776  // document.getElementById('reservationType').addEventListener('change', function() {
1777  //   var selectedOption = this.value;
1778
1779
1780  // $(document).ready(function() {
1781  //   $('#reservationType').change(function() {
1782  //       var selectedValue = $(this).val();
1783  //       var selectedID = $('#listing_id').val();
1784
1785  //       // if (selectedValue === 'virtual_meeting') {
1786  //       //     var meetingLink = prompt('Please enter the link for the virtual meeting:');
1787  //       //     if (meetingLink !== null) {
1788  //       //         saveMeetingLink(meetingLink, selectedValue, selectedID);
1789  //       //     }
1790  //       // }
1791  //   });
1792  // });
1793
1794  // function saveMeetingLink(link, selectedValue, selectedID) {
1795  //   $.ajax({
1796  //       type: 'POST',
1797  //       url: ajax_url, 
1798  //       data: {
1799  //           action: 'store_meeting_type',
1800  //           meetingType: selectedValue,
1801  //           meetingLink: link,
1802  //           postID: selectedID
1803  //       },
1804  //       success: function(response) {
1805  //           // Handle the response here
1806  //           console.log('Meeting type stored successfully.');
1807  //           console.log('Response from server:', response);
1808  //       },
1809  //       error: function(xhr, status, error) {
1810  //           console.error('Error storing meeting type:', error);
1811  //       }
1812  //   });
1813  // }
1814
1815
1816
1817
1818
1819
1820  //for post status
1821
1822  $(".booking_status").on("change", function () {
1823    var booking_status = $(this).val();
1824    var booking_id = $(this).attr("data-id");
1825    var booking_type = $(this).attr("data-type");
1826    var meeting = $(this).attr("data-meeting");
1827
1828    console.log("MEETING", meeting);
1829    var link_field = $(".form-meeting")
1830    if (booking_status === "rejected" || meeting === 'physical_meeting') {
1831      link_field.css("display", "none");
1832      $("#link-text").prop("required", false);
1833    } else if (meeting === 'virtual_meeting') {
1834      link_field.css("display", "block");
1835      $("#link-text").prop("required", true);
1836    }
1837
1838    // var link_text = $(this).val();
1839    $("#current_booking_id").val(booking_id);
1840    $("#current_booking_status").val(booking_status);
1841    //  $("#link-text").val(link_text);
1842    if (booking_type === '' || booking_type === "paid") {
1843      $("#exampleModal").modal({
1844        show: true,
1845      });
1846    }
1847  });
1848
1849  $(".form_booking_email").on("submit", function (e) {
1850    e.preventDefault();
1851    var booking_id = $("#current_booking_id").val();
1852    var booking_status = $("#current_booking_status").val();
1853    var listing_id = $('#listing_id').val();
1854    var message_text = $("#message-text").val();
1855    var link_text = $("#link-text").val();
1856    console.log(message_text);
1857    console.log(link_text);
1858    $.post(ajax_url, {
1859      action: "booked_listing_status",
1860      staus: booking_status,
1861      booking_id: booking_id,
1862      listing_id: listing_id,
1863      message_text: message_text,
1864      link_text: link_text,
1865      // collect_data: $("form#event_attendies").serialize(),
1866
1867    }).done(function (response) {
1868      console.log(response.success);
1869      if (response.success == true) {
1870        $.alert({
1871          title: get_strings.congratulations,
1872          backgroundDismiss: true,
1873          rtl: yes_rtl,
1874          icon: "fa fa-smile-o",
1875          theme: "modern",
1876          animation: "scale",
1877          type: "green",
1878          content: response.data.message,
1879          buttons: { okay: { btnClass: "btn-blue" } },
1880        });
1881        window.setTimeout(function () {
1882          location.reload();
1883        }, 2000);
1884      } else {
1885        $.alert({
1886          title: get_strings.whoops,
1887          closeIcon: true,
1888          rtl: yes_rtl,
1889          backgroundDismiss: true,
1890          icon: "fa fa-frown-o",
1891          theme: "modern",
1892          animation: "scale",
1893          type: "red",
1894          content: response.data.message,
1895          buttons: { okay: { btnClass: "btn-blue" } },
1896        });
1897        window.setTimeout(function () {
1898          location.reload();
1899        }, 2000);
1900      }
1901      // $('.sonu-button').button('reset');
1902      // return false;
1903    });
1904  });
1905
1906  //for tickets status
1907
1908  $(".ticket_status").on("change", function () {
1909    var tickets_status = $(this).val();
1910    var tickets_id = $(this).attr("data-event-id");
1911    $("#current_tickets_id").val(tickets_id);
1912    $("#current_tickets_status").val(tickets_status);
1913    $("#exampleModals").modal({
1914      show: true,
1915    });
1916  });
1917
1918  $(".form_ticket_booking_email").on("submit", function (e) {
1919    e.preventDefault();
1920    var tickets_id = $("#current_tickets_id").val();
1921    var tickets_status = $("#current_tickets_status").val();
1922    var messages_text = $("#messages-text").val();
1923    $.post(ajax_url, {
1924      action: "booked_tickets_status",
1925      staus: tickets_status,
1926      tickets_id: tickets_id,
1927      message_text: messages_text,
1928    }).done(function (response) {
1929      $(".sonu-button").button("reset");
1930      return false;
1931    });
1932  });
1933
1934  //adding event attendees
1935  $("#attending_event").on("click", function () {
1936    var event_id = $("#attending_event").attr("event-data-id");
1937    $.post(ajax_url, {
1938      action: "event_attendees_status",
1939      event_id: event_id,
1940    }).done(function (response) {
1941      location.reload();
1942    });
1943  });
1944
1945  //deleting meta of not attending event
1946
1947  $("#cancel_attendance").on("click", function () {
1948    var event_id = $("#cancel_attendance").attr("event-data-delete-id");
1949
1950    $.post(ajax_url, {
1951      action: "dwt_delete_event_attendance",
1952      event_id: event_id,
1953    }).done(function (response) {
1954      location.reload();
1955    });
1956  });
1957
1958  //ajax for Payouts
1959
1960  $("#payout_form")
1961    .validator()
1962    .on("submit", function (e) {
1963      if (e.isDefaultPrevented()) {
1964        return false;
1965      } else {
1966        var is_update = $("#is_update").val();
1967        var curent_lang = $("#lang").val();
1968        $(".sonu-button").button("loading");
1969        $.post(ajax_url, {
1970          action: "my_event_payouts",
1971          lang: curent_lang,
1972          collect_data: $("form#payout_form").serialize(),
1973          is_update: $("#is_update").val(),
1974        }).done(function (response) {
1975          $(".sonu-button").button("reset");
1976
1977          if (response.success == true) {
1978            $.alert({
1979              title: get_strings.payout_sent,
1980              rtl: yes_rtl,
1981              icon: "fa fa-smile-o",
1982              theme: "modern",
1983              animation: "scale",
1984              type: "green",
1985              content: profile_strings,
1986              buttons: {
1987                Close: function () {
1988                  location.reload();
1989                },
1990              },
1991            });
1992          } else {
1993            $.alert({
1994              title: get_strings.amount_is_greater,
1995              rtl: yes_rtl,
1996              icon: "fa fa-frown-o",
1997              theme: "modern",
1998              animation: "scale",
1999              type: "red",
2000              content: profile_strings,
2001              buttons: {
2002                Close: function () { },
2003              },
2004            });
2005          }
2006        });
2007        /*--- stop submitting ---*/
2008        return false;
2009      }
2010    });
2011
2012  $("#subscription").change(function () {
2013    var selectedOption = $(this).val();
2014    var priceField = $(".table_reservation_price");
2015
2016    if (selectedOption === "paid") {
2017      priceField.show();
2018    } else {
2019      priceField.hide();
2020    }
2021    if (selectedOption === "free") {
2022      priceField.hide();
2023    }
2024  });
2025})(jQuery);
2026

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.