Skip to content

Commit

Permalink
update PWA pour fonctionner avec IOS, pour de vrai
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianLatapie committed Apr 6, 2024
1 parent 6adaa88 commit c6fdcf3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion PWA/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h1>Bienvenue dans l'installeur de FlorianLatapie/Config</h1>
<div>
<div class="flexRow">
Appuyez sur
<svg width="31" height="30" viewBox="0 0 31 30" fill="none" xmlns="http://www.w3.org/2000/svg">
<svg width="31" height="30" viewBox="0 0 31 30" fill="none" xmlns="http://www.w3.org/2000/svg"> <!-- vient du site https://fr.trygalaxy.com/ -->
<rect x="0.5" width="30" height="30" rx="8" fill="#F2F2F2"></rect>
<path d="M18.5855 11.4102H20.5C21.6046 11.4102 22.5 12.3056 22.5 13.4102V22.4102C22.5 23.5147 21.6046 24.4102 20.5 24.4102H10.5C9.39543 24.4102 8.5 23.5147 8.5 22.4102V13.4102C8.5 12.3056 9.39543 11.4102 10.5 11.4102H12.2303" stroke="#0381FE" stroke-linecap="round"></path>
<path d="M12.6768 8.41341L15.2507 5.83944C15.3886 5.70161 15.612 5.70161 15.7499 5.83944L18.3238 8.41341M15.5003 16.8251V5.58984" stroke="#0381FE" stroke-linecap="round"></path>
Expand Down
32 changes: 15 additions & 17 deletions PWA/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,30 @@ if ('serviceWorker' in navigator) {
.catch((e) => { console.log('Service Worker Registration Failed'); console.error(e); });
}


let deferredPrompt;
const installBtn = document.getElementById('installBtn');
const iosText = document.getElementById("iosText");

console.log(localStorage.getItem('a2hs'));

if (localStorage.getItem('a2hs') === 'accepted') {
installBtn.style.display = 'none';
}

const installBtn = document.getElementById('installBtn');
const iosText = document.getElementById("iosText");

var isIOS = /Mac|iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;

if (isIOS) {
installBtn.style.display = "none";
iosText.style.display = "block";
} else {
installBtn.style.display = "block";
iosText.style.display = "none";
}

let deferredPrompt;
window.addEventListener('beforeinstallprompt', (e) => {
e.preventDefault();
deferredPrompt = e;

if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
installBtn.style.display = "none";
iosText.style.display = "block";
console.log("ios");
} else {
installBtn.style.display = "block";
iosText.style.display = "none";
console.log("not ios");
}
installBtn.addEventListener('click', () => {
installBtn.style.display = 'none';

Expand Down Expand Up @@ -66,10 +65,9 @@ goHomeBtn.addEventListener('click', () => {
});

goRepoBtn.addEventListener('click', () => {
window.location.href = "https://github.com/florianlatapie/config";
window.open("https://github.com/florianlatapie/config", "_self");
});


function gotoHome() {
window.location.href = "../";
window.open("../", "_self");
}

0 comments on commit c6fdcf3

Please sign in to comment.