Initial commit

This commit is contained in:
Allen
2026-04-30 02:14:25 +00:00
commit 7090e6f01d
243 changed files with 115122 additions and 0 deletions
+56
View File
@@ -0,0 +1,56 @@
// Push notification handler for GamerComp PWA
// This file is loaded by the service worker via importScripts
self.addEventListener('push', function(event) {
if (!event.data) return;
try {
const data = event.data.json();
const options = {
body: data.body || 'You have a new notification',
icon: '/icon.svg',
badge: '/icon.svg',
vibrate: [100, 50, 100],
data: {
url: data.url || '/'
},
actions: [
{ action: 'open', title: 'Open' }
]
};
event.waitUntil(
self.registration.showNotification(data.title || 'GamerComp', options)
);
} catch (err) {
// Fallback for non-JSON payloads
event.waitUntil(
self.registration.showNotification('GamerComp', {
body: event.data.text(),
icon: '/icon.svg'
})
);
}
});
self.addEventListener('notificationclick', function(event) {
event.notification.close();
const url = event.notification.data?.url || '/';
event.waitUntil(
clients.matchAll({ type: 'window', includeUncontrolled: true }).then(function(clientList) {
// Try to focus an existing window
for (const client of clientList) {
if (client.url.includes('gamercomp.com') && 'focus' in client) {
client.navigate(url);
return client.focus();
}
}
// Open new window if none exists
if (clients.openWindow) {
return clients.openWindow(url);
}
})
);
});