2
0
stany.ferer 1 жил өмнө
parent
commit
04825f7e10
1 өөрчлөгдсөн 25 нэмэгдсэн , 14 устгасан
  1. 25 14
      public-events/js/control.js

+ 25 - 14
public-events/js/control.js

@@ -9,17 +9,21 @@ $("#qrr-close").on("click", function () {
 
 function checkEmagementControl() {
     if (checkconnection()) {
-        const currentUrl = window.location;
-        const targetUrl = new URL($("#QRCodeRead").val());
 
-        // Vérifiez si les deux URLs sont du même domaine
-        if (currentUrl.protocol === targetUrl.protocol &&
-            currentUrl.hostname === targetUrl.hostname &&
-            currentUrl.port === targetUrl.port) {
-            
-            // Redirigez vers l'URL cible
-            window.location.replace(targetUrl.href);
-        } else {
+        $.ajax({
+            url: $("#QRCodeRead").val(),
+            dataType: "json",
+            encode: true,
+        }).done(function (data) {
+            $('#ResultQRCode').remove();
+            $("#confirmationModal").append(getConfirmModal(data));
+            $('#ResultQRCode').modal("show");
+            if (data["result"] == true) {
+                $('#ResultQRCode').on('hidden.bs.modal', function () {
+                    getEvements();
+                });
+            }
+        }).fail(function (xhr, status, error) {
             retour = Array;
             retour["result"] = false;
             retour["description"] = "Le QR-Code n'est pas valide";
@@ -29,11 +33,19 @@ function checkEmagementControl() {
             $('#ResultQRCode').remove();
             $("#confirmationModal").append(getConfirmModal(retour));
             $('#ResultQRCode').modal("show");
-        }
+        });
+        $("#QRCodeRead").removeAttr('value');
+
     } else {
         $("#divOffline").empty();
-        $("#divOffline").append('<div class="alert alert-warning" role="alert">Vous n\'êtes pas connecté à internet</div>');
+        $("#divOffline").append('<div class="alert alert-warning alertLogin" role="alert">Vous n\'êtes pas connecté à internet</div>');
         $("#divOffline").show();
+        window.setTimeout(function () {
+            $("#divOffline").fadeTo(600, 0).slideUp(600, function () {
+                $(this).hide();
+                $(this).css('opacity', '1');
+            });
+        }, 1000);
     }
 }
 
@@ -57,7 +69,7 @@ $(document).ready(function () {
                 const value = $("#QRCodeRead").val();
                 console.log("Modification détectée : ", value);
                 if (value !== null && value !== '') {
-                    checkEmagementControl();
+                    checkEmagementSalarie();
                 }
             }
         });
@@ -73,4 +85,3 @@ $(document).ready(function () {
 });
 
 
-