This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| self.addEventListener('install', function(event) { | |
| console.log(caches) | |
| console.log("SW Install Event: Is in the process"); | |
| const onSuccessCachesOpen = (cache) => { | |
| console.log(cache) | |
| console.log("SW Install Event: Successfully opened the cache and add the cache list"); | |
| return cache.addAll(CACHE_LIST) | |
| } | |
| // Works like async/await |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| self.addEventListener('install', function(event) { | |
| console.log("SW Install Event: Is in the process"); | |
| }) | |
| self.addEventListener('activate', (event) => { | |
| console.log("SW Activate Event: Is in the process") | |
| }) | |
| self.addEventListener('fetch', (event) => { | |
| console.log("SW Fetch Event: Is in the process"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| body, html { | |
| margin: 0; | |
| padding: 0; | |
| } | |
| body { | |
| height: 100%; | |
| background-color: var(--dark); | |
| color: var(--white); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "short_name": "PWA", | |
| "name": "Progressive Web App", | |
| "lang": "en", | |
| "background_color": "#343a40", | |
| "theme_color": "#343a40", | |
| "display": "standalone", | |
| "scope": "/", | |
| "start_url": "/", | |
| "icons": [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function() { | |
| function init() { | |
| if ('serviceWorker' in navigator) { | |
| const onSuccessRegister = (registration) => console.log("SW Register Success: ", registration.scope) | |
| const onErrorRegister = (error) => console.log("SW Register Error: ",error) | |
| navigator.serviceWorker.register('/sw.js') | |
| .then(onSuccessRegister) | |
| .catch(onErrorRegister) | |
| } else console.log('Your browser do not support service worker') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>PWA</title> | |
| <link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.3/css/bootstrap.min.css'/> | |
| <link rel="stylesheet" href="main.css"> | |
| <link rel="manifest" href="manifest.json"> | |
| <link rel="shortcut icon" href="images/icon-72x72.png" type="image/x-icon"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require("express"); | |
| const app = express(); | |
| const path = require("path"); | |
| const PORT = 4000 || process.env.NODE_ENV; | |
| app.use(express.static(path.join(__dirname, "static"))); | |
| app.use("/", (_request, response) => { | |
| return response.sendFile(path.join(__dirname, "index.html")); | |
| }); |
NewerOlder