PWA offline try to check if offline

This commit is contained in:
Louis DUMONT 2022-03-30 11:35:47 +02:00
parent 16eab3f5d7
commit b14b5443aa
2 changed files with 21 additions and 19 deletions

View File

@ -1,6 +1,10 @@
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
// [ Form Login ] // [ Form Login ]
(function ($) { (function ($) {
if (!window.navigator.onLine){
console.log("offline");
$(".info_message").show();
}
"use strict"; "use strict";
var input = $('.validate-input .input-forms'); var input = $('.validate-input .input-forms');
$('.validate').on('submit',(function(){ $('.validate').on('submit',(function(){
@ -14,25 +18,22 @@
} }
if (check){ if (check){
if (window.navigator.onLine){ $.ajax({
$.ajax({ type: 'POST',
type: 'POST', url: 'controller/Auth.php',
url: 'controller/Auth.php', data: {user: $(input[0]).val().trim(), pass: sha1($(input[1]).val().trim())},
data: {user: $(input[0]).val().trim(), pass: sha1($(input[1]).val().trim())}, success: function(data, status, jqXHR) {
success: function(data, status, jqXHR) { console.log(data.trim());
console.log(data.trim()); if (data.trim() == "true"){
if (data.trim() == "true"){ location.href='/';
location.href='/'; } else {
} else { $("#zone-login").addClass("shaking_error");
$("#zone-login").addClass("shaking_error"); setTimeout(function() {
setTimeout(function() { $("#zone-login").removeClass("shaking_error");
$("#zone-login").removeClass("shaking_error"); }, 1000);
}, 1000); }
} }});
}});
} else {
$(".info_message").show();
}
} }
check = false; check = false;
return check; return check;

View File

@ -18,6 +18,7 @@ self.addEventListener('install', (e) => {
'index.php', 'index.php',
'http://ctsstatic.fr/assets/css/index.css', 'http://ctsstatic.fr/assets/css/index.css',
'http://ctsstatic.fr/assets/js/index.js', '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' 'http://ctsstatic.fr/assets/vendors/jquery/jquery-3.6.0.min.js'
]; ];