This repository has been archived by the owner on Mar 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Level 2 Web Share + extras
Includes updated service worker with proper scope, notification and working file upload. Disables Level 1 (until spec for using both works correctly) Adds Audio play from gallery (and 3 premade filetype filters) Bump version due to stats.json change.
- Loading branch information
Showing
9 changed files
with
112 additions
and
26 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,3 +1,42 @@ | ||
let version = "0.0.19" | ||
|
||
function poke(topic,body) { | ||
self.registration.showNotification(topic, { | ||
body: body, | ||
tag: 'webshareupload', | ||
badge: new URL("poop96.png",self.registration.scope).toString(), | ||
icon: new URL("poop192.png",self.registration.scope).toString(), | ||
silent: true, | ||
}); | ||
}; | ||
|
||
function uploadDone(req) { | ||
return req.then(function(response) { | ||
if (response.ok) { | ||
poke('Upload Completed'); | ||
} else { | ||
poke('Upload Failed'); | ||
} | ||
return true | ||
}) | ||
} | ||
|
||
self.addEventListener('notificationclick', function(event) { | ||
event.notification.close(); | ||
}); | ||
|
||
self.addEventListener('message', function(event){ | ||
if (event.data == "debug") { poke("Test Notification",version); } | ||
if (event.data == "debug2") { self.registration.showNotification("Test2 Notification", {body: "Hope you are happy now",tag: 'egg',badge: new URL("poop96.png",self.registration.scope).toString(),icon: new URL("poop192.png",self.registration.scope).toString(),vibrate: [500,110,500,110,450,110,200,110,170,40,450,110,200,110,170,40,500]}); } | ||
}); | ||
|
||
self.addEventListener('fetch', function(event) { | ||
event.respondWith(fetch(event.request)); | ||
const url = new URL(event.request.url); | ||
if (event.request.method == 'POST' && url.pathname.endsWith('webshareupload')) { | ||
let req = fetch(event.request); | ||
event.respondWith(req); | ||
poke('Uploading File', 'Please wait while file is uplading'); | ||
event.waitUntil(uploadDone(req)); | ||
} | ||
return event.respondWith(fetch(event.request)); | ||
}); |
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