hacky workaround
This commit is contained in:
parent
3785258c57
commit
c10b8f6ee0
2 changed files with 8 additions and 5 deletions
|
|
@ -76,7 +76,7 @@
|
||||||
<script type="module">
|
<script type="module">
|
||||||
function toggleTheme(e) {
|
function toggleTheme(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
fetch('./light-dark-toggle')
|
fetch('./light-dark-toggle?ref=https%3A%2F%2Fpagwin.xyz%2Fstatic%2Fdemos%2Flight-dark-demo-4%2F')
|
||||||
if (!document.body.classList.contains("toggled")) {
|
if (!document.body.classList.contains("toggled")) {
|
||||||
document.body.classList.add("toggled")
|
document.body.classList.add("toggled")
|
||||||
}
|
}
|
||||||
|
|
@ -92,13 +92,16 @@
|
||||||
|
|
||||||
await navigator.serviceWorker.register("sw.js");
|
await navigator.serviceWorker.register("sw.js");
|
||||||
</script>
|
</script>
|
||||||
<p>Don't copy this code at all, it is for demo purposes only and is terrible code. <span class="red">Note: if you
|
<p>Don't copy this code at all, it is for demo purposes only and is terrible code. <span class="red"><br>Note: if
|
||||||
|
you
|
||||||
hard refresh you will get your system preference of light/dark due to this demo being powered by a service
|
hard refresh you will get your system preference of light/dark due to this demo being powered by a service
|
||||||
worker</span></p>
|
worker</span></p>
|
||||||
<form action="./light-dark-toggle" method="get">
|
<form action="./light-dark-toggle" method="get">
|
||||||
|
<input type="hidden" name="ref" value="https://pagwin.xyz/static/demos/light-dark-demo-4/">
|
||||||
<input id="full-demo" type="submit" value="Fully enhanced demo">
|
<input id="full-demo" type="submit" value="Fully enhanced demo">
|
||||||
</form>
|
</form>
|
||||||
<form action="./light-dark-toggle" method="get">
|
<form action="./light-dark-toggle" method="get">
|
||||||
|
<input type="hidden" name="ref" value="https://pagwin.xyz/static/demos/light-dark-demo-4/">
|
||||||
<input id="min-demo" type="submit" value="No javascript simulation">
|
<input id="min-demo" type="submit" value="No javascript simulation">
|
||||||
</form>
|
</form>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,9 @@ self.addEventListener("fetch", event =>{
|
||||||
})
|
})
|
||||||
|
|
||||||
async function handle_redirect(req){
|
async function handle_redirect(req){
|
||||||
const go_back_to = req.headers.get('Referer') || '/';;
|
const url = new URL(event.request.url);
|
||||||
console.log("ref:",req.headers.get('Referer'), go_back_to);
|
const go_back_to = url.searchParams.get('ref') ?? '/';
|
||||||
console.log('All headers:', [...req.headers.entries()]);
|
console.log("ref:",url.searchParams.get('ref'), go_back_to);
|
||||||
const db_req = self.indexedDB.open("light-dark-store");
|
const db_req = self.indexedDB.open("light-dark-store");
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue