update PWA

This commit is contained in:
2023-09-03 11:39:13 +03:00
parent 183ad70df9
commit 89f7ac8204
8 changed files with 3738 additions and 42 deletions

View File

@@ -1,3 +1,5 @@
'use strict';
const container = document.querySelector('.container');
const coffees = [
{ name: 'Tony Stark', image: 'images/Tony_Stark.jpg' },
@@ -12,8 +14,7 @@ const showCoffees = () => {
(output += `
<div class="card">
<img class="card--avatar" src=${image} />
<h1 class="card--title">${name}</h1>
<a class="card--link" href="#">[CLICK]</a>
<p class="card--title">${name}</p>
</div>
`),
);
@@ -21,3 +22,12 @@ const showCoffees = () => {
};
document.addEventListener('DOMContentLoaded', showCoffees);
if ('serviceWorker' in navigator) {
window.addEventListener('load', function () {
navigator.serviceWorker
.register('/sw.js', { scope: '/' })
.then((res) => console.log('Service worker registered'))
.catch((err) => console.log('Service worker not registered', err));
});
}