-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update PWA features and fix bugs (#5)
* Add footer styles and update styles.css * configuring package manager * Initializing PWA features * Implementing PWA and W3.CSS * Files cleanup * bugfix * bugfixes for sw.js * fixes manifest url for Pages * Fix broken image URLs and update manifest start_url in README.md, manifest.webmanifest, and index.html
- Loading branch information
1 parent
eb360b8
commit d10efbe
Showing
5 changed files
with
82 additions
and
74 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// register-sw.js | ||
if ('serviceWorker' in navigator) { | ||
window.addEventListener('load', function() { | ||
const scope = window.location.pathname; | ||
navigator.serviceWorker.register(scope + 'sw.js', {scope: scope}).then(function(registration) { | ||
console.log('ServiceWorker registration successful with scope: ', registration.scope); | ||
// Register backgroundSync | ||
registration.sync.register('fetch-new-content').then(() => { | ||
console.log('Background Sync registered'); | ||
}, function(err) { | ||
console.log('Background Sync registration failed: ', err); | ||
}); | ||
// Check support for periodicSync and register | ||
if ('periodicSync' in registration) { | ||
registration.periodicSync.register('fetch-new-content', { | ||
minInterval: 24 * 60 * 60 * 1000, // 1 day | ||
}).then(() => { | ||
console.log('Periodic Sync registered'); | ||
}, function(err) { | ||
console.log('Periodic Sync registration failed: ', err); | ||
}); | ||
} | ||
}, function(err) { | ||
console.log('ServiceWorker registration failed: ', err); | ||
}); | ||
}); | ||
} |
This file contains 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