PageSourceSearch

https://ashghal-ye.com/public/assets/frontend/js/script.js?version=?version=642245

js ashghal-ye.com collected 2026-09-24 14:38:39 UTC 21,356 bytes, 1,012 lines download raw bytes

1jQuery(document).ready(function ($) {
2
3
4
5
6
7  let baseUrl = $("#baseurl").val();
8
9
10  $('.collapse-select').change(function() {
11    var selectedValue = $(this).val();
12    var targetId = $(this).attr('id');
13
14    $('[data-target="' + targetId + '"]').each(function() {
15        if ($(this).attr('data-value') === selectedValue) {
16            $(this).slideDown();
17        } else {
18            $(this).slideUp();
19        }
20    });
21});
22
23
24
25  function apiForm(selector, callback, onError = () => { }) {
26
27
28    $("body").on("submit", selector, function () {
29
30      let form = $(this);
31
32      console.log($(this).attr("action"));
33
34      let submit = $(this).find("button[type='submit']");
35      let responseP = form.find('.response-message');
36
37      let formData = new FormData($(this)[0]);
38      let content = submit.html();
39
40      if (form.hasClass("loading")) return false;
41      form.addClass("loading");
42      // submit.html(' <i class="fi fi-rr-spinner rotating "></i>').attr('disabled', 'disabled');
43      submit.text('يرجى الإنتظار').attr('disabled', 'disabled');
44
45      $.ajax({
46
47
48        type: $(form).attr("method"),
49        url: $(form).attr("action"),
50        data: formData,
51        processData: false,
52        contentType: false,
53        // async: false,
54        cache: false,
55        dataType: 'json',
56        success: function (data) {
57          form.removeClass("loading");
58
59          // console.log(data.message);
60          responseP.removeClass(' alert-danger alert-success ').html(data.message);
61
62          if (data.status) {
63
64            responseP.addClass('alert-success alert');
65
66            callback(data);
67
68          } else {
69            responseP.addClass('alert-danger alert');
70
71
72
73            onError(data);
74
75          }
76
77
78          submit.removeAttr("disabled").html(content);
79
80        },
81        error: function (error) {
82          form.removeClass("loading");
83
84          if (error.status == 422) {
85            onError(error);
86
87            responseP.removeClass('alert-danger alert-success').addClass('alert-danger alert').html("");
88            $.each(error.responseJSON.errors, function (key, value) {
89              responseP.append('<span>' + value + '</span>');
90            });
91          } else {
92            form.find('.response-message').removeClass('alert-danger alert-success').addClass('alert-danger alert').text("حصلت مشكلة ، يرجى إعادة المحاولة").removeAttr("disabled");
93
94            // responseP.append('<span>' + error.responseJSON.message + '</span>');
95          }
96
97          onError(error);
98
99
100          console.log(error);
101          submit.removeAttr("disabled").html(content);
102        }
103
104
105      });
106
107      return false;
108
109    });
110
111  }
112  apiForm("#guider-login-form", (data) => {
113
114    window.location = data.redirect;
115
116
117  }, (error) => { });
118
119
120
121  apiForm(".api-form", (data) => {
122
123
124  }, (error) => { });
125
126
127
128  function showAlert(msg) {
129    // alert(msg);
130    $(".notify").toggleClass("active");
131    $("#notifyType").toggleClass("success").text(msg);
132    setTimeout(function () {
133      $(".notify").removeClass("active");
134      $("#notifyType").removeClass("success");
135    }, 2000);
136  }
137
138  function updateModal(modalTitle, modalText, replaceElement, url) {
139
140    var modal = $("#update-modal");
141
142    modal.find(".modal-title").text(modalTitle);
143    modal.find("#update-modal-text").html("هل ترغب ب" + modalText + "؟");
144    modal.find("#update-modal-ajax-url").val(url);
145
146    modal.find("#update-modal-replace-element").val(replaceElement);
147
148    modal.modal("show");
149  }
150
151  function dropZoneObj(selector, uploadMultiple = true, maxFiles = 10) {
152
153
154    if ($(selector).length) {
155      let $this = $(selector);
156
157      var output = $($this.attr("data-output"));
158      let uploader = new Dropzone(selector, {
159        url: $this.attr("data-url"),
160        paramName: "files",
161        uploadMultiple: uploadMultiple,
162        // acceptedFiles: "image/*",
163        addRemoveLinks: true,
164        forceFallback: false,
165        maxFiles: uploadMultiple ? maxFiles : 1,
166        // maxFilesize:1000,
167
168
169        parallelUploads: 1,
170
171      });
172
173
174
175
176      if (!uploadMultiple) {
177        // alert("exccened");
178        uploader.on("maxfilesexceeded", function (file) {
179          this.removeAllFiles();
180          this.addFile(file);
181        });
182
183      }
184
185      if ($this.attr("data-images")) {
186
187        var existingFiles = JSON.parse($this.attr('data-images'));
188
189        for (var i = 0; i < existingFiles.length; i++) {
190          console.log(existingFiles[i]);
191          var mockFile = {
192
193            name: existingFiles[i].split('/').pop(),
194            size: 12345,
195            status: Dropzone.ADDED,
196            url: existingFiles[i]
197          };
198
199          uploader.emit("addedfile", mockFile);
200          uploader.emit("thumbnail", mockFile, existingFiles[i]);
201          uploader.emit("complete", mockFile);
202          uploader.emit("success", mockFile);
203
204          uploader.files.push(mockFile);
205
206
207        }
208
209      }
210
211      uploader.on("success", function (file, response) {
212        // console.log(file.xhr.response.ss);
213        // console.log(response);
214        // console.log(file);
215        file.newName = response.fileName;
216        file.filename = response.fileName;
217
218        console.log(response);
219        if (!response.status) {
220
221          alert(response.message);
222          uploader.removeFile(file);
223        } else {
224
225          output.val(output.val() + "|" + response.fileName)
226        }
227
228      });
229      uploader.on("error", function (file, errorMessage) {
230
231        console.log("erorr");
232        alert(errorMessage);
233        // console.log(file);
234        // alert("حصلت مشكلة يرجى إعادة المحاولة ");
235        uploader.removeFile(file);
236
237      });
238
239      uploader.on("removedfile", function (file, data) {
240        console.log(file);
241
242
243        // $.ajax({
244        // 	url: base_url + "/ajax/remove-ad-image",
245        // 	cache: false,
246        // 	type: "post",
247        // 	data: { "name": file.name },
248        // 	error: function (data) {
249
250        // 		console.log(data);
251        // 	}
252
253        // });
254
255        output.val(output.val().replace(file.url, ""));
256        output.val(output.val().replace(file.name, ""));
257        if (file.newName != null) {
258
259
260          output.val(output.val().replace(file.newName, ""));
261        }
262
263      });
264
265
266    }
267
268  }
269
270
271  apiForm(".api-form", (data) => {
272
273
274  }, (error) => { });
275
276
277
278
279  apiForm("#check-ssn-form", (data) => {
280
281    // window.location = data.redirect;
282
283    $(".ssn-container").slideUp(500);
284    $(".main-info-container").slideDown(500);
285    $(".main-info-container").find("input[name='ssn']").val($(".ssn-container").find("input[name='ssn']").val());
286
287  }, (error) => { });
288
289  apiForm("#add-action-form", (data) => {
290
291    // window.location = data.redirect;
292    setTimeout(function () {
293
294
295      $("#add-action-modal").modal('hide');
296    }, 1000);
297
298  }, (error) => { });
299
300
301  apiForm("#contact-form", (data) => {
302
303    // window.location = data.redirect;
304
305
306  }, (error) => { });
307
308
309
310  apiForm(".register-form", (data) => {
311
312    window.location = data.redirect;
313    $(".register-container").css("min-height", $(".register-container > div > .row.active").height() + 20)
314
315
316  }, (error) => {
317
318    setTimeout(function () {
319
320      $(".register-container").css("min-height", $(".register-container > div > .row.active").height() + 20)
321
322    }, 50);
323  });
324
325
326
327  apiForm("#add-note-form", (data) => {
328
329    // window.location = data.redirect;
330    setTimeout(function () {
331
332
333      $("#add-note-modal").modal('hide');
334    }, 1000);
335
336  }, (error) => { });
337
338
339  apiForm("#register-guider-form", (data) => {
340
341    window.location = data.redirect;
342
343
344  }, (error) => { });
345  apiForm("#register-supervisor-form", (data) => {
346
347
348
349  }, (error) => { });
350
351
352
353  apiForm("#update-student-form", (data) => {
354
355    // window.location = data.redirect;
356
357    // $(".ssn-container").slideUp(500);
358    // $(".main-info-container").slideDown(500);
359    // $(".main-info-container").find("input[name='ssn']").val($(".ssn-container").find("input[name='ssn']").val());
360
361  }, (error) => { });
362
363
364  apiForm("#user-login-form", (data) => {
365
366    window.location = data.redirect;
367
368
369  }, (error) => { });
370
371
372
373
374  $("body").on("click", ".register-payment-info", function (e) {
375    e.preventDefault();
376    var $this = $(this);
377    $("#register-payment-info-modal .modal-body").attr("data-register-id", $this.attr('data-register-id'));
378
379    $("#register-payment-info-modal").modal("show");
380    $("#register-payment-info-modal .modal-body").html('<div class="loadingio-spinner-eclipse-32u0grrfoj8 block"><div class="ldio-6vy4x6221wn"><div></div></div></div>');
381    $.ajax({
382      url: $this.attr("href"),
383      type: "GET",
384      success: function (data) {
385
386        $("#register-payment-info-modal .modal-body").html(data.html);
387
388      },
389      error: function (data) {
390        $("#register-payment-info-modal .modal-body").html("<p class='alert alert-danger'>حصلت مشكلة ، يرجى إعادة المحاولة</p>");
391
392      },
393    });
394
395
396  });
397
398  $("body").on("submit", "#update-modal-form", function (e) {
399
400    e.preventDefault();
401    var submit = $("#modal-update-submit");
402
403
404
405    submit.html("<div class='loading-spinner'></div>").attr("disabled", "disabled");
406
407    // var json = JSON.parse($("#update-modal-json-args").val());
408
409    $.ajax({
410      url: $("#update-modal-ajax-url").val(),
411      type: "POST",
412
413      dataType: "json",
414      success: function (data) {
415        console.log(data);
416
417
418        if (data.status) {
419          $("#update-modal").modal("hide");
420
421          $($("#update-modal-replace-element").val()).parents("tr").replaceWith(data.html);
422
423        }
424        showAlert(data.message);
425
426        submit.removeAttr("disabled").html("تنفيذ");
427      },
428      error: function (data) {
429        console.log(data);
430
431        showAlert("حصلت مشكلة ، يرجى تحديث الصفحة");
432        submit.removeAttr("disabled").html("تنفيذ");
433
434
435      }
436    });
437
438    return false;
439
440  });
441  // fold all collapses
442
443
444  $("body").on("click", ".payment-options a", function (e) {
445    e.preventDefault();
446    var $this = $(this);
447    var label = $this.html();
448    $this.text("جاري التنفيذ ...");
449
450
451    $.ajax({
452      url: $this.attr("href"),
453      type: "POST",
454
455      dataType: "json",
456      success: function (data) {
457        console.log(data);
458
459
460        if (data.status) {
461          $("#register-payment-info-modal").modal("hide");
462
463          var id = $("#register-payment-info-modal .modal-body").attr("data-register-id");
464          $("#" + id).replaceWith(data.html);
465          $this.text("تم التنفيذ ");
466
467
468        } else {
469
470          $this.html(label);
471        }
472        showAlert(data.message);
473
474      },
475      error: function (data) {
476        console.log(data);
477
478        showAlert("حصلت مشكلة ، يرجى تحديث الصفحة");
479        $this.html(label);
480
481
482
483      }
484    });
485  });
486
487  $(".collapse").not('.show').collapse('hide');
488
489
490
491  // add hash to any modal or collapse
492
493  var hash = location.hash.replace(/^#/, '');  // ^ means starting, meaning only match the first hash
494
495  if (hash) {
496    $('#' + hash).collapse('show');
497  }
498
499
500
501  // Change hash for page-reload
502  $('body').on('click', '[data-bs-target]', function (e) {
503    window.location.hash = $(this).attr('data-bs-target');
504  })
505
506
507
508  $("body").on("click", ".modal-action", function (e) {
509
510    e.preventDefault();
511
512    updateModal("تنفيذ الإجراء", $(this).attr("data-text"), "#" + $(this).attr("id"), $(this).attr("href"));
513  });
514
515  dropZoneObj("#construction-files-dropZone", true);
516
517  dropZoneObj("#edit-construction-files-dropZone", true);
518
519
520  dropZoneObj("#tender-files-dropZone", true);
521
522  dropZoneObj("#edit-tender-files-dropZone", true);
523
524  dropZoneObj("#user-image-dropzone", false);
525  dropZoneObj("#employer-image-dropzone", false);
526
527
528  dropZoneObj("#government-image-dropzone", false);
529  dropZoneObj("#company-image-dropzone", false);
530
531
532
533  dropZoneObj("#user-passport-dropzone", false);
534  dropZoneObj("#employer-passport-dropzone", false);
535
536
537  dropZoneObj("#government-premit-dropzone", false);
538  dropZoneObj("#company-premit-dropzone", false);
539
540
541
542
543
544  // dropZoneObj(".dropzone-def", true);
545
546
547  dropZoneObj("#product-images-dropZone", true);
548  dropZoneObj("#edit-product-images-dropZone", true);
549
550
551  dropZoneObj("#haraj-images-dropZone", true);
552  dropZoneObj("#edit-haraj-images-dropZone", true);
553
554  dropZoneObj("#home-service-images-dropZone", true);
555  dropZoneObj("#edit-home-service-images-dropZone", true);
556  dropZoneObj("#home-service-files-dropZone", true);
557
558
559  dropZoneObj("#rental-images-dropZone", true);
560  dropZoneObj("#edit-rental-images-dropZone", true);
561  dropZoneObj("#rental-files-dropZone", true);
562
563
564
565  dropZoneObj("#freelancer-images-dropZone", true);
566  dropZoneObj("#edit-freelancer-images-dropZone", true);
567  dropZoneObj("#freelancer-files-dropZone", true);
568
569
570
571  dropZoneObj("#realtor-images-dropZone", true);
572  dropZoneObj("#edit-realtor-images-dropZone", true);
573  dropZoneObj("#realtor-files-dropZone", true);
574
575
576
577  dropZoneObj("#technician-images-dropZone", true);
578  dropZoneObj("#edit-technician-images-dropZone", true);
579  dropZoneObj("#technician-files-dropZone", true);
580
581
582
583  dropZoneObj("#pprofile-images-dropZone", true);
584  dropZoneObj("#edit-pprofile-images-dropZone", true);
585  dropZoneObj("#pprofile-files-dropZone", true);
586  dropZoneObj("#pprofile-attachments-dropZone", true);
587
588
589  $(".select-city-district .ver-slider-cities .quick-filter-button").click(function () {
590
591
592
593    // get districts 
594
595    var parent = $(this).parents(".select-city-district");
596
597    var val = $(this).attr("data-city-id");
598
599    var districtsContainer = parent.find(".ver-slider-districts .splide__list");
600    $.ajax({
601
602
603      type: "post",
604      url: baseUrl + "/api/city/" + val + "/html-districts",
605      data: {},
606      processData: false,
607      contentType: false,
608      // async: false,
609      cache: false,
610      dataType: 'json',
611      success: function (data) {
612
613
614
615
616
617        if (data.status) {
618          var newClassName = data.newClassName;
619          districtsContainer.html(data.html);
620
621          var s = new Splide(".ver-slider-districts");
622          s.destroy();
623          var splide = new Splide(".ver-slider-districts", {
624            type: 'slide',
625            rewind: false,
626            dots: false,
627            loop: false,
628
629            drag: 'free',
630            autoWidth: true,
631            pagination: false,
632            duration: 1000,
633            autoplay: false,
634            direction: 'rtl',
635            autoScroll: {
636              speed: 1,
637            },
638            paginationDirection: "rtl",
639          });
640
641
642          splide.mount();
643
644        } else {
645          responseP.addClass('alert-danger alert');
646
647
648
649          onError(data);
650
651        }
652
653
654
655      },
656      error: function (error) {
657
658
659        console.log(error);
660      }
661
662
663    });
664
665  });
666
667
668  $("body").on( "change" , ".select-city-district .city-select" ,  function () {
669
670
671
672    // get districts 
673
674    var parent = $(this).parents(".select-city-district");
675    var val = $(this).val();
676
677    var districtsSelect = parent.find(".district-select");
678
679    districtsSelect.html("<option value=''>يرجى الإنتظار</option>");
680    $.ajax({
681
682
683      type: "post",
684      url: baseUrl + "/api/city/" + val + "/districts",
685      data: {},
686      processData: false,
687      contentType: false,
688      // async: false,
689      cache: false,
690      dataType: 'json',
691      success: function (data) {
692
693
694
695
696
697        if (data.status) {
698
699          districtsSelect.html(data.html);
700        } else {
701          responseP.addClass('alert-danger alert');
702
703
704          districtsSelect.html("<option value=''>لا توجد مناطق لهذه المدينة</option>");
705
706          onError(data);
707
708        }
709
710
711
712      },
713      error: function (error) {
714
715        districtsSelect.html("<option value=''>حصلت مشكلة  يرجى إختيار مدينة اخرى</
715option>");
716
717        console.log(error);
718      }
719
720
721    });
722
723  });
724
725  $(".select-pprofile-category .pprofile-select").change(function () {
726
727
728    // get districts 
729
730    var parent = $(this).parents(".select-pprofile-category");
731    var val = $(this).val();
732
733    var catsSelect = parent.find(".category-select");
734
735    catsSelect.html("<option value=''>يرجى الإنتظار</option>");
736    $.ajax({
737
738
739      type: "post",
740      url: baseUrl + "/api/pprofile/" + val + "/categories",
741      data: {},
742      processData: false,
743      contentType: false,
744      // async: false,
745      cache: false,
746      dataType: 'json',
747      success: function (data) {
748
749
750
751
752
753        if (data.status) {
754
755          catsSelect.html(data.html);
756        } else {
757          responseP.addClass('alert-danger alert');
758
759
760          catsSelect.html("<option value=''>لا توجد   تخصصات فرعية لهذا التخصص</option>");
761
762          onError(data);
763
764        }
765
766
767
768      },
769      error: function (error) {
770
771        catsSelect.html("<option value=''>حصلت مشكلة  يرجى إختيار تخصص  آخر </option>");
772
773        console.log(error);
774      }
775
776
777    });
778
779  });
780
781
782  $(".filter-category-button").click(function (e) {
783
784
785    // alert();
786
787    $(".filter-category-button.active").removeClass("active");
788
789    $(this).addClass("active");
790    e.preventDefault();
791
792    var parent = $(this).parents(".filters-container");
793
794
795    parent.find(".filter-category-id").val($(this).attr("data-category-id"));
796
797
798    parent.find(".filter-form").submit();
799  });
800
801
802
803
804  $(".filter-city-button").click(function (e) {
805
806
807    // alert();
808
809    $(".filter-city-button.active").removeClass("active");
810
811    $(this).addClass("active");
812    e.preventDefault();
813
814    var parent = $(this).parents(".filters-container");
815
816
817    parent.find(".filter-city-id").val($(this).attr("data-city-id"));
818
819
820    parent.find(".filter-form").submit();
821  });
822
823
824  $("body").on("click", ".filter-district-button", function (e) {
825
826
827    // alert();
828
829    $(".filter-district-button.active").removeClass("active");
830
831    $(this).addClass("active");
832    e.preventDefault();
833
834    var parent = $(this).parents(".filters-container");
835
836
837    parent.find(".filter-district-id").val($(this).attr("data-district-id"));
838
839
840    parent.find(".filter-form").submit();
841  });
842
843
844
845  $(".filters-container select ,.filters-container input ").change(function (e) {
846
847
848    var parent = $(this).parents(".filters-container");
849
850    parent.find(".filter-form").submit();
851
852  });
853
854  $(".filters-container .filter-form").submit(function (e) {
855
856
857    e.preventDefault();
858
859    var form = $(this);
860
861
862
863
864    $(".loading-container").show();
865
866    $(".services-grid").html("");
867
868
869
870
871    $.ajax({
872
873
874      type: $(form).attr("method"),
875      url: $(form).attr("action"),
876      data: form.serialize(),
877      processData: false,
878      contentType: false,
879      // async: false,
880      // cache: false,
881      dataType: 'json',
882      success: function (data) {
883
884        if (data.status) {
885
886          $(".loading-container").hide();
887
888          $(".services-grid").html(data.html);
889
890        } else {
891
892
893          $(".loading-container").hide();
894
895          $(".services-grid").html("<div class='alert alert-danger'>لا توجد نتائج لهذه البحث</div>");
896
897
898        }
899
900
901
902      },
903      error: function (error) {
904        form.removeClass("loading");
905
906        if (error.status == 422) {
907
908          responseP.removeClass('alert-danger alert-success').addClass('alert-danger alert').html("");
909          $.each(error.responseJSON.errors, function (key, value) {
910            responseP.append('<span>' + value + '</span>');
911          });
912        } else {
913          form.find('.response-message').removeClass('alert-danger alert-success').addClass('alert-danger alert').text("حصلت مشكلة ، يرجى إعادة المحاولة").removeAttr("disabled");
914
915          // responseP.append('<span>' + error.responseJSON.message + '</span>');
916        }
917
918
919
920        console.log(error);
921        submit.removeAttr("disabled").html(content);
922      }
923
924
925    });
926
927  });
928
929
930  $(".add-to-favorite").click(function (e) {
931
932
933    e.preventDefault();
934
935    var $this = $(this);
936
937    let content = $this.html();
938
939    if ($this.hasClass("button")) {
940      $this.find('span').text('يرجى الإنتظار');
941      // $this.find('i').html('<i class="fi fi-rr-loading"></i>');
942    } else {
943      $this.html('<i class="fi fi-rr-loading"></i>');
944
945    }
946
947    $.ajax({
948
949
950      type: "post",
951      url: $this.attr("href"),
952
953      // processData: false,
954      // contentType: false,
955      // async: false,
956      // cache: false,
957      dataType: 'json',
958      success: function (data) {
959
960        if (data.status) {
961
962
963          if ($this.hasClass("button")) {
964            $this.find('span').text(data.label);
965            $this.find('i').html(data.html);
966          } else {
967            $this.html(data.html);
968
969          }
970        } else {
971
972
973          alert(data.message);
974
975          $this.html(content);
976
977        }
978
979
980
981      },
982      error: function (error) {
983        $this.html(content);
984
985
986        alert("حصلت مشكلة ، يرجى إعادة المحاولة");
987      }
988
989
990    });
991
992  });
993
994
995  $(".share-link-button").click(function () {
996
997
998
999    $("#share-modal").modal("show");
1000
1001    var link = $(this).attr("data-link");
1002
1003
1004  });
1005
1006
1007  $("body").on("click", ".reset-modal-link", function (e) {
1008    
1009    $("#login-modal").modal("hide");
1010  });
1011
1012});

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.