updated public key

This commit is contained in:
cpu
2025-03-26 21:01:18 +01:00
parent fc278ed256
commit 3561db616c

35
app.js
View File

@@ -10,7 +10,9 @@ let carouselPosition = 0;
let startX = 0;
let currentX = 0;
let pushSubscription = null;
const PUBLIC_VAPID_KEY = 'BNIXGVBzq6SNqvlDMFylw_hLTpf_J96ddbwfMa9Cn1tFQ1-vDqmz_NQS0a5UiczqAJ-uYs-6EeuwrnwaMRGtifk=';
const PUBLIC_VAPID_KEY = 'BKfRJXjSQmAJ452gLwlK_8scGrW6qMU1mBRp39ONtcQHkSsQgmLAaODIyGbgHyRpnDEv3HfXV1oGh3SC0fHxY0E';
const BACKEND_URL = 'https://webpush.virtonline.eu';
const BUTTON_ID = 'your_button1_serial';
// DOM Elements
const carousel = document.getElementById('carousel');
@@ -49,12 +51,15 @@ async function subscribeToPushNotifications() {
});
// Send subscription to your server
await fetch('https://webpush.virtonline.eu/subscribe', {
await fetch(`${BACKEND_URL}/subscribe`, {
method: 'POST',
body: JSON.stringify(subscription),
body: JSON.stringify({
button_id: BACKEND_URL,
subscription: subscription // The PushSubscription object
}),
headers: {
'Content-Type': 'application/json'
}
},
});
pushSubscription = subscription;
@@ -220,13 +225,11 @@ gameButton.addEventListener('click', () => {
gameState = 'paused';
audioManager.play('gamePause');
stopTimer();
// sendPushNotification('Game Paused', 'The game timer has paused!');
break;
case 'paused':
gameState = 'running';
audioManager.play('gameResume');
startTimer();
// sendPushNotification('Game Resumed', 'The game timer has resumed!');
break;
case 'over':
// Reset timers and start new game
@@ -243,26 +246,6 @@ gameButton.addEventListener('click', () => {
saveData();
});
async function sendPushNotification(title, message) {
if (!pushSubscription) return;
try {
await fetch('https://webpush.virtonline.eu/flic-webhook', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
title: title,
body: message,
action: 'game_update'
})
});
} catch (error) {
console.error('Error sending push notification:', error);
}
}
// Timer variables
let timerInterval = null;