Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
Subhajit-2023-44 committed Nov 8, 2024
1 parent 3bfa9f9 commit 245d152
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 0 deletions.
Binary file added icon-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "NexTrade",
"short_name": "NexTrade",
"start_url": "/",
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#000000",
"icons": [
{
"src": "/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}

14 changes: 14 additions & 0 deletions scripts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Register the service worker
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/sw.js') // Pointing to the sw.js file
.then(registration => {
console.log('ServiceWorker registration successful:', registration);
})
.catch(error => {
console.error('ServiceWorker registration failed:', error);
});
});


}
46 changes: 46 additions & 0 deletions sw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const CACHE_NAME = 'my-pwa-cache-v1';
const urlsToCache = [
'/',
'/index.html',
'/styles.css',
'/scripts.js',
'/manifest.json',
'/icon-192x192.png',
'/icon-512x512.png'
];


self.addEventListener('install', (event) => {
event.waitUntil(
caches.open(CACHE_NAME)
.then((cache) => {
return cache.addAll(urlsToCache);
})
);
});


self.addEventListener('fetch', (event) => {
event.respondWith(
caches.match(event.request)
.then((response) => {
return response || fetch(event.request);
})
);
});


self.addEventListener('activate', (event) => {
const cacheWhitelist = [CACHE_NAME];
event.waitUntil(
caches.keys().then((cacheNames) => {
return Promise.all(
cacheNames.map((cacheName) => {
if (!cacheWhitelist.includes(cacheName)) {
return caches.delete(cacheName);
}
})
);
})
);
});
3 changes: 3 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<link rel="stylesheet" href="styles.css"> <!-- Link to your CSS file -->
<link rel="manifest" href="/manifest.json">

<style>
body {
Expand Down Expand Up @@ -253,6 +254,8 @@
</style>
</head>
<body>

<script src="scripts.js"></script> <!-- Link to your service worker registration script -->
<div class="gtranslate_wrapper"></div>
<script>
window.gtranslateSettings = {
Expand Down

0 comments on commit 245d152

Please sign in to comment.