-
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.
Refactor PWA functionality and file structure (#7)
This pull request refactors the PWA functionality by moving the Service Worker loading script to a separate file called register-sw.js. It also fixes the PWA scope registration to be more universal. Additionally, it adds new PWA functionality for periodicSync.
- Loading branch information
1 parent
82ace57
commit 4d7ca5a
Showing
5 changed files
with
83 additions
and
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
# RSI-Waves2Epochs | ||
![Static Badge](https://img.shields.io/badge/RSI_Waves2Epochs-SC_Open_dev-gold?style=for-the-badge&logo=github&link=https%3A%2F%2Fsc-open.github.io%2FRSI-Waves2Epochs%2F) | ||
![Static Badge](https://img.shields.io/badge/RSI_Waves2Epochs-SC_Open_dev-gold?logo=github&link=https%3A%2F%2Fsc-open.github.io%2FRSI-Waves2Epochs%2F) | ||
|
||
Convert RSI Waves from UTC datetime to Discord Epochs | ||
|
||
This is a simple javascript function that runs in the browser and accepts pasted text input, matches to a regular expression, and outputs the results in converted epoch timestamps compatible with Discord. | ||
This is a simple JavaScript function that runs in the browser and accepts pasted text input, matches to a regular expression, and outputs the results in converted epoch timestamps compatible with Discord. | ||
|
||
[Click Here to Begin](https://sc-open.github.io/RSI-Waves2Epochs/) |
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