From b14b5443aa75b45abaf01d9d3bc13b43adfaa2d0 Mon Sep 17 00:00:00 2001 From: Axok Date: Wed, 30 Mar 2022 11:35:47 +0200 Subject: [PATCH] PWA offline try to check if offline --- server_static/assets/js/index.js | 39 ++++++++++++++++---------------- website/sw.js | 1 + 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/server_static/assets/js/index.js b/server_static/assets/js/index.js index fd0e80a..d60a1d6 100644 --- a/server_static/assets/js/index.js +++ b/server_static/assets/js/index.js @@ -1,6 +1,10 @@ //////////////////////////////////////////////////// // [ Form Login ] (function ($) { + if (!window.navigator.onLine){ + console.log("offline"); + $(".info_message").show(); + } "use strict"; var input = $('.validate-input .input-forms'); $('.validate').on('submit',(function(){ @@ -14,25 +18,22 @@ } if (check){ - if (window.navigator.onLine){ - $.ajax({ - type: 'POST', - url: 'controller/Auth.php', - data: {user: $(input[0]).val().trim(), pass: sha1($(input[1]).val().trim())}, - success: function(data, status, jqXHR) { - console.log(data.trim()); - if (data.trim() == "true"){ - location.href='/'; - } else { - $("#zone-login").addClass("shaking_error"); - setTimeout(function() { - $("#zone-login").removeClass("shaking_error"); - }, 1000); - } - }}); - } else { - $(".info_message").show(); - } + $.ajax({ + type: 'POST', + url: 'controller/Auth.php', + data: {user: $(input[0]).val().trim(), pass: sha1($(input[1]).val().trim())}, + success: function(data, status, jqXHR) { + console.log(data.trim()); + if (data.trim() == "true"){ + location.href='/'; + } else { + $("#zone-login").addClass("shaking_error"); + setTimeout(function() { + $("#zone-login").removeClass("shaking_error"); + }, 1000); + } + }}); + } check = false; return check; diff --git a/website/sw.js b/website/sw.js index 1d60cb2..a244b29 100644 --- a/website/sw.js +++ b/website/sw.js @@ -18,6 +18,7 @@ self.addEventListener('install', (e) => { 'index.php', 'http://ctsstatic.fr/assets/css/index.css', 'http://ctsstatic.fr/assets/js/index.js', + 'http://ctsstatic.fr/assets/images/logo_petit.png', 'http://ctsstatic.fr/assets/vendors/jquery/jquery-3.6.0.min.js' ];